This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Integer.getInteger patch for null argument
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- To: Mark Wielaard <mark at klomp dot org>
- Cc: java-patches at gcc dot gnu dot org
- Date: Tue, 16 Apr 2002 14:14:31 +1200
- Subject: Re: Integer.getInteger patch for null argument
- References: <1018901478.30911.14.camel@elsschot>
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.