Skip to content

Conversation

@mbien
Copy link
Member

@mbien mbien commented Oct 21, 2025

followup on #6094

Once Preferences is loaded containing U+0000 in a key, it can't be used anymore since even removing that key (e.g via clear()) will throw IAE.

What we can do however is to remove and recreate the Preferences node.

example output with this change active:

WARNING [org.apache.tools.ant.module.api.IntrospectedInfo]: skipping malformed key; pref path: /org/apache/tools/ant/module/customDefs, msg: Key contains code point U+0000
WARNING [org.apache.tools.ant.module.AntSettings]: recreating preferences node due to code point U+0000

tested by corrupting the config file using this script:

    static void main() throws java.io.IOException {
        String path = "netbeans/nbbuild/testuserdir/config/Preferences/org/apache/tools/ant/module/customDefs.properties";
        Files.writeString(
                Path.of(path),
                "\u0000",
                StandardOpenOption.APPEND
        );
    }

closes #8941
targets delivery

Once the Preferences is loaded containing U+0000 in a key, it can't
be used anymore since even removing that key (e.g via clear()) will
throw IAE.

What we can do however is to remove and recreate the Preferences node.
@mbien mbien added this to the NB28 milestone Oct 21, 2025
@mbien mbien added the Ant [ci] enable "build tools" tests label Oct 21, 2025
@mbien mbien requested a review from lkishalmi October 21, 2025 07:22
Copy link
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really ugly and IMHO a JDK issue. Anyway for us we have no real alternative, so I don't see an alternative.

@mbien
Copy link
Member Author

mbien commented Oct 21, 2025

agreed. At least clear() should be implemented in a way so that it can reliably clear preferences.

@ebarboni ebarboni merged commit a99e87c into apache:delivery Oct 23, 2025
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ant [ci] enable "build tools" tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

am getting an Unexpected Exception when cleaning a Netbeans project; can't use Netbeans for app developement now.

3 participants