Author: rdonkin
Date: Thu Oct 13 14:39:26 2005
New Revision: 320929

URL: http://svn.apache.org/viewcvs?rev=320929&view=rev
Log:
Fixed memory leak with bad singleton. Contributed by John M. Issue #37046.

Modified:
    
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/BindingConfiguration.java
    
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/DefaultIdStoringStrategy.java
    
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/IdStoringStrategy.java
    jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml

Modified: 
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/BindingConfiguration.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/BindingConfiguration.java?rev=320929&r1=320928&r2=320929&view=diff
==============================================================================
--- 
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/BindingConfiguration.java
 (original)
+++ 
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/BindingConfiguration.java
 Thu Oct 13 14:39:26 2005
@@ -50,7 +50,7 @@
     /** Strategy for suppressing attributes with certain values when writing */
     private ValueSuppressionStrategy valueSuppressionStrategy  = 
ValueSuppressionStrategy.DEFAULT;
     /** Strategy for storing and accessing ID values */
-    private IdStoringStrategy idStoringStrategy = IdStoringStrategy.DEFAULT;
+    private IdStoringStrategy idStoringStrategy = 
IdStoringStrategy.createDefault();
     
     /**
      * Constructs a BindingConfiguration with default properties.

Modified: 
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/DefaultIdStoringStrategy.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/DefaultIdStoringStrategy.java?rev=320929&r1=320928&r2=320929&view=diff
==============================================================================
--- 
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/DefaultIdStoringStrategy.java
 (original)
+++ 
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/DefaultIdStoringStrategy.java
 Thu Oct 13 14:39:26 2005
@@ -24,7 +24,7 @@
  * Stores every ID that given to it into an internal <code>HashMap</code> and
  * returns it on request.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Christian Aust </a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Christian Aust</a>
  * @since 0.7
  */
 public class DefaultIdStoringStrategy extends IdStoringStrategy {

Modified: 
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/IdStoringStrategy.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/IdStoringStrategy.java?rev=320929&r1=320928&r2=320929&view=diff
==============================================================================
--- 
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/IdStoringStrategy.java
 (original)
+++ 
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/strategy/IdStoringStrategy.java
 Thu Oct 13 14:39:26 2005
@@ -33,10 +33,22 @@
     /**
      * Default storage strategy
      * 
-     * @see DefaultIdStoringStrategy
+     * @deprecated do not use this singleton since it 
+     * creates a static Map of all objects ever written. 
+     * Use [EMAIL PROTECTED] #createDefault} instead
      */
     public static IdStoringStrategy DEFAULT = new DefaultIdStoringStrategy();
 
+    /**
+     * Factory method creates the default <code>Betwixt</code> implementation.
+     * The implementation created may vary if the default implementation 
changes.
+     * @return <code>IdStoringStrategy</code> used as default
+     */
+    public static IdStoringStrategy createDefault() {
+        return new DefaultIdStoringStrategy();
+    }
+        
+    
     /**
      * Retrieves a reference for the given instance.
      * If a not null value is returned from this method,

Modified: jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml?rev=320929&r1=320928&r2=320929&view=diff
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml (original)
+++ jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml Thu Oct 13 14:39:26 
2005
@@ -411,6 +411,16 @@
 <section name='Deprecated'>
        <subsection name='Since 0.7'>
                <ul>
+                       <li>IdStoringStrategy
+                               <ul>
+                                       <li>IdStoringStrategy.DEFAULT should 
never have been a constant
+                                       since the implementation uses instance 
variables.
+                                       Using this constant will result in a 
memory leak.
+                                       Note: use proper factory methods 
+                                       rather than public constant fields in 
the future!
+                                       </li>
+                               </ul>
+                       </li>
                        <li>ElementRule added forceAccessible attribute
                                <ul>
                                        <li>configureDescriptor replaced by 
private method with extra parameter</li>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to