commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections TestReferenceMap.java
Date Tue, 06 May 2003 11:19:27 GMT
rdonkin     2003/05/06 04:19:26

  Modified:    collections/src/java/org/apache/commons/collections
                        ReferenceMap.java
               collections/src/test/org/apache/commons/collections
                        TestReferenceMap.java
  Log:
  Rolled back last commit. Accidentally committed everything in commons when I just wanted
to commit docs and xdocs. Doh!
  
  Revision  Changes    Path
  1.10      +1 -48     jakarta-commons/collections/src/java/org/apache/commons/collections/ReferenceMap.java
  
  Index: ReferenceMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/ReferenceMap.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ReferenceMap.java	6 May 2003 10:24:01 -0000	1.9
  +++ ReferenceMap.java	6 May 2003 11:19:26 -0000	1.10
  @@ -175,11 +175,6 @@
        *  @serial
        */
       private float loadFactor;
  -    
  -    /**
  -     * Should the value be automatically purged when the associated key has been collected?
  -     */
  -    private boolean purgeValues = false;
   
   
       // -- Non-serialized instance variables
  @@ -242,21 +237,6 @@
           this(HARD, SOFT);
       }
   
  -    /**
  -     *  Constructs a new <Code>ReferenceMap</Code> that will
  -     *  use the specified types of references.
  -     *
  -     *  @param keyType  the type of reference to use for keys;
  -     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
  -     *  @param valueType  the type of reference to use for values;
  -     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
  -     *  @param purgeValues should the value be automatically purged when the 
  -     *   key is garbage collected 
  -     */
  -    public ReferenceMap(int keyType, int valueType, boolean purgeValues) {
  -        this(keyType, valueType);
  -        this.purgeValues = purgeValues;
  -    }
   
       /**
        *  Constructs a new <Code>ReferenceMap</Code> that will
  @@ -271,29 +251,6 @@
           this(keyType, valueType, 16, 0.75f);
       }
   
  -    /**
  -     *  Constructs a new <Code>ReferenceMap</Code> with the
  -     *  specified reference types, load factor and initial
  -     *  capacity.
  -     *
  -     *  @param keyType  the type of reference to use for keys;
  -     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
  -     *  @param valueType  the type of reference to use for values;
  -     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
  -     *  @param capacity  the initial capacity for the map
  -     *  @param loadFactor  the load factor for the map
  -     *  @param purgeValues should the value be automatically purged when the 
  -     *   key is garbage collected 
  -     */
  -    public ReferenceMap(
  -                        int keyType, 
  -                        int valueType, 
  -                        int capacity, 
  -                        float loadFactor, 
  -                        boolean purgeValues) {
  -        this(keyType, valueType, capacity, loadFactor);
  -        this.purgeValues = purgeValues;
  -    }
   
       /**
        *  Constructs a new <Code>ReferenceMap</Code> with the
  @@ -821,11 +778,7 @@
               r = r || ((valueType > HARD) && (value == ref));
               if (r) {
                   if (keyType > HARD) ((Reference)key).clear();
  -                if (valueType > HARD) {
  -                    ((Reference)value).clear();
  -                } else if (purgeValues) {
  -                    value = null;
  -                }
  +                if (valueType > HARD) ((Reference)value).clear();
               }
               return r;
           }
  
  
  
  1.7       +1 -42     jakarta-commons/collections/src/test/org/apache/commons/collections/TestReferenceMap.java
  
  Index: TestReferenceMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestReferenceMap.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestReferenceMap.java	6 May 2003 10:24:01 -0000	1.6
  +++ TestReferenceMap.java	6 May 2003 11:19:26 -0000	1.7
  @@ -61,8 +61,6 @@
   
   package org.apache.commons.collections;
   
  -import java.lang.ref.WeakReference;
  -
   import java.util.Map;
   
   import junit.framework.Test;
  @@ -188,44 +186,5 @@
           return "2.1";
       }
   
  -    /** Tests whether purge values setting works */
  -    public void testPurgeValues() throws Exception {
  -        // many thanks to Juozas Baliuka for suggesting this method
  -        Object key = new Object();
  -        Object value = new Object();
  -        
  -        WeakReference keyReference = new WeakReference(key);
  -        WeakReference valueReference = new WeakReference(value);
  -        
  -        Map testMap = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.HARD, true);
  -        testMap.put(key, value);
  -        
  -        assertEquals("In map", value, testMap.get(key));
  -        assertNotNull("Weak reference released early (1)", keyReference.get());
  -        assertNotNull("Weak reference released early (2)", valueReference.get());
  -        
  -        // dereference strong references
  -        key = null;
  -        value = null;
  -        
  -        int iterations = 0;
  -        int bytz = 2;
  -        while(true) {
  -            System.gc();
  -            if(iterations++ > 50){
  -                fail("Max iterations reached before resource released.");
  -            }
  -            testMap.isEmpty();
  -            if( 
  -                keyReference.get() == null &&
  -                valueReference.get() == null) {
  -                break;
  -                
  -            } else {
  -                // create garbage:
  -                byte[] b =  new byte[bytz];
  -                bytz = bytz * 2;
  -            }
  -        }
  -    }
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message