-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NPE in EclipseXmlFormatterStepImpl.java / PREFERENCE_FACTORY is null #489
Comments
Did some more digging into this issue - sharing my thoughts here - please comment if you'd like:
Rationale: How can Simply looking in the code reveals the issue at hand: Lines 185 to 188 in d4b9b88
The designers of this class made a singleton-ish like implementation, and indeed protected the method via the synchronized modifier. To see this, simply perform the following thought experiment: Hence, the NPE in the above stacktrace. The most obvious solution would be to redo the configuration and initialization part (maybe centralizing to a central repository, where other components fetch their config, always) This calls for a redesign of the various components. The problem described in this issue report could, in all likelihood (but I have not tried this in production), be solved by making the |
Wow! Thanks very much for digging in so deeply. @fvgh generally maintains this bit, and I believe he's quite busy at the moment, so it might be a while before he has a chance to dig in. Regardless, we'd be happy to take a PR for this. Just as an FYI, when you're looking at code in GitHub, you can press |
Thanks for the GitHub trick, @nedtwigg! |
@epkanol Thanks for the research. I wanted to refactor this part of the code for quite some time. Once due to the problem you mentioned, but the complete interface was based on initial assumptions that there are dependencies between If you are interested, I am of-course also happy about any PR refactoring that part of the framework. Thanks for your help and sorry for letting you run into the problem in the first place... |
The method EclipseXmlFormatterStepImpl used the return value of SpotlessEclipseFramework.setup() ir order to take decisions whether or not to initialize. This introduced a race condition, which is fixed by making the method synchronized. Also removed another empty if-statement in GrEclipseFormatterStepImpl which also called SpotlessEclipseFramework.setup()
The method EclipseXmlFormatterStepImpl used the return value of SpotlessEclipseFramework.setup() ir order to take decisions whether or not to initialize. This introduced a race condition, which is fixed by making the method synchronized. Also removed another empty if-statement in GrEclipseFormatterStepImpl which also called SpotlessEclipseFramework.setup()
Fix NPE in EclipseXmlFormatterStepImpl (#489)
Published in x.26.1 |
NPE in EclipseXmlFormatterStepImpl.java at line 64
Saw this on one of our build machines, but could not reproduce locally on a 4-core laptop.
Happened after a retrigger of the build (due to environmental issues). Reproduced twice in a row (retriggering the Jenkins build), and a third time after submitting a new patch.
Only seen it in one repo so far, we have other repos (around 10) where XML formatting works like a charm
Command line used from Jenkins is
Judging from the code (albeit only checked master), PREFERENCE_FACTORY is null, meaning that
the static method setupFramework() either has not been called (yet), or
SpotlessEclipseFramework.setup() returned false for some reason
This is the spotless version:
classpath group: 'com.diffplug.spotless', name: 'spotless-plugin-gradle', version: '3.24.2'
This is the spotless configuration:
The xml prefs are standard eclipse prefs:
The text was updated successfully, but these errors were encountered: