Community
Participate
Working Groups
Created attachment 250516 [details] Do not set user properties if value is null Related bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=338633 Here is a new stacktrace for Mars: java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:459) at org.apache.tools.ant.PropertyHelper.setUserProperty(PropertyHelper.java:750) at org.apache.tools.ant.Project.setUserProperty(Project.java:563) at org.eclipse.ant.internal.core.ant.InternalAntRunner.setProperties(InternalAntRunner.java:267) at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:632) at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:525) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.eclipse.ant.core.AntRunner.run(AntRunner.java:371) at org.eclipse.pde.internal.core.exports.FeatureExportOperation.runScript(FeatureExportOperation.java:423) at org.eclipse.pde.internal.core.exports.FeatureExportOperation.doExport(FeatureExportOperation.java:261) at org.eclipse.pde.internal.core.exports.FeatureBasedExportOperation.run(FeatureBasedExportOperation.java:50) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) Looking at the code here: http://git.eclipse.org/c/platform/eclipse.platform.git/tree/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java#n1035 We can see that the variable userProperties is a HashMap, which permits the use of a null value. This means the method setProperties() which has the following code may be passing in a null value: private void setProperties(Project project) { setBuiltInProperties(project); if (userProperties != null) { for (Entry<String, String> entry : userProperties.entrySet()) { project.setUserProperty(entry.getKey(), entry.getValue()); } } } Following the stack, however, wee see that the internal implementation for project.setUserProperty(k,v) leads to PropertyHelper, which uses a HashTable as an internal implementation, which does not allow null values. InternalAntRunner should make sure there are no null values being passed in here! A similar problem is shown in the other InternalAntRunner: http://git.eclipse.org/c/platform/eclipse.platform.git/tree/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java#n268 No null checks are performed.
Pushed patch to master: http://git.eclipse.org/c/platform/eclipse.platform.git/commit/?id=608b1481160755e3e8dacceca5f7a1782195f6cc As it turns out we have (potentially) been violating the Ant API for a while around setting user props - the methods are all spec'd to not accept null. Thanks for the patch Rob!
Verified by code inspect and PDE case scenario. Eclipse SDK Version: Mars (4.5) Build id: I20150315-2000