Skip to content

java.lang.IllegalArgumentException: Key contains code point U+0000 #6076

Closed

Description

@maryam-yousefi-Canada

Apache NetBeans version

Apache NetBeans 18

What happened

When I build the java project, the process bar keeps ongoing and does not finish. There is an error message beside it.
messages.log

How to reproduce

No response

Did this work correctly in an earlier version?

Apache NetBeans 17

Operating System

Windows 10

JDK

17

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

since yesterday it occurs every time I build the project

Are you willing to submit a pull request?

No

Activity

  1. added
    kind:bug
    needs:triage
    on Jun 14, 2023
  2. mbien commented on Jun 15, 2023

    @mbien
    Member
    SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor org.apache.tools.ant.module.bridge.impl.BridgeImpl$PostRun
    java.lang.IllegalArgumentException: Key contains code point U+0000
    	at java.prefs/java.util.prefs.AbstractPreferences.get(AbstractPreferences.java:296)
    	at org.apache.tools.ant.module.api.IntrospectedInfo$3.load(IntrospectedInfo.java:681)
    	at org.apache.tools.ant.module.AntSettings.getCustomDefs(AntSettings.java:119)
    	at org.apache.tools.ant.module.bridge.impl.BridgeImpl$PostRun.run(BridgeImpl.java:443)
    	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
    	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
    	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
    

    duplicate of #5147, #5633

  3. added
    Ant
    on Jun 15, 2023
  4. neilcsmith-net commented on Jun 15, 2023

    @neilcsmith-net
    Member

    @mbien probably #5634 as well. Noticed same message in the log there.

  5. added and removed
    needs:triage
    on Jun 15, 2023
  6. mbien commented on Jun 15, 2023

    @mbien
    Member

    all reported issues, including the old ones are using windows:
    https://bz.apache.org/netbeans/show_bug.cgi?id=271652
    https://issues.apache.org/jira/browse/NETBEANS-3284

    additional to #6076 (comment)

    this is from bugzilla

    java.lang.IllegalArgumentException: Key contains code point U+0000
       at java.util.prefs.AbstractPreferences.get(AbstractPreferences.java:296)
       at java.util.prefs.AbstractPreferences.getBoolean(AbstractPreferences.java:531)
       at org.netbeans.core.windows.TopComponentTracker.load(TopComponentTracker.java:99)
       at org.netbeans.core.windows.PersistenceHandler.load(PersistenceHandler.java:126)
       at org.netbeans.core.windows.WindowSystemImpl.load(WindowSystemImpl.java:81)
       at org.netbeans.core.GuiRunLevel$InitWinSys.run(GuiRunLevel.java:229)
    

    and this from stackoverflow

    java.lang.IllegalArgumentException: Key contains code point U+0000
        at java.prefs/java.util.prefs.AbstractPreferences.get(AbstractPreferences.java:296)
        at org.netbeans.modules.maven.queries.MavenFileOwnerQueryImpl.registerCoordinates(MavenFileOwnerQueryImpl.java:153)
        at org.netbeans.modules.maven.ProjectOpenedHookImpl.registerWithSubmodules(ProjectOpenedHookImpl.java:431)
        at org.netbeans.modules.maven.ProjectOpenedHookImpl.projectOpened(ProjectOpenedHookImpl.java:138)
        at org.netbeans.spi.project.ui.ProjectOpenedHook$1.projectOpened(ProjectOpenedHook.java:60)
    [catch] at org.netbeans.modules.project.ui.OpenProjectList.notifyOpened(OpenProjectList.java:1273)
        at org.netbeans.modules.project.ui.OpenProjectList.doOpenProject(OpenProjectList.java:1354)
        at org.netbeans.modules.project.ui.OpenProjectList.open(OpenProjectList.java:798)
        at org.netbeans.modules.project.ui.OpenProjectList$6.run(OpenProjectList.java:650)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
        at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
        at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
    
  7. changed the title [-]A java lang illegal argument exception has occured[/-] [+]java.lang.IllegalArgumentException: Key contains code point U+0000[/+] on Jun 15, 2023
  8. mbien commented on Jun 15, 2023

    @mbien
    Member

    reading @lkishalmi comment makes me think we should change the config importer to only import "recent" configs. E.g N-2,

    I think this would have avoided several issues by now if we would have restricted it a while ago.

  9. mbien commented on Jun 15, 2023

    @mbien
    Member
  10. FernandoY2203 commented on Jun 15, 2023

    @FernandoY2203

    I had the same problem and this question on stack helped me:
    https://stackoverflow.com/questions/51244824/exception-creating-new-maven-project-in-apache-netbeans9
    I found a .properties file in that path
    C:\Users[your username]\AppData\Roaming\NetBeans\16\config\Preferences\org\apache\tools\ant\module
    containing lines full of \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000
    So I removed the file, restarted netbeans and the error was resolved.

  11. neilcsmith-net commented on Jun 15, 2023

    @neilcsmith-net
    Member

    reading @lkishalmi comment makes me think we should change the config importer to only import "recent" configs. E.g N-2,

    @mbien yes, that would make sense, and simplify some things in that code. I've thought before we should also merge some of the behaviour in the Options window import and the upgrader. The Options import would remain available for people wanting to import some things from earlier versions anyway.

  12. mbien commented on Jun 19, 2023

    @mbien
    Member

    @maryam-yousefi-Canada It would be good to know if there are more corrupted properties files in your config. Could you run this utility which scans all property files of your netbeans configs for invalid code points?

    You can simply paste it into a maven project and run it on JDK 11+, thanks!

    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.util.stream.Stream;
    
    public class NbConfigScanner {
    
        public static void main(String[] args) throws IOException {
            System.out.println(Runtime.version());
            Path path = Path.of("C:\\Users\\myousefi\\AppData\\Roaming\\NetBeans");
            try (Stream<Path> configs = Files.list(path)) {
                configs.filter(Files::isDirectory)
                       .sorted()
                       .forEach(NbConfigScanner::check);
            }
        }
    
        private static void check(Path config) {
            System.out.println("checking: "+config);
            try (Stream<Path> stream = Files.walk(config)) {
                stream.filter(path -> path.getFileName().toString().endsWith(".properties"))
                      .forEach(path -> {
                            try {
                                if (Files.readString(path).indexOf('\u0000') != -1) {
                                    System.out.println("WARNING: "+path+" contains invalid code points");
                                }
                            } catch (IOException ex) {
                                ex.printStackTrace();
                            }
                      });
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Antkind:bugos:windows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions