Author: dkulp
Date: Mon Sep 12 20:05:36 2011
New Revision: 1169903

URL: http://svn.apache.org/viewvc?rev=1169903&view=rev
Log:
Merged revisions 1169899 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1169899 | dkulp | 2011-09-12 15:54:22 -0400 (Mon, 12 Sep 2011) | 1 line
  
  [CXF-3801] Slight optimizations for the JAXBContextCache.
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    
cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java?rev=1169903&r1=1169902&r2=1169903&view=diff
==============================================================================
--- 
cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java
 (original)
+++ 
cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java
 Mon Sep 12 20:05:36 2011
@@ -22,6 +22,7 @@ package org.apache.cxf.jaxb;
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.lang.ref.SoftReference;
 import java.lang.ref.WeakReference;
 import java.lang.reflect.Method;
 import java.util.Collection;
@@ -46,12 +47,12 @@ import org.apache.cxf.common.util.String
  */
 public final class JAXBContextCache {
     public static final class CachedContextAndSchemas {
-        private WeakReference<JAXBContext> context;
+        private SoftReference<JAXBContext> context;
         private WeakReference<Set<Class<?>>> classes;
         private Collection<DOMSource> schemas;
 
         CachedContextAndSchemas(JAXBContext context, Set<Class<?>> classes) {
-            this.context = new WeakReference<JAXBContext>(context);
+            this.context = new SoftReference<JAXBContext>(context);
             this.classes = new WeakReference<Set<Class<?>>>(classes);
         }
 
@@ -153,15 +154,15 @@ public final class JAXBContextCache {
                         }
                     }
                 }
-            }
-        }
-        if (cachedContextAndSchemas != null) {
-            context = cachedContextAndSchemas.getContext();
-            if (context ==  null) {
-                synchronized (JAXBCONTEXT_CACHE) {
-                    
JAXBCONTEXT_CACHE.remove(cachedContextAndSchemas.getClasses());
+                if (cachedContextAndSchemas != null) {
+                    context = cachedContextAndSchemas.getContext();
+                    if (context == null) {
+                        
JAXBCONTEXT_CACHE.remove(cachedContextAndSchemas.getClasses());
+                        cachedContextAndSchemas = null;
+                    } else {
+                        return cachedContextAndSchemas;
+                    }
                 }
-                cachedContextAndSchemas = null;
             }
         }
         if (context == null) {


Reply via email to