Description
I very rare cases the Freemaker BundleTemplate loader is getting NPE when loading resources from bundles.
java.lang.NullPointerException at org.apache.felix.framework.BundleRevisionImpl.getResourceLocal(BundleRevisionImpl.java:495) at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1472) at org.apache.felix.framework.BundleWiringImpl.getResourceByDelegation(BundleWiringImpl.java:1400) at org.apache.felix.framework.Felix.getBundleResource(Felix.java:1600) at org.apache.felix.framework.BundleImpl.getResource(BundleImpl.java:639) at org.apache.stanbol.commons.freemarker.impl.BundleTemplateLoader.containsTemplates(BundleTemplateLoader.java:117)
This NPE happens when trying to load the resource `templates/` via Bundle.getResource(..). Even if it appears it does only affect few of the installed bundles.
As the call is only used to check if the folder `templates/` is available in a bundle an exception MUST NOT break the whole BundleTemplateLoader initialization. Because of that the code needs to be changed to catch this NPE and log it on WARN level.