Community
Participate
Working Groups
In the initializeServices method, line 420 of 3.5, we have if (profileId == null) preservedProfile = System.setProperty(PROP_P2_PROFILE, profileId); else System.getProperties().remove(PROP_P2_PROFILE); If profileId is actually null we will throw a NullPointerException. I think this wasn't discovered because it is not possible to get null with the current code. Line 675 of restoreServices seems to have the correct implementation.
Fixed.
The mentioned piece of code in its original form had the unpleasant consequence of not setting the preservedProfile in case profileId != null, as in that case the return value of: System.getProperties().remove(PROP_P2_PROFILE); was ignored, which caused P2 not to be re-initialized properly later on. So I suggest to improve the (already fixed) code in the following way: if (profileId != null) preservedProfile = System.setProperty(PROP_P2_PROFILE, profileId); else preservedProfile = (String)System.getProperties().remove(PROP_P2_PROFILE); Note that I realize that the else branch is currently not reachable, this is just for the case it became reachable by changes in other parts of the class's code. The other option is to throw an exception in the else branch to make it apparent that it's really not to be reached.
Change released.