directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r951314 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
Date Fri, 04 Jun 2010 07:50:56 GMT
Author: felixk
Date: Fri Jun  4 07:50:56 2010
New Revision: 951314

URL: http://svn.apache.org/viewvc?rev=951314&view=rev
Log:
Don't catch RuntimeExceptions accidentally

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?rev=951314&r1=951313&r2=951314&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
Fri Jun  4 07:50:56 2010
@@ -25,6 +25,7 @@ import java.io.File;
 import java.io.FileFilter;
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
@@ -3345,7 +3346,17 @@ public class StringTools
                 Method method = Charset.class.getMethod( "defaultCharset", new Class[0] );
                 defaultCharset = ((Charset) method.invoke( null, new Object[0]) ).name();
             } 
-            catch (Exception e) 
+            catch (NoSuchMethodException e) 
+            {
+                // fall back to old method
+                defaultCharset = new OutputStreamWriter( new ByteArrayOutputStream() ).getEncoding();
+            }
+            catch (InvocationTargetException e) 
+            {
+                // fall back to old method
+                defaultCharset = new OutputStreamWriter( new ByteArrayOutputStream() ).getEncoding();
+            }
+            catch (IllegalAccessException e) 
             {
                 // fall back to old method
                 defaultCharset = new OutputStreamWriter( new ByteArrayOutputStream() ).getEncoding();



Mime
View raw message