{"action":"created","issue":{"url":"https://api.github.com/repos/bndtools/bnd/issues/1270","labels_url":"https://api.github.com/repos/bndtools/bnd/issues/1270/labels{/name}","comments_url":"https://api.github.com/repos/bndtools/bnd/issues/1270/comments","events_url":"https://api.github.com/repos/bndtools/bnd/issues/1270/events","html_url":"https://github.com/bndtools/bnd/issues/1270","id":122756488,"number":1270,"title":"NPE at aQute.bnd.osgi.Macro.process(Macro.java:96)","user":{"login":"xtracoder","id":2301820,"avatar_url":"https://avatars.githubusercontent.com/u/2301820?v=3","gravatar_id":"","url":"https://api.github.com/users/xtracoder","html_url":"https://github.com/xtracoder","followers_url":"https://api.github.com/users/xtracoder/followers","following_url":"https://api.github.com/users/xtracoder/following{/other_user}","gists_url":"https://api.github.com/users/xtracoder/gists{/gist_id}","starred_url":"https://api.github.com/users/xtracoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xtracoder/subscriptions","organizations_url":"https://api.github.com/users/xtracoder/orgs","repos_url":"https://api.github.com/users/xtracoder/repos","events_url":"https://api.github.com/users/xtracoder/events{/privacy}","received_events_url":"https://api.github.com/users/xtracoder/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-17T15:22:57Z","updated_at":"2015-12-17T15:37:47Z","closed_at":null,"body":"I'm getting NullPointerException by stacktrace below \r\n(Bnd is built from sources at revision \r\nSHA-1: 5780ccf68be8d0365f84ff385ed93632e6e17f5a\r\nMerge pull request #1268 from bjhargrave/javac.defaults)\r\n\r\n```\r\n\"main\"\r\n\tat java.lang.StringBuilder.<init>(StringBuilder.java:125)\r\n\tat aQute.bnd.osgi.Macro.process(Macro.java:96)\r\n\tat aQute.bnd.osgi.Macro.process(Macro.java:91)\r\n\tat aQute.bnd.osgi.Macro.process(Macro.java:86)\r\n\tat aQute.bnd.osgi.Macro.process(Macro.java:1204)\r\n\tat aQute.bnd.osgi.Macro.getFlattenedProperties(Macro.java:1152)\r\n\tat aQute.bnd.osgi.Macro.getFlattenedProperties(Macro.java:1128)\r\n\tat aQute.bnd.osgi.Processor.getFlattenedProperties(Processor.java:1375)\r\n\tat aQute.bnd.osgi.Analyzer.calcManifest(Analyzer.java:881)\r\n\tat aQute.bnd.osgi.Builder.build(Builder.java:105)\r\n\tat aQute.bnd.osgi.Builder$build.call\r\n```\r\n\r\nIt occurs because `process()` is invoked with `null` argument\r\n```\r\n\tpublic Properties getFlattenedProperties(boolean ignoreInstructions) {\r\n\t      ...\r\n\t\t\t\t\t\tflattened.put(key, process(source.getProperty(key)));\r\n```\r\n\r\nwhat happens because of this code\r\n```\r\npackage java.util;\r\n\r\npublic class Properties extends Hashtable<Object,Object> {\r\n    public String getProperty(String key) {\r\n        Object oval = super.get(key);\r\n        String sval = (oval instanceof String) ? (String)oval : null;\r\n        return ((sval == null) && (defaults != null)) ? defaults.getProperty(key) : sval;\r\n    }\r\n```\r\n\r\nbecause value stored in Hashtable is actually a GString (a Groovy String) and is evaluated as null therefore (i would say Hashtable implementation is the origin of that problem). At the moment i have no idea how GString comes into Bnd's code (project is build by Gradle + plugin: 'org.dm.bundle''), but that stack trace with NPE is absolutely misleading for problem resolution and such weird condition should be handled more gracefully within Bnd code - for example name of the 'bad' key should be logged and more informative exception can be thrown."},"comment":{"url":"https://api.github.com/repos/bndtools/bnd/issues/comments/165486191","html_url":"https://github.com/bndtools/bnd/issues/1270#issuecomment-165486191","issue_url":"https://api.github.com/repos/bndtools/bnd/issues/1270","id":165486191,"user":{"login":"xtracoder","id":2301820,"avatar_url":"https://avatars.githubusercontent.com/u/2301820?v=3","gravatar_id":"","url":"https://api.github.com/users/xtracoder","html_url":"https://github.com/xtracoder","followers_url":"https://api.github.com/users/xtracoder/followers","following_url":"https://api.github.com/users/xtracoder/following{/other_user}","gists_url":"https://api.github.com/users/xtracoder/gists{/gist_id}","starred_url":"https://api.github.com/users/xtracoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xtracoder/subscriptions","organizations_url":"https://api.github.com/users/xtracoder/orgs","repos_url":"https://api.github.com/users/xtracoder/repos","events_url":"https://api.github.com/users/xtracoder/events{/privacy}","received_events_url":"https://api.github.com/users/xtracoder/received_events","type":"User","site_admin":false},"created_at":"2015-12-17T15:37:47Z","updated_at":"2015-12-17T15:37:47Z","body":"Yep, of course something has to be fixed in 'that' plugin and will take about it separately. I'm just saying that Bnd better be somewhat more bullet-proof in that case of 'wrong' usage."}}