ArrayIndexOBE if add/clear is repeated twice issue71583_branch_root
authorjtulach@netbeans.org
Mon, 26 Dec 2005 16:32:04 +0000
changeset 107cad6e2839998
parent 106 8af314d94973
child 108 53a265e28048
ArrayIndexOBE if add/clear is repeated twice
openide.util/src/org/openide/util/lookup/ArrayStorage.java
openide.util/test/unit/src/org/openide/util/lookup/AbstractLookupBaseHid.java
     1.1 --- a/openide.util/src/org/openide/util/lookup/ArrayStorage.java	Mon Dec 26 12:59:31 2005 +0000
     1.2 +++ b/openide.util/src/org/openide/util/lookup/ArrayStorage.java	Mon Dec 26 16:32:04 2005 +0000
     1.3 @@ -359,9 +359,13 @@
     1.4                          throw new UnsupportedOperationException();
     1.5                      } else {
     1.6                          // ensure we have allocated enough space
     1.7 -                        if (arr[arr.length - 2] != null) {
     1.8 +                        if (arr.length < 2 || arr[arr.length - 2] != null) {
     1.9                              // double the array
    1.10                              int newSize = (arr.length - 1) * 2;
    1.11 +                            
    1.12 +                            if (newSize <= 1) {
    1.13 +                                newSize = 2;
    1.14 +                            }
    1.15  
    1.16                              if (newSize > maxSize) {
    1.17                                  newSize = maxSize;
     2.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/AbstractLookupBaseHid.java	Mon Dec 26 12:59:31 2005 +0000
     2.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/AbstractLookupBaseHid.java	Mon Dec 26 16:32:04 2005 +0000
     2.3 @@ -1270,6 +1270,14 @@
     2.4              }
     2.5          }
     2.6      }
     2.7 +    
     2.8 +    public void testSomeProblemWithDVBFrameworkSeemsToBeInLookup() {
     2.9 +        for (int i = 0; i < 5; i++) {
    2.10 +            ic.add(lookup);
    2.11 +            assertEquals("Can be found", lookup, lookup.lookup(lookup.getClass()));
    2.12 +            ic.set(Collections.EMPTY_LIST, null);
    2.13 +        }        
    2.14 +    }
    2.15  
    2.16      public void testListeningAndQueryingByTwoListenersInstances() {
    2.17          doListeningAndQueryingByTwoListeners(0);