Title: [2141] trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection: Use internal init() method.

Diff

Modified: trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection/PureJavaReflectionProvider.java (2140 => 2141)


--- trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection/PureJavaReflectionProvider.java	2013-09-26 20:58:39 UTC (rev 2140)
+++ trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection/PureJavaReflectionProvider.java	2013-09-26 21:01:51 UTC (rev 2141)
@@ -42,7 +42,7 @@
  */
 public class PureJavaReflectionProvider implements ReflectionProvider {
 
-    private transient Map serializedDataCache = new WeakHashMap();
+    private transient Map serializedDataCache;
     protected FieldDictionary fieldDictionary;
 
     public PureJavaReflectionProvider() {
@@ -51,6 +51,7 @@
 
     public PureJavaReflectionProvider(FieldDictionary fieldDictionary) {
         this.fieldDictionary = fieldDictionary;
+        init();
     }
 
     public Object newInstance(Class type) {
@@ -192,9 +193,12 @@
         this.fieldDictionary = dictionary;
     }
 
-    protected Object readResolve() {
-        serializedDataCache = new WeakHashMap();
+    private Object readResolve() {
+        init();
         return this;
     }
 
+    protected void init() {
+        serializedDataCache = new WeakHashMap();
+    }
 }

Modified: trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection/Sun14ReflectionProvider.java (2140 => 2141)


--- trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection/Sun14ReflectionProvider.java	2013-09-26 20:58:39 UTC (rev 2140)
+++ trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection/Sun14ReflectionProvider.java	2013-09-26 21:01:51 UTC (rev 2141)
@@ -30,7 +30,7 @@
     private final static Unsafe unsafe;
     private final static Exception exception;
     // references to the Field key are kept in the FieldDictionary
-    private transient Map fieldOffsetCache = new WeakHashMap();
+    private transient Map fieldOffsetCache;
     static {
         Unsafe u = null;
         Exception ex = null;
@@ -132,9 +132,13 @@
         // (overriden) don't mind final fields.
     }
 
-    protected Object readResolve() {
-        super.readResolve();
-        fieldOffsetCache = new WeakHashMap();
+    private Object readResolve() {
+        init();
         return this;
     }
+
+    protected void init() {
+        super.init();
+        fieldOffsetCache = new WeakHashMap();
+    }
 }

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to