Details
-
Bug
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
None
-
None
-
None
-
Pulsar
-
Platform 203 - Beanless 1
Description
For some reason not completely clear to me, the code below in PluginUserSession:
if (session == null) { Main main = (Main)Application.get(); if (fallbackCredentials == null) { try { main.getRepository(); // side effect of reinitializing fallback credentials } catch (RepositoryException ignored) { } } if (fallbackSession == null) { try { fallbackSession = JcrSessionModel.login(fallbackCredentials); } catch (RepositoryException e) { log.warn("Cannot login fallback session: " + e.getMessage()); } }
can result in fallbackCredentials still being null, while main.getRepository() should set the fallback credentials (static class member of PluginUserSession). That this happens during tests is not strange since 'main' gets subclassed in tests which do not set the fallbackCredentials
Since PluginUserSession is serializable, it should not rely in static class variables imho. Hence, improve the code to avoid odd possible NPE's