You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Ja...@rzf.fin-nrw.de on 2003/08/27 13:46:24 UTC
Project.toBoolean(String) can not accept 'null' value
While playing with the Project class I saw that the toBoolean() method
in line 1578 can´t accept a null value.
/**
* @param s The string to convert to a boolean value.
* Must not be <code>null</code>.
*/
public static boolean toBoolean(String s) {
return (s.equalsIgnoreCase("on")
|| s.equalsIgnoreCase("true")
|| s.equalsIgnoreCase("yes"));
}
If we change the implementation to
return ("on".equalsIgnoreCase(s)
|| "true".equalsIgnoreCase(s)
|| "yes".equalsIgnoreCase(s));
this restriction wouldn´t be there anymore.
Is the NullPointerException somewhere needed?
If found the following occurences:
- IntrospectionHelper.createAttributeSetter(Method, Class, String) line 898
- MailLogger.buildFinished(BuildEvent) line 154
- Rename.setReplace(String) line 100
- Copyfile.setFiltering(String) line 94
- Copy.setPreserveLastModified(String) line 191
- Jvc.execute() line 124: NPE handled but not needed
- Jikes.execute() line 178, 195, 213, 225
- NetRexxC.init() line 538, several more: NPE handled but not needed
- VAJToolsServlet.getBooleanParam(String, boolean) line 188: not sure, seems
not to require NPE
- JUnitTestRunner.main(String[]) line 502, 504, 506, 520
- DateSelector.setParameters(Parameter[]) line 217
- ContainsSelector.setParameters(Parameter[]) line 160, 163
- FilenameSelector.setParameters(Parameter[]) line 161, 164
In all these files NPEs can´t occur or is handled without depending on the
NPE (like in Jvc).
Jan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org