[Git][java-team/jackson-jr][upstream] New upstream version 2.9.9
Markus Koschany
gitlab at salsa.debian.org
Sun Jul 21 23:30:20 BST 2019
Markus Koschany pushed to branch upstream at Debian Java Maintainers / jackson-jr
Commits:
89ff3919 by Markus Koschany at 2019-07-21T22:20:53Z
New upstream version 2.9.9
- - - - -
15 changed files:
- jr-all/pom.xml
- jr-objects/pom.xml
- jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/ArrayReader.java
- jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/BeanPropertyReader.java
- jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/BeanReader.java
- jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/CollectionReader.java
- jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/JSONReader.java
- jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/MapReader.java
- jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/TypeDetector.java
- + jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/ReadListTest.java
- jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/ReadMapTest.java
- jr-retrofit2/pom.xml
- jr-stree/pom.xml
- pom.xml
- release-notes/VERSION
Changes:
=====================================
jr-all/pom.xml
=====================================
@@ -5,7 +5,7 @@
<parent>
<groupId>com.fasterxml.jackson.jr</groupId>
<artifactId>jackson-jr-parent</artifactId>
- <version>2.9.8</version>
+ <version>2.9.9</version>
</parent>
<artifactId>jackson-jr-all</artifactId>
<name>jackson-jr-all</name>
=====================================
jr-objects/pom.xml
=====================================
@@ -3,7 +3,7 @@
<parent>
<groupId>com.fasterxml.jackson.jr</groupId>
<artifactId>jackson-jr-parent</artifactId>
- <version>2.9.8</version>
+ <version>2.9.9</version>
</parent>
<artifactId>jackson-jr-objects</artifactId>
<packaging>bundle</packaging>
=====================================
jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/ArrayReader.java
=====================================
@@ -24,7 +24,7 @@ public class ArrayReader extends ValueReader
if (p.hasToken(JsonToken.VALUE_NULL)) {
return null;
}
- return JSONObjectException.from(p, "Unexpected token "+p.getCurrentToken()+"; should get START_ARRAY");
+ throw JSONObjectException.from(p, "Unexpected token "+p.getCurrentToken()+"; should get START_ARRAY");
}
CollectionBuilder b = r._collectionBuilder(null);
=====================================
jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/BeanPropertyReader.java
=====================================
@@ -81,8 +81,11 @@ public final class BeanPropertyReader
if (t instanceof InvocationTargetException) {
t = t.getCause();
}
- throw new JSONObjectException("Failed to set property '"+_name+"'; exception "+e.getClass().getName()+"): "
- +t.getMessage(), t);
+ final String valueTypeDesc = (value == null) ? "NULL" : value.getClass().getName();
+ throw new JSONObjectException(String.format(
+ "Failed to set property '%s' (raw type %s) to value of type %s; exception (%s): %s",
+ _name, _rawType().getName(), valueTypeDesc, e.getClass().getName(), t.getMessage()),
+ t);
}
}
@@ -93,6 +96,13 @@ public final class BeanPropertyReader
return _field.getDeclaringClass().getName();
}
+ protected Class<?> _rawType() {
+ if (_setter != null) {
+ return _setter.getParameterTypes()[0];
+ }
+ return _field.getType();
+ }
+
@Override
public String toString() {
return _name;
=====================================
jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/BeanReader.java
=====================================
@@ -118,8 +118,8 @@ public class BeanReader
handleUnknown(r, p, propName);
continue;
}
- ValueReader vr = prop.getReader();
- prop.setValueFor(bean, vr.readNext(r, p));
+ final Object value = prop.getReader().readNext(r, p);
+ prop.setValueFor(bean, value);
}
// also verify we are not confused...
if (!p.hasToken(JsonToken.END_OBJECT)) {
=====================================
jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/CollectionReader.java
=====================================
@@ -34,7 +34,7 @@ public class CollectionReader extends ValueReader
if (p.hasToken(JsonToken.VALUE_NULL)) {
return null;
}
- return JSONObjectException.from(p, "Unexpected token "+p.getCurrentToken()+"; should get START_ARRAY");
+ throw JSONObjectException.from(p, "Unexpected token "+p.getCurrentToken()+"; should get START_ARRAY");
}
CollectionBuilder b = r._collectionBuilder(_collectionType);
if (p.nextToken() == JsonToken.END_ARRAY) {
=====================================
jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/JSONReader.java
=====================================
@@ -245,7 +245,8 @@ public class JSONReader
@SuppressWarnings("unchecked")
public <T> T readBean(Class<T> type) throws IOException {
ValueReader vr = _typeDetector.findReader(type);
- return (T) vr.read(this, _parser);
+ final Object ob = vr.read(this, _parser);
+ return (T) ob;
}
@SuppressWarnings("unchecked")
=====================================
jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/MapReader.java
=====================================
@@ -27,7 +27,7 @@ public class MapReader extends ValueReader
if (p.hasToken(JsonToken.VALUE_NULL)) {
return null;
}
- return JSONObjectException.from(p, "Unexpected token "+p.getCurrentToken()+"; should get START_OBJECT");
+ throw JSONObjectException.from(p, "Unexpected token "+p.getCurrentToken()+"; should get START_OBJECT");
}
MapBuilder b = r._mapBuilder(_mapType);
=====================================
jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/TypeDetector.java
=====================================
@@ -517,16 +517,18 @@ public class TypeDetector
protected ValueReader collectionReader(Class<?> collectionType, ResolvedType valueType)
{
- Class<?> raw = valueType.erasedType();
- if (Collection.class.isAssignableFrom(raw)) {
+ final Class<?> rawValueType = valueType.erasedType();
+ final ValueReader valueReader;
+ if (Collection.class.isAssignableFrom(rawValueType)) {
List<ResolvedType> params = valueType.typeParametersFor(Collection.class);
- return collectionReader(raw, params.get(0));
- }
- if (Map.class.isAssignableFrom(raw)) {
+ valueReader = collectionReader(rawValueType, params.get(0));
+ } else if (Map.class.isAssignableFrom(rawValueType)) {
List<ResolvedType> params = valueType.typeParametersFor(Map.class);
- return mapReader(raw, params.get(1));
+ valueReader = mapReader(rawValueType, params.get(1));
+ } else {
+ valueReader = createReader(null, rawValueType, rawValueType);
}
- return new CollectionReader(collectionType, createReader(null, raw, raw));
+ return new CollectionReader(collectionType, valueReader);
}
protected ValueReader mapReader(Class<?> contextType, Type mapType)
@@ -535,19 +537,21 @@ public class TypeDetector
List<ResolvedType> params = t.typeParametersFor(Map.class);
return mapReader(t.erasedType(), params.get(1));
}
-
+
protected ValueReader mapReader(Class<?> mapType, ResolvedType valueType)
{
- Class<?> raw = valueType.erasedType();
- if (Collection.class.isAssignableFrom(raw)) {
+ final Class<?> rawValueType = valueType.erasedType();
+ final ValueReader valueReader;
+ if (Collection.class.isAssignableFrom(rawValueType)) {
List<ResolvedType> params = valueType.typeParametersFor(Collection.class);
- return collectionReader(raw, params.get(0));
- }
- if (Map.class.isAssignableFrom(raw)) {
+ valueReader = collectionReader(rawValueType, params.get(0));
+ } else if (Map.class.isAssignableFrom(rawValueType)) {
List<ResolvedType> params = valueType.typeParametersFor(Map.class);
- return mapReader(raw, params.get(1));
+ valueReader = mapReader(rawValueType, params.get(1));
+ } else {
+ valueReader = createReader(null, rawValueType, rawValueType);
}
- return new MapReader(mapType, createReader(null, raw, raw));
+ return new MapReader(mapType, valueReader);
}
/*
=====================================
jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/ReadListTest.java
=====================================
@@ -0,0 +1,37 @@
+package com.fasterxml.jackson.jr.ob;
+
+import java.util.List;
+import java.util.Map;
+
+public class ReadListTest extends TestBase
+{
+ static class ListHolder {
+ public List<Map<String, Integer>> stuff;
+ }
+
+ public void testListOfMaps() throws Exception
+ {
+ ListHolder h = JSON.std
+ .with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
+ .with(JSON.Feature.USE_FIELDS)
+ .beanFrom(ListHolder.class,
+ aposToQuotes("{'stuff':[{'a':4}, {'a':6}]}"));
+ List<Map<String, Integer>> list = h.stuff;
+ assertNotNull(list);
+ assertEquals(2, list.size());
+ assertEquals(Integer.valueOf(6), list.get(1).get("a"));
+ }
+
+ public void testInvalidListOfMaps() throws Exception
+ {
+ try {
+ JSON.std
+ .with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
+ .with(JSON.Feature.USE_FIELDS)
+ .beanFrom(ListHolder.class,
+ aposToQuotes("{'stuff':{ 'a' : 3 }}"));
+ } catch (JSONObjectException e) {
+ verifyException(e, "Unexpected token START_OBJECT");
+ }
+ }
+}
=====================================
jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/ReadMapTest.java
=====================================
@@ -7,6 +7,10 @@ import com.fasterxml.jackson.jr.ob.JSON;
// for [jackson-jr#49], where `DeferredMap` explodes
public class ReadMapTest extends TestBase
{
+ static class MapHolder {
+ public Map<String, List<Integer>> stuff;
+ }
+
public void testIssues49() throws Exception
{
for (int i : new int[] { 7, 99, 513, 1099, 3003, 5005, 10001, 90003, 111111 }) {
@@ -24,4 +28,31 @@ public class ReadMapTest extends TestBase
assertNotNull(result);
assertEquals(size, result.size());
}
+
+ public void testMapOfLists() throws Exception
+ {
+ MapHolder m = JSON.std
+ .with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
+ .with(JSON.Feature.USE_FIELDS)
+ .beanFrom(MapHolder.class,
+ aposToQuotes("{'stuff':{'a':[1, 2, 3], 'b' : [7, 2]}}"));
+ Map<String, List<Integer>> map = m.stuff;
+ assertNotNull(map);
+ assertEquals(2, map.size());
+ assertEquals(Arrays.asList(Integer.valueOf(7), Integer.valueOf(2)),
+ map.get("b"));
+ }
+
+ public void testInvalidMapOfLists() throws Exception
+ {
+ try {
+ JSON.std
+ .with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
+ .with(JSON.Feature.USE_FIELDS)
+ .beanFrom(MapHolder.class,
+ aposToQuotes("{'stuff':[ 1 ]}"));
+ } catch (JSONObjectException e) {
+ verifyException(e, "Unexpected token START_ARRAY");
+ }
+ }
}
=====================================
jr-retrofit2/pom.xml
=====================================
@@ -3,7 +3,7 @@
<parent>
<groupId>com.fasterxml.jackson.jr</groupId>
<artifactId>jackson-jr-parent</artifactId>
- <version>2.9.8</version>
+ <version>2.9.9</version>
</parent>
<artifactId>jackson-jr-retrofit2</artifactId>
<packaging>bundle</packaging>
=====================================
jr-stree/pom.xml
=====================================
@@ -3,7 +3,7 @@
<parent>
<groupId>com.fasterxml.jackson.jr</groupId>
<artifactId>jackson-jr-parent</artifactId>
- <version>2.9.8</version>
+ <version>2.9.9</version>
</parent>
<artifactId>jackson-jr-stree</artifactId>
<packaging>bundle</packaging>
=====================================
pom.xml
=====================================
@@ -3,12 +3,12 @@
<parent>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-base</artifactId>
- <version>2.9.8</version>
+ <version>2.9.9</version>
</parent>
<groupId>com.fasterxml.jackson.jr</groupId>
<artifactId>jackson-jr-parent</artifactId>
<name>Parent pom for Jackson jr components</name>
- <version>2.9.8</version>
+ <version>2.9.9</version>
<packaging>pom</packaging>
<description>Parent pom for Jackson jr components
</description>
@@ -25,7 +25,7 @@
<connection>scm:git:git at github.com:FasterXML/jackson-jr.git</connection>
<developerConnection>scm:git:git at github.com:FasterXML/jackson-jr.git</developerConnection>
<url>http://github.com/FasterXML/jackson-jr</url>
- <tag>jackson-jr-parent-2.9.8</tag>
+ <tag>jackson-jr-parent-2.9.9</tag>
</scm>
<properties>
=====================================
release-notes/VERSION
=====================================
@@ -4,6 +4,10 @@ Project: jackson-jr
=== Releases ===
------------------------------------------------------------------------
+2.9.9 (16-May-2019)
+
+- Fix an issue with Maps-of-Lists, Lists-of-Maps
+
2.9.8 (15-Dec-2018)
2.9.7 (19-Sep-2018)
2.9.6 (12-Jun-2018)
View it on GitLab: https://salsa.debian.org/java-team/jackson-jr/commit/89ff3919e0e2a2abb96a52673857a5b5174e861d
--
View it on GitLab: https://salsa.debian.org/java-team/jackson-jr/commit/89ff3919e0e2a2abb96a52673857a5b5174e861d
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20190721/41e6dc91/attachment.html>
More information about the pkg-java-commits
mailing list