You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by se...@apache.org on 2009/03/18 03:44:14 UTC

svn commit: r755462 - /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/Punycode.java

Author: sebb
Date: Wed Mar 18 02:44:13 2009
New Revision: 755462

URL: http://svn.apache.org/viewvc?rev=755462&view=rev
Log:
Inline private init method so as to make class immutable

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/Punycode.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/Punycode.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/Punycode.java?rev=755462&r1=755461&r2=755462&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/Punycode.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/Punycode.java Wed Mar 18 02:44:13 2009
@@ -30,27 +30,29 @@
 
 package org.apache.http.client.utils;
 
+import net.jcip.annotations.Immutable;
+
 /**
  * Facade that provides conversion between Unicode and Punycode domain names.
  * It will use an appropriate implementation.
  *
  * @since 4.0
  */
+@Immutable
 public class Punycode {
-    private static Idn impl;
+    private static final Idn impl;
     static {
-        init();
+        Idn _impl;
+        try {
+            _impl = new JdkIdn();
+        } catch (Exception e) {
+            _impl = new Rfc3492Idn();
+        }
+        impl = _impl;
     }
     
     public static String toUnicode(String punycode) {
         return impl.toUnicode(punycode);
     }
     
-    private static void init() {
-        try {
-            impl = new JdkIdn();
-        } catch (Exception e) {
-            impl = new Rfc3492Idn();
-        }
-    }
 }