This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Integer.getInteger patch for null argument


Mark Wielaard wrote:

>Index: java/lang/Integer.java
>===================================================================
>RCS file: /cvs/gcc/gcc/libjava/java/lang/Integer.java,v
>retrieving revision 1.13.2.1
>diff -u -r1.13.2.1 Integer.java
>--- java/lang/Integer.java	1 Apr 2002 19:11:16 -0000	1.13.2.1
>+++ java/lang/Integer.java	15 Apr 2002 19:54:48 -0000
>@@ -183,11 +183,13 @@
>    */
>   public static Integer getInteger(String nm, Integer def)
>   {
>-    String val = System.getProperty(nm);
>-    if (val == null) return def;
>+    if (nm == null || "".equals(nm))
>+      return def;
>+    nm = System.getProperty(nm);
>+    if (nm == null) return def;
>     try
>       {
>-      return decode(val);
>+	return decode(nm);
>       }
>     catch (NumberFormatException e)
>       {
>

I think a better fix would be to add an IllegalArgumentException catch 
to the existing try block, and move the System.getProperty() call inside 
it. And fix System.getProperty() since it doesn't seem to throw the 
right exception on a null argument ;-)

regards

Bryce.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]