@@ -42,7 +42,7 @@ public class ObjectReader
42
42
extends ObjectCodec
43
43
implements Versioned , java .io .Serializable // since 2.1
44
44
{
45
- private static final long serialVersionUID = 1L ; // since 2.5
45
+ private static final long serialVersionUID = 2L ; // since 2.9
46
46
47
47
private final static JavaType JSON_NODE_TYPE = SimpleType .constructUnsafe (JsonNode .class );
48
48
@@ -180,9 +180,6 @@ protected ObjectReader(ObjectMapper mapper, DeserializationConfig config,
180
180
_parserFactory = mapper ._jsonFactory ;
181
181
_valueType = valueType ;
182
182
_valueToUpdate = valueToUpdate ;
183
- if (valueToUpdate != null && valueType .isArrayType ()) {
184
- throw new IllegalArgumentException ("Can not update an array value" );
185
- }
186
183
_schema = schema ;
187
184
_injectableValues = injectableValues ;
188
185
_unwrapRoot = config .useRootWrapping ();
@@ -209,9 +206,6 @@ protected ObjectReader(ObjectReader base, DeserializationConfig config,
209
206
_valueType = valueType ;
210
207
_rootDeserializer = rootDeser ;
211
208
_valueToUpdate = valueToUpdate ;
212
- if (valueToUpdate != null && valueType .isArrayType ()) {
213
- throw new IllegalArgumentException ("Can not update an array value" );
214
- }
215
209
_schema = schema ;
216
210
_injectableValues = injectableValues ;
217
211
_unwrapRoot = config .useRootWrapping ();
@@ -1015,7 +1009,7 @@ public <T> T readValue(JsonParser p, TypeReference<?> valueTypeRef) throws IOExc
1015
1009
*/
1016
1010
@ Override
1017
1011
@ SuppressWarnings ("unchecked" )
1018
- public <T > T readValue (JsonParser p , ResolvedType valueType ) throws IOException , JsonProcessingException {
1012
+ public <T > T readValue (JsonParser p , ResolvedType valueType ) throws IOException {
1019
1013
return (T ) forType ((JavaType )valueType ).readValue (p );
1020
1014
}
1021
1015
@@ -1181,8 +1175,7 @@ public void writeTree(JsonGenerator g, TreeNode rootNode) {
1181
1175
* was specified with {@link #withValueToUpdate(Object)}.
1182
1176
*/
1183
1177
@ SuppressWarnings ("unchecked" )
1184
- public <T > T readValue (InputStream src )
1185
- throws IOException , JsonProcessingException
1178
+ public <T > T readValue (InputStream src ) throws IOException
1186
1179
{
1187
1180
if (_dataFormatReaders != null ) {
1188
1181
return (T ) _detectBindAndClose (_dataFormatReaders .findFormat (src ), false );
@@ -1198,8 +1191,7 @@ public <T> T readValue(InputStream src)
1198
1191
* was specified with {@link #withValueToUpdate(Object)}.
1199
1192
*/
1200
1193
@ SuppressWarnings ("unchecked" )
1201
- public <T > T readValue (Reader src )
1202
- throws IOException , JsonProcessingException
1194
+ public <T > T readValue (Reader src ) throws IOException
1203
1195
{
1204
1196
if (_dataFormatReaders != null ) {
1205
1197
_reportUndetectableSource (src );
@@ -1215,8 +1207,7 @@ public <T> T readValue(Reader src)
1215
1207
* was specified with {@link #withValueToUpdate(Object)}.
1216
1208
*/
1217
1209
@ SuppressWarnings ("unchecked" )
1218
- public <T > T readValue (String src )
1219
- throws IOException , JsonProcessingException
1210
+ public <T > T readValue (String src ) throws IOException
1220
1211
{
1221
1212
if (_dataFormatReaders != null ) {
1222
1213
_reportUndetectableSource (src );
@@ -1232,8 +1223,7 @@ public <T> T readValue(String src)
1232
1223
* was specified with {@link #withValueToUpdate(Object)}.
1233
1224
*/
1234
1225
@ SuppressWarnings ("unchecked" )
1235
- public <T > T readValue (byte [] src )
1236
- throws IOException , JsonProcessingException
1226
+ public <T > T readValue (byte [] src ) throws IOException
1237
1227
{
1238
1228
if (_dataFormatReaders != null ) {
1239
1229
return (T ) _detectBindAndClose (src , 0 , src .length );
@@ -1250,7 +1240,7 @@ public <T> T readValue(byte[] src)
1250
1240
*/
1251
1241
@ SuppressWarnings ("unchecked" )
1252
1242
public <T > T readValue (byte [] src , int offset , int length )
1253
- throws IOException , JsonProcessingException
1243
+ throws IOException
1254
1244
{
1255
1245
if (_dataFormatReaders != null ) {
1256
1246
return (T ) _detectBindAndClose (src , offset , length );
@@ -1262,7 +1252,7 @@ public <T> T readValue(byte[] src, int offset, int length)
1262
1252
1263
1253
@ SuppressWarnings ("unchecked" )
1264
1254
public <T > T readValue (File src )
1265
- throws IOException , JsonProcessingException
1255
+ throws IOException
1266
1256
{
1267
1257
if (_dataFormatReaders != null ) {
1268
1258
return (T ) _detectBindAndClose (_dataFormatReaders .findFormat (_inputStream (src )), true );
@@ -1279,7 +1269,7 @@ public <T> T readValue(File src)
1279
1269
*/
1280
1270
@ SuppressWarnings ("unchecked" )
1281
1271
public <T > T readValue (URL src )
1282
- throws IOException , JsonProcessingException
1272
+ throws IOException
1283
1273
{
1284
1274
if (_dataFormatReaders != null ) {
1285
1275
return (T ) _detectBindAndClose (_dataFormatReaders .findFormat (_inputStream (src )), true );
@@ -1297,7 +1287,7 @@ public <T> T readValue(URL src)
1297
1287
*/
1298
1288
@ SuppressWarnings ("unchecked" )
1299
1289
public <T > T readValue (JsonNode src )
1300
- throws IOException , JsonProcessingException
1290
+ throws IOException
1301
1291
{
1302
1292
if (_dataFormatReaders != null ) {
1303
1293
_reportUndetectableSource (src );
@@ -1395,7 +1385,7 @@ public JsonNode readTree(DataInput src) throws IOException
1395
1385
* to the token following it.
1396
1386
*/
1397
1387
public <T > MappingIterator <T > readValues (JsonParser p )
1398
- throws IOException , JsonProcessingException
1388
+ throws IOException
1399
1389
{
1400
1390
DeserializationContext ctxt = createDeserializationContext (p );
1401
1391
// false -> do not close as caller gave parser instance
@@ -1423,7 +1413,7 @@ public <T> MappingIterator<T> readValues(JsonParser p)
1423
1413
* <code>START_ARRAY</code> which is part of the first element).
1424
1414
*/
1425
1415
public <T > MappingIterator <T > readValues (InputStream src )
1426
- throws IOException , JsonProcessingException
1416
+ throws IOException
1427
1417
{
1428
1418
if (_dataFormatReaders != null ) {
1429
1419
return _detectBindAndReadValues (_dataFormatReaders .findFormat (src ), false );
@@ -1437,7 +1427,7 @@ public <T> MappingIterator<T> readValues(InputStream src)
1437
1427
*/
1438
1428
@ SuppressWarnings ("resource" )
1439
1429
public <T > MappingIterator <T > readValues (Reader src )
1440
- throws IOException , JsonProcessingException
1430
+ throws IOException
1441
1431
{
1442
1432
if (_dataFormatReaders != null ) {
1443
1433
_reportUndetectableSource (src );
@@ -1456,7 +1446,7 @@ public <T> MappingIterator<T> readValues(Reader src)
1456
1446
*/
1457
1447
@ SuppressWarnings ("resource" )
1458
1448
public <T > MappingIterator <T > readValues (String json )
1459
- throws IOException , JsonProcessingException
1449
+ throws IOException
1460
1450
{
1461
1451
if (_dataFormatReaders != null ) {
1462
1452
_reportUndetectableSource (json );
@@ -1472,7 +1462,7 @@ public <T> MappingIterator<T> readValues(String json)
1472
1462
* Overloaded version of {@link #readValue(InputStream)}.
1473
1463
*/
1474
1464
public <T > MappingIterator <T > readValues (byte [] src , int offset , int length )
1475
- throws IOException , JsonProcessingException
1465
+ throws IOException
1476
1466
{
1477
1467
if (_dataFormatReaders != null ) {
1478
1468
return _detectBindAndReadValues (_dataFormatReaders .findFormat (src , offset , length ), false );
@@ -1485,15 +1475,15 @@ public <T> MappingIterator<T> readValues(byte[] src, int offset, int length)
1485
1475
* Overloaded version of {@link #readValue(InputStream)}.
1486
1476
*/
1487
1477
public final <T > MappingIterator <T > readValues (byte [] src )
1488
- throws IOException , JsonProcessingException {
1478
+ throws IOException {
1489
1479
return readValues (src , 0 , src .length );
1490
1480
}
1491
1481
1492
1482
/**
1493
1483
* Overloaded version of {@link #readValue(InputStream)}.
1494
1484
*/
1495
1485
public <T > MappingIterator <T > readValues (File src )
1496
- throws IOException , JsonProcessingException
1486
+ throws IOException
1497
1487
{
1498
1488
if (_dataFormatReaders != null ) {
1499
1489
return _detectBindAndReadValues (
@@ -1508,7 +1498,7 @@ public <T> MappingIterator<T> readValues(File src)
1508
1498
* @param src URL to read to access JSON content to parse.
1509
1499
*/
1510
1500
public <T > MappingIterator <T > readValues (URL src )
1511
- throws IOException , JsonProcessingException
1501
+ throws IOException
1512
1502
{
1513
1503
if (_dataFormatReaders != null ) {
1514
1504
return _detectBindAndReadValues (
@@ -1542,12 +1532,12 @@ public <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingEx
1542
1532
} catch (JsonProcessingException e ) {
1543
1533
throw e ;
1544
1534
} catch (IOException e ) { // should not occur, no real i/o...
1545
- throw new IllegalArgumentException ( e . getMessage (), e );
1535
+ throw JsonMappingException . fromUnexpectedIOE ( e );
1546
1536
}
1547
1537
}
1548
1538
1549
1539
@ Override
1550
- public void writeValue (JsonGenerator gen , Object value ) throws IOException , JsonProcessingException {
1540
+ public void writeValue (JsonGenerator gen , Object value ) throws IOException {
1551
1541
throw new UnsupportedOperationException ("Not implemented for ObjectReader" );
1552
1542
}
1553
1543
@@ -1761,7 +1751,7 @@ protected Object _detectBindAndClose(DataFormatReaders.Match match, boolean forc
1761
1751
1762
1752
@ SuppressWarnings ("resource" )
1763
1753
protected <T > MappingIterator <T > _detectBindAndReadValues (DataFormatReaders .Match match , boolean forceClosing )
1764
- throws IOException , JsonProcessingException
1754
+ throws IOException
1765
1755
{
1766
1756
if (!match .hasMatch ()) {
1767
1757
_reportUnkownFormat (_dataFormatReaders , match );
@@ -1792,7 +1782,8 @@ protected JsonNode _detectBindAndCloseAsTree(InputStream in) throws IOException
1792
1782
* Method called to indicate that format detection failed to detect format
1793
1783
* of given input
1794
1784
*/
1795
- protected void _reportUnkownFormat (DataFormatReaders detector , DataFormatReaders .Match match ) throws JsonProcessingException
1785
+ protected void _reportUnkownFormat (DataFormatReaders detector , DataFormatReaders .Match match )
1786
+ throws JsonProcessingException
1796
1787
{
1797
1788
// 17-Aug-2015, tatu: Unfortunately, no parser/generator available so:
1798
1789
throw new JsonParseException (null , "Can not detect format from input, does not look like any of detectable formats "
@@ -1827,13 +1818,6 @@ protected DefaultDeserializationContext createDeserializationContext(JsonParser
1827
1818
return _context .createInstance (_config , p , _injectableValues );
1828
1819
}
1829
1820
1830
- protected void _reportUndetectableSource (Object src ) throws JsonProcessingException
1831
- {
1832
- // 17-Aug-2015, tatu: Unfortunately, no parser/generator available so:
1833
- throw new JsonParseException (null , "Can not use source of type "
1834
- +src .getClass ().getName ()+" with format auto-detection: must be byte- not char-based" );
1835
- }
1836
-
1837
1821
protected InputStream _inputStream (URL src ) throws IOException {
1838
1822
return src .openStream ();
1839
1823
}
@@ -1842,6 +1826,13 @@ protected InputStream _inputStream(File f) throws IOException {
1842
1826
return new FileInputStream (f );
1843
1827
}
1844
1828
1829
+ protected void _reportUndetectableSource (Object src ) throws JsonProcessingException
1830
+ {
1831
+ // 17-Aug-2015, tatu: Unfortunately, no parser/generator available so:
1832
+ throw new JsonParseException (null , "Can not use source of type "
1833
+ +src .getClass ().getName ()+" with format auto-detection: must be byte- not char-based" );
1834
+ }
1835
+
1845
1836
/*
1846
1837
/**********************************************************
1847
1838
/* Helper methods, locating deserializers etc
0 commit comments