mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
03.22.2013 e944524d9d51dfee01f4e5dad5fd3538dd8873b0
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ReferenceCountedObject.java
@@ -25,6 +25,7 @@
package com.forgerock.opendj.util;
/**
 * An object which is lazily created when first referenced, and destroyed when
 * the last reference is released.
@@ -72,9 +73,12 @@
        public void release() {
            T instanceToRelease = null;
            synchronized (lock) {
                if (value != null && instance == value && --refCount == 0) {
                    instanceToRelease = value;
                    instance = null;
                if (value != null) {
                    if (instance == value && --refCount == 0) {
                        // This was the last reference.
                        instanceToRelease = value;
                        instance = null;
                    }
                    /*
                     * Force NPE for subsequent get() attempts and prevent
@@ -83,7 +87,6 @@
                    value = null;
                }
            }
            if (instanceToRelease != null) {
                destroyInstance(instanceToRelease);
            }