apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.55k stars 813 forks source link

Fix: Settings persistence does not work for inner-class hints #7077

Closed mbien closed 1 month ago

mbien commented 2 months ago

Settings persistence does not like keys with $ signs in them. Two hints (bugs.Unbalanced$Array and $Collection) were implemented via annotated inner classes and can't be disabled by the user since the FQN is used as key/id by default.

~Easiest fix seems to be to change the default id generation a bit and replace '$' with '_'. I am sure this could be also implemented somewhere later in the logic but I couldn't find the reason why the preference entry is quietly ignored, so I went for the easy option.~

However a better option might be to encode the $ in AuxiliaryConfigBasedPreferencesProvider which is already encoding other chars.

how to replicate:

matthiasblaesing commented 2 months ago

What happens in the problematic cases? This sounds like the problem lies deeper and should be fixed at the root.

mbien commented 2 months ago

you are right. I couldn't find it yesterday, but I did find it today. Enabling all tests since this would be in the project api itself.

btw invalid keys will produce a warning:

WARNING [org.netbeans.modules.maven.MavenProjectPropsImpl]: #200901: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. from org-netbeans-spi-editor-hints-projects.text.x-java.org_2e_netbeans_2e_modules_2e_java_2e_hints_2e_bugs_2e_Unbalanced$Collection.enabled

here: https://github.com/apache/netbeans/blob/6a9d501fd805541ed261fd371772ab772c294c7f/java/maven/src/org/netbeans/modules/maven/MavenProjectPropsImpl.java#L174-L179