You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2010/06/04 09:50:56 UTC
svn commit: r951314 -
/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
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();
Re: svn commit: r951314 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
Posted by Emmanuel Lecharny <el...@gmail.com>.
On 6/4/10 9:50 AM, felixk@apache.org wrote:
> 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
>
Good 'catch' :-)
btw, there are many places where we throw NullPointerExceptions
(mainly when checking the methods arguments, which is wrong : we should
throw a IllegalArgumentException instead).
--
Regards,
Cordialement,
Emmanuel Lécharny
www.nextury.com