Merge change 5967 into donut
* changes:
Modifies OpenSSLSocketImpl to use a different lock for the instance count. It was using the same lock when use around native methods meaning that the finalizer could be blocked unnecessarily resulting in a VM crash.
diff --git a/libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java b/libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
index 3b9006d..fcc1a77 100644
--- a/libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
+++ b/libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
@@ -30,6 +30,7 @@
import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPublicKey;
import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -74,18 +75,14 @@
"TLSv1"
};
- private static int instanceCount = 0;
+ private static final AtomicInteger instanceCount = new AtomicInteger(0);
public static int getInstanceCount() {
- synchronized (OpenSSLSocketImpl.class) {
- return instanceCount;
- }
+ return instanceCount.get();
}
private static void updateInstanceCount(int amount) {
- synchronized (OpenSSLSocketImpl.class) {
- instanceCount += amount;
- }
+ instanceCount.addAndGet(amount);
}
/**