Skip to content

Commit f925f3a

Browse files
committed
Merge branch '2.11'
2 parents 299d2bc + 01b2d62 commit f925f3a

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

release-notes/VERSION-2.x

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Project: jackson-databind
3939
(reported by Fabian L)
4040
#2560: Check `WRAP_EXCEPTIONS` in `CollectionDeserializer.handleNonArray()`
4141
(reported by Stefan W)
42+
#2564: Fix `IllegalArgumentException` on empty input collection for `ArrayBlockingQueue`
43+
(repoted, fix suggested by yamert89@github)
4244
#2567: Incorrect target type for arrays when providing nulls and nulls are disabled
4345
(reported by João G)
4446

src/main/java/com/fasterxml/jackson/databind/deser/std/ArrayBlockingQueueDeserializer.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ public Collection<Object> deserialize(JsonParser p, DeserializationContext ctxt,
9292
}
9393
// Ok: must point to START_ARRAY (or equivalent)
9494
if (!p.isExpectedStartArrayToken()) {
95-
return handleNonArray(p, ctxt, new ArrayBlockingQueue<Object>(1));
95+
return handleNonArray(p, ctxt, new ArrayBlockingQueue<>(1));
9696
}
97-
result0 = super.deserialize(p, ctxt, new ArrayList<Object>());
98-
if (result0.isEmpty()) return new ArrayBlockingQueue<Object>(1, false);
99-
return new ArrayBlockingQueue<Object>(result0.size(), false, result0);
97+
result0 = super.deserialize(p, ctxt, new ArrayList<>());
98+
if (result0.isEmpty()) {
99+
return new ArrayBlockingQueue<>(1, false);
100+
}
101+
return new ArrayBlockingQueue<>(result0.size(), false, result0);
100102
}
101103

102104
@Override

src/test/java/com/fasterxml/jackson/databind/deser/jdk/MapRelatedTypesDeserTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class MapRelatedTypesDeserTest
99
extends BaseMapTest
1010
{
11-
private final ObjectMapper MAPPER = new ObjectMapper();
11+
private final ObjectMapper MAPPER = newJsonMapper();
1212

1313
/*
1414
/**********************************************************
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.fasterxml.jackson.databind.deser.jdk;
2+
3+
import java.util.Collection;
4+
import java.util.concurrent.ArrayBlockingQueue;
5+
6+
import com.fasterxml.jackson.core.JsonProcessingException;
7+
import com.fasterxml.jackson.databind.*;
8+
9+
public class TestEmptyArrayBlockingQueueDeser extends BaseMapTest
10+
{
11+
static class RemoteEntity{
12+
private Collection<Double> values = new ArrayBlockingQueue<>(20);
13+
14+
public Collection<Double> getValues() {
15+
return values;
16+
}
17+
}
18+
19+
static class Entity{
20+
private ArrayBlockingQueue<Double> values;
21+
22+
public Collection<Double> getValues() {
23+
return values;
24+
}
25+
}
26+
27+
private final ObjectMapper MAPPER = newJsonMapper();
28+
29+
public void testEmptyBlockingQueue() throws Exception
30+
{
31+
String json = MAPPER.writeValueAsString(new RemoteEntity());
32+
Entity entity = MAPPER.readValue(json, Entity.class);
33+
assertEquals(0, entity.values.size());
34+
}
35+
}

0 commit comments

Comments
 (0)