Repository navigation
Declare the IntelliJ plugin incompatible with palantir-java-format - #278
Merged
Merged
Conversation
Both plugins register a project service named com.palantir.javaformat.intellij.PalantirJavaFormatSettings, and the IDE keys a service by its class name. With both enabled, one plugin's getService returns the instance the other plugin's class loader made, and its settings page fails with a ClassCastException (#276). Both replace the Java formatter, so the IDE now loads only one of them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on
21.X.X. Fixes #276.Before this PR
With palantir-java-format installed next to open-java-format, the settings page fails with a
ClassCastExceptionbetween two copies ofcom.palantir.javaformat.intellij.PalantirJavaFormatSettings, each from its ownPluginClassLoader. The trace in #276 is upstream's code: itsgetInstanceis at line 46 and itsisModifiedat line 108, lines that no open-java-format release has there.Both plugins register a project service with that class name, and the IDE keys a service by its class name, so one plugin's
project.getService(PalantirJavaFormatSettings.class)returns the instance made by the other's class loader. It can fail either way round, in either plugin's code.After this PR
==COMMIT_MSG==
plugin.xmldeclares<incompatible-with>palantir-java-format</incompatible-with>, so the IDE never loads the two together. Both replace the Java formatter, so running both was never useful.==COMMIT_MSG==
Checked
verifyPluginStructureand the plugin's tests pass. Not yet tried in an IDE with both plugins installed.Possible downsides?
Someone who has both plugins enabled ends up with only one of them. I haven't checked which one the IDE keeps or what it tells the user.
The real cause is still there: the plugin keeps upstream's package,
com.palantir.javaformat.intellij, and its state name,PalantirJavaFormatSettings. Moving to a package of its own would end the clash, but the stored state name would then need a migration for settings already inopen-java-format.xml, so that is left for a separate pull request.