< prev index next >

jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/Pool.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -28,12 +28,14 @@
 import com.sun.xml.internal.ws.api.pipe.Tube;
 import com.sun.xml.internal.ws.api.pipe.TubeCloner;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
+
 import java.util.concurrent.ConcurrentLinkedQueue;
-import java.lang.ref.WeakReference;
+import java.lang.ref.SoftReference;
+
 
 /**
  * General-purpose object pool.
  *
  * <p>

@@ -48,11 +50,11 @@
  * @author Kohsuke Kawaguchi
  */
 public abstract class Pool<T> {
 
     // volatile since multiple threads may access queue reference
-    private volatile WeakReference<ConcurrentLinkedQueue<T>> queue;
+    private volatile SoftReference<ConcurrentLinkedQueue<T>> queue;
 
     /**
      * Gets a new object from the pool.
      *
      * <p>

@@ -67,20 +69,20 @@
             return create();
         return t;
     }
 
     private ConcurrentLinkedQueue<T> getQueue() {
-        WeakReference<ConcurrentLinkedQueue<T>> q = queue;
+        SoftReference<ConcurrentLinkedQueue<T>> q = queue;
         if (q != null) {
             ConcurrentLinkedQueue<T> d = q.get();
             if (d != null)
                 return d;
         }
 
         // overwrite the queue
         ConcurrentLinkedQueue<T> d = new ConcurrentLinkedQueue<T>();
-        queue = new WeakReference<ConcurrentLinkedQueue<T>>(d);
+        queue = new SoftReference<ConcurrentLinkedQueue<T>>(d);
 
         return d;
     }
 
     /**
< prev index next >