4
4
import java .util .concurrent .ConcurrentHashMap ;
5
5
6
6
import com .fasterxml .jackson .annotation .JsonFormat ;
7
+
7
8
import com .fasterxml .jackson .databind .*;
8
9
import com .fasterxml .jackson .databind .cfg .MapperConfig ;
9
10
import com .fasterxml .jackson .databind .deser .std .StdDelegatingDeserializer ;
20
21
* ({@link com.fasterxml.jackson.databind.deser.DeserializerFactory}).
21
22
*/
22
23
public final class DeserializerCache
23
- implements java .io .Serializable // since 2.1 -- needs to be careful tho
24
+ implements java .io .Serializable
24
25
{
25
- private static final long serialVersionUID = 1L ;
26
+ private static final long serialVersionUID = 3L ;
26
27
27
28
/*
28
- /**********************************************************
29
+ /**********************************************************************
29
30
/* Caching
30
- /**********************************************************
31
+ /**********************************************************************
31
32
*/
32
33
33
34
/**
@@ -40,42 +41,41 @@ public final class DeserializerCache
40
41
* (should very quickly converge to zero after startup), let's
41
42
* define a relatively low concurrency setting.
42
43
*/
43
- final protected ConcurrentHashMap <JavaType , JsonDeserializer <Object >> _cachedDeserializers
44
+ private final transient ConcurrentHashMap <JavaType , JsonDeserializer <Object >> _cachedDeserializers
44
45
= new ConcurrentHashMap <JavaType , JsonDeserializer <Object >>(64 , 0.75f , 4 );
45
46
46
47
/**
47
48
* During deserializer construction process we may need to keep track of partially
48
49
* completed deserializers, to resolve cyclic dependencies. This is the
49
50
* map used for storing deserializers before they are fully complete.
50
51
*/
51
- final protected HashMap <JavaType , JsonDeserializer <Object >> _incompleteDeserializers
52
+ private final transient HashMap <JavaType , JsonDeserializer <Object >> _incompleteDeserializers
52
53
= new HashMap <JavaType , JsonDeserializer <Object >>(8 );
53
54
54
55
/*
55
- /**********************************************************
56
+ /**********************************************************************
56
57
/* Life-cycle
57
- /**********************************************************
58
+ /**********************************************************************
58
59
*/
59
60
60
61
public DeserializerCache () { }
61
62
62
63
/*
63
- /**********************************************************
64
+ /**********************************************************************
64
65
/* JDK serialization handling
65
- /**********************************************************
66
+ /**********************************************************************
66
67
*/
67
68
68
- Object writeReplace () {
69
- // instead of making this transient, just clear it:
70
- _incompleteDeserializers .clear ();
71
- // TODO: clear out "cheap" cached deserializers?
72
- return this ;
69
+ // 11-Apr-2018, tatu: instead of clearing or such on write, keep everything transient,
70
+ // recreate as empty. No point trying to revive cached instances
71
+ protected Object readResolve () {
72
+ return new DeserializerCache ();
73
73
}
74
-
74
+
75
75
/*
76
- /**********************************************************
76
+ /**********************************************************************
77
77
/* Access to caching aspects
78
- /**********************************************************
78
+ /**********************************************************************
79
79
*/
80
80
81
81
/**
@@ -106,9 +106,9 @@ public void flushCachedDeserializers() {
106
106
}
107
107
108
108
/*
109
- /**********************************************************
109
+ /**********************************************************************
110
110
/* General deserializer locating method
111
- /**********************************************************
111
+ /**********************************************************************
112
112
*/
113
113
114
114
/**
@@ -194,9 +194,9 @@ public boolean hasValueDeserializerFor(DeserializationContext ctxt,
194
194
195
195
196
196
/*
197
- /**********************************************************
197
+ /**********************************************************************
198
198
/* Helper methods that handle cache lookups
199
- /**********************************************************
199
+ /**********************************************************************
200
200
*/
201
201
202
202
protected JsonDeserializer <Object > _findCachedDeserializer (JavaType type )
@@ -301,9 +301,9 @@ protected JsonDeserializer<Object> _createAndCache2(DeserializationContext ctxt,
301
301
}
302
302
303
303
/*
304
- /**********************************************************
304
+ /**********************************************************************
305
305
/* Helper methods for actual construction of deserializers
306
- /**********************************************************
306
+ /**********************************************************************
307
307
*/
308
308
309
309
/**
@@ -532,9 +532,9 @@ private JavaType modifyTypeByAnnotation(DeserializationContext ctxt,
532
532
}
533
533
534
534
/*
535
- /**********************************************************
535
+ /**********************************************************************
536
536
/* Helper methods, other
537
- /**********************************************************
537
+ /**********************************************************************
538
538
*/
539
539
540
540
/**
@@ -579,9 +579,9 @@ private Class<?> _verifyAsClass(Object src, String methodName, Class<?> noneClas
579
579
}
580
580
581
581
/*
582
- /**********************************************************
583
- /* Overridable error reporting methods
584
- /**********************************************************
582
+ /**********************************************************************
583
+ /* Error reporting methods
584
+ /**********************************************************************
585
585
*/
586
586
587
587
protected JsonDeserializer <Object > _handleUnknownValueDeserializer (DeserializationContext ctxt , JavaType type )
0 commit comments