Search in sources :

Example 1 with ExposedNodeLinkedList

use of org.eclipse.persistence.internal.helper.linkedlist.ExposedNodeLinkedList in project eclipselink by eclipse-ee4j.

the class ReadSoftCacheWeakIdentityMapTest method test.

@Override
public void test() {
    if (getIdentityMap().getSize() == 0) {
        throw new TestWarningException("We did not fill the cache, the test is invalid.");
    }
    // Ensure subcache has correct references.
    ExposedNodeLinkedList list = ((SoftCacheWeakIdentityMap) getIdentityMap()).getReferenceCache();
    java.lang.ref.SoftReference ref = (java.lang.ref.SoftReference) list.getFirst();
    if (ref.get() == null) {
        throw new TestErrorException("Soft reference is null.");
    }
    ref = (java.lang.ref.SoftReference) list.getLast();
    if (ref.get() == null) {
        throw new TestErrorException("Soft reference is null.");
    }
    // The jdk1.2.0 on the Testing machine treats the weak reference as a softweak reference so we must waste memory
    Vector vector = new Vector(10000);
    for (int i = 0; i < 10000; ++i) {
        vector.addElement(new java.math.BigDecimal(i));
    }
    // Force garbage collection, which should clear the cache.
    System.gc();
    System.runFinalization();
    System.gc();
}
Also used : ExposedNodeLinkedList(org.eclipse.persistence.internal.helper.linkedlist.ExposedNodeLinkedList)

Aggregations

ExposedNodeLinkedList (org.eclipse.persistence.internal.helper.linkedlist.ExposedNodeLinkedList)1