Skip to content

Commit

Permalink
Fix NPE in EclipseXmlFormatterStepImpl (diffplug#489)
Browse files Browse the repository at this point in the history
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()
  • Loading branch information
Anders Sundelin authored and Anders Sundelin committed Nov 26, 2019
1 parent d4b9b88 commit 4c46f99
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public class GrEclipseFormatterStepImpl {
private final boolean ignoreFormatterProblems;

public GrEclipseFormatterStepImpl(final Properties properties) throws Exception {
if (SpotlessEclipseFramework.setup(
SpotlessEclipseFramework.setup(
config -> {
config.applyDefault();
config.useSlf4J(GrEclipseFormatterStepImpl.class.getPackage().getName());
},
plugins -> {
plugins.add(new GroovyCoreActivator());
})) {}
});
PreferenceStore preferences = createPreferences(properties);
preferencesStore = new FormatterPreferencesOnStore(preferences);
ignoreFormatterProblems = Boolean.parseBoolean(properties.getProperty(IGNORE_FORMATTER_PROBLEMS, "false"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public EclipseXmlFormatterStepImpl(Properties properties) throws Exception {
xmlAdapterFactory = new ModelQueryAdapterFactoryForXML();
}

private static void setupFramework(boolean resolveExternalURI) throws BundleException {
private synchronized static void setupFramework(boolean resolveExternalURI) throws BundleException {
if (SpotlessEclipseFramework.setup(
config -> {
config.applyDefault();
Expand Down

0 comments on commit 4c46f99

Please sign in to comment.