harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r726369 - /harmony/enhanced/classlib/trunk/modules/x-net/src/main/java/javax/net/ssl/SSLSocketFactory.java
Date Sun, 14 Dec 2008 05:38:06 GMT
Author: ndbeyer
Date: Sat Dec 13 21:38:06 2008
New Revision: 726369

URL: http://svn.apache.org/viewvc?rev=726369&view=rev
Log:
add synchronized keyword to keep thread-safe; general clean up of code

Modified:
    harmony/enhanced/classlib/trunk/modules/x-net/src/main/java/javax/net/ssl/SSLSocketFactory.java

Modified: harmony/enhanced/classlib/trunk/modules/x-net/src/main/java/javax/net/ssl/SSLSocketFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/x-net/src/main/java/javax/net/ssl/SSLSocketFactory.java?rev=726369&r1=726368&r2=726369&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/x-net/src/main/java/javax/net/ssl/SSLSocketFactory.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/x-net/src/main/java/javax/net/ssl/SSLSocketFactory.java
Sat Dec 13 21:38:06 2008
@@ -25,14 +25,11 @@
 import java.io.IOException;
 import java.net.Socket;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.security.Security;
 
 import javax.net.SocketFactory;
 
-/**
- * @com.intel.drl.spec_ref
- * 
- */
 public abstract class SSLSocketFactory extends SocketFactory {
     // FIXME EXPORT CONTROL
 
@@ -41,28 +38,23 @@
 
     private static String defaultName;
 
-    public SSLSocketFactory() {
-        super();
-    }
-
-    public static SocketFactory getDefault() {
+    public static synchronized SocketFactory getDefault() {
         if (defaultSocketFactory != null) {
             return defaultSocketFactory;
         }
         if (defaultName == null) {
-            AccessController.doPrivileged(new java.security.PrivilegedAction(){
-                public Object run() {
-                	defaultName = Security.getProperty("ssl.SocketFactory.provider");
-                    if (defaultName != null) {    
+            AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                public Void run() {
+                    defaultName = Security.getProperty("ssl.SocketFactory.provider");
+                    if (defaultName != null) {
                         ClassLoader cl = Thread.currentThread().getContextClassLoader();
                         if (cl == null) {
                             cl = ClassLoader.getSystemClassLoader();
                         }
                         try {
-                        	defaultSocketFactory = (SocketFactory) Class.forName(
-                                    defaultName, true, cl).newInstance();
-                         } catch (Exception e) {
-                            return e;
+                            final Class<?> sfc = Class.forName(defaultName, true, cl);
+                            defaultSocketFactory = (SocketFactory) sfc.newInstance();
+                        } catch (Exception e) {
                         }
                     }
                     return null;
@@ -84,11 +76,14 @@
         return defaultSocketFactory;
     }
 
+    public SSLSocketFactory() {
+        super();
+    }
+
     public abstract String[] getDefaultCipherSuites();
 
     public abstract String[] getSupportedCipherSuites();
 
-    public abstract Socket createSocket(Socket s, String host, int port,
-            boolean autoClose) throws IOException;
-
-}
\ No newline at end of file
+    public abstract Socket createSocket(Socket s, String host, int port, boolean autoClose)
+            throws IOException;
+}



Mime
View raw message