Closed dpolivaev closed 6 years ago
(the version of freeplane launcher containing this call to getResource is not submitted to git, it was only created for test. The exception is thrown from line URL resource = classLoader.getResource(foo);
)
private Controller launchWithoutUICheck(String[] args) {
if(freeplaneLaunched)
throw new IllegalStateException("Freeplane already launched");
freeplaneLaunched = true;
setDefines();
if (! disableSecurityManager)
System.setSecurityManager(new SecurityManager(){
@Override
public void checkConnect(String pHost, int pPort, Object pContext) {
if(pContext != null)
super.checkConnect(pHost, pPort, pContext);
else
super.checkConnect(pHost, pPort);
}
});
setArgProperties(args);
final Controller controller = startFramework();
ClassLoader classLoader = controller.getClass().getClassLoader();
String foo = Controller.class.getPackage().getName().replace('.', '/') + '/' + "foo.txt";
URL resource = classLoader.getResource(foo);
return controller;
}
Thanks for the PR. We'll have a closer look at it in a day or two.
Thanks, Christer
Thanks for the fix.
If bundle class loader should find a resource from package loaded by application class loader and this resource is not available, it currently throws NoSuchElementException instead of returning null.
It happens because it delegates to application class loader
which can return non null enumeration which is empty.
The pull request adds a check for this case.