Fixed normalized paths bug that prevented copying class in IDE. Issue 8497
If both repo and project paths were symlinks or network drive paths, copying with refactoring caused exceptions to be thrown. Other actions may have resulted in the same.
A normalized file path canNOT be passed into getIgnores because getIgnores creates and executes a StatusCommand. Executing the StatusCommand passes the repository and the source file. StatusCommand gets the repository path by calling repository.getWorkTree(), which returns a non-normalized path.
If both the repository and the source file are referenced via a symlink or network drive, referencing file paths via normalizing and non-normaling causes file path mismatches.
The normalized file path points to another location on the system, but repository.getWorkTree() will provide a non-normalized file path.
^Add meaningful description above
Click to collapse/expand PR instructions
By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
- are all your own work, and you have the right to contribute them.
- are contributed solely under the terms and conditions of the Apache License 2.0 (see section 5 of the license for more information).
Please make sure (eg. git log) that all commits have a valid name and email address for you in the Author field.
If you're a first time contributor, see the Contributing guidelines for more information.
If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.
PR approval and merge checklist:
- [x] Was this PR correctly labeled, did the right tests run? When did they run?
- [x] Is this PR squashed?
- [x] Are author name / email address correct? Are co-authors correctly listed? Do the commit messages need updates?
- [x] Does the PR title and description still fit after the Nth iteration? Is the description sufficient to appear in the release notes?
If this PR targets the delivery branch: don't merge. (full wiki article)
This is the exception it fixes:
java.lang.IllegalArgumentException: \\localhost\C$\Users\hunte\Documents\NetBeansProjects\SkoonieJavaLibraries\src\com\skoonie\model\persistentdata\PersistentDataSetHandlerInterface_1_1.java is not under V:\SkoonieJavaLibraries
at org.netbeans.libs.git.jgit.Utils.getRelativePath(Utils.java:228)
at org.netbeans.libs.git.jgit.Utils.getRelativePath(Utils.java:223)
at org.netbeans.libs.git.jgit.Utils.getRelativePath(Utils.java:205)
at org.netbeans.libs.git.jgit.Utils.getRelativePaths(Utils.java:198)
at org.netbeans.libs.git.jgit.Utils.getPathFilters(Utils.java:115)
at org.netbeans.libs.git.jgit.commands.StatusCommand.run(StatusCommand.java:115)
at org.netbeans.libs.git.jgit.commands.MoveTreeCommand.getIgnores(MoveTreeCommand.java:206)
at org.netbeans.libs.git.jgit.commands.MoveTreeCommand.run(MoveTreeCommand.java:84)
at org.netbeans.libs.git.jgit.commands.GitCommand$1.run(GitCommand.java:56)
at org.netbeans.libs.git.jgit.commands.GitCommand$1.run(GitCommand.java:53)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:571)
at org.netbeans.libs.git.jgit.commands.GitCommand.execute(GitCommand.java:53)
at org.netbeans.libs.git.GitClient.copyAfter(GitClient.java:505)
at org.netbeans.modules.git.client.GitClient$10.call(GitClient.java:307)
at org.netbeans.modules.git.client.GitClient$10.call(GitClient.java:303)
at org.netbeans.modules.git.client.GitClient$CommandInvoker$1$1.call(GitClient.java:933)
at org.netbeans.modules.git.client.GitClient$CommandInvoker$1.call(GitClient.java:956)
at org.netbeans.modules.git.FilesystemInterceptor.runWithoutExternalEvents(FilesystemInterceptor.java:477)
at org.netbeans.modules.git.Git.runWithoutExternalEvents(Git.java:259)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.runMethodIntern(GitClient.java:966)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.runMethod(GitClient.java:893)
at org.netbeans.modules.git.client.GitClient.copyAfter(GitClient.java:303)
at org.netbeans.modules.git.FilesystemInterceptor.doCopy(FilesystemInterceptor.java:363)
at org.netbeans.modules.versioning.DelegatingVCS$4.doCopy(DelegatingVCS.java:314)
at org.netbeans.modules.versioning.core.filesystems.VCSFilesystemInterceptor$DelegatingInterceptor.doCopy(VCSFilesystemInterceptor.java:640)
at org.netbeans.modules.versioning.core.filesystems.VCSFilesystemInterceptor$DelegatingInterceptor$2.handle(VCSFilesystemInterceptor.java:699)
at org.netbeans.modules.versioning.masterfs.FilesystemInterceptor$2.handle(FilesystemInterceptor.java:318)
at org.netbeans.modules.masterfs.ProvidedExtensionsProxy$DelegatingIOHandler$1.run(ProvidedExtensionsProxy.java:507)
at org.netbeans.modules.masterfs.ProvidedExtensionsProxy.runCheckCode(ProvidedExtensionsProxy.java:467)
at org.netbeans.modules.masterfs.ProvidedExtensionsProxy.access$300(ProvidedExtensionsProxy.java:42)
at org.netbeans.modules.masterfs.ProvidedExtensionsProxy$DelegatingIOHandler.handle(ProvidedExtensionsProxy.java:504)
at org.netbeans.modules.masterfs.filebasedfs.fileobjects.BaseFileObj.handleMoveCopy(BaseFileObj.java:334)
at org.netbeans.modules.masterfs.filebasedfs.fileobjects.BaseFileObj.copy(BaseFileObj.java:229)
at org.openide.loaders.FileEntry.copy(FileEntry.java:52)
at org.openide.loaders.MultiDataObject.handleCopy(MultiDataObject.java:486)
at org.openide.loaders.DataObject$2.run(DataObject.java:671)
at org.openide.loaders.DataObjectPool$1WrapAtomicAction.run(DataObjectPool.java:236)
at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:102)
at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:494)
at org.openide.loaders.DataObjectPool.runAtomicAction(DataObjectPool.java:261)
at org.openide.loaders.DataObject.invokeAtomicAction(DataObject.java:1025)
at org.openide.loaders.DataObject.copy(DataObject.java:669)
at org.netbeans.modules.refactoring.java.ui.CopyClassRefactoringUI$1.run(CopyClassRefactoringUI.java:174)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1403)
at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2018)
@mbien I noticed that a build check failed. Is that something I need to figure out how to resolve or is that for you to resolve?
You can run the unittests locally, check if the problem is reproducible.
These seem to be real and related to the change:
2025-05-23T23:39:23.4747400Z [junit] Testcase: testCopyToIgnoredFile(org.netbeans.libs.git.jgit.commands.CopyTest): FAILED
2025-05-23T23:39:23.4747871Z [junit] expected:<false> but was:<true>
2025-05-23T23:39:23.4748269Z [junit] junit.framework.AssertionFailedError: expected:<false> but was:<true>
2025-05-23T23:39:23.4748864Z [junit] at org.netbeans.libs.git.jgit.AbstractGitTestCase.assertStatus(AbstractGitTestCase.java:139)
2025-05-23T23:39:23.4749540Z [junit] at org.netbeans.libs.git.jgit.commands.CopyTest.testCopyToIgnoredFile(CopyTest.java:304)
2025-05-23T23:39:23.4750411Z [junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2025-05-23T23:39:23.4751103Z [junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
2025-05-23T23:39:23.4752088Z [junit] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2025-05-23T23:39:23.4752748Z [junit] at org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:84)
2025-05-23T23:39:23.4753237Z [junit] at org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:489)
2025-05-23T23:39:23.4753701Z [junit] at org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:410)
2025-05-23T23:39:23.4754120Z [junit] at java.base/java.lang.Thread.run(Thread.java:840)
2025-05-23T23:39:23.4754426Z [junit]
2025-05-23T23:39:23.4754607Z [junit]
2025-05-23T23:39:23.4754974Z [junit] Testcase: testCopyToIgnored(org.netbeans.libs.git.jgit.commands.CopyTest): FAILED
2025-05-23T23:39:23.4755424Z [junit] expected:<false> but was:<true>
2025-05-23T23:39:23.4755818Z [junit] junit.framework.AssertionFailedError: expected:<false> but was:<true>
2025-05-23T23:39:23.4756417Z [junit] at org.netbeans.libs.git.jgit.AbstractGitTestCase.assertStatus(AbstractGitTestCase.java:139)
2025-05-23T23:39:23.4757336Z [junit] at org.netbeans.libs.git.jgit.commands.CopyTest.testCopyToIgnored(CopyTest.java:281)
2025-05-23T23:39:23.4758424Z [junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2025-05-23T23:39:23.4759565Z [junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
2025-05-23T23:39:23.4761026Z [junit] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2025-05-23T23:39:23.4762131Z [junit] at org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:84)
2025-05-23T23:39:23.4762922Z [junit] at org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:489)
2025-05-23T23:39:23.4763715Z [junit] at org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:410)
2025-05-23T23:39:23.4764427Z [junit] at java.base/java.lang.Thread.run(Thread.java:840)
2025-05-23T23:39:23.4764908Z [junit]
2025-05-23T23:39:23.4765199Z [junit]
2025-05-23T23:39:23.4827038Z [junit] Test org.netbeans.libs.git.jgit.commands.CopyTest FAILED
2025-05-23T23:39:55.7546859Z [junit] Testcase: testRenameToIgnoredFile(org.netbeans.libs.git.jgit.commands.RenameTest): FAILED
2025-05-23T23:39:55.7547722Z [junit] expected:<false> but was:<true>
2025-05-23T23:39:55.7548419Z [junit] junit.framework.AssertionFailedError: expected:<false> but was:<true>
2025-05-23T23:39:55.7549501Z [junit] at org.netbeans.libs.git.jgit.AbstractGitTestCase.assertStatus(AbstractGitTestCase.java:139)
2025-05-23T23:39:55.7550898Z [junit] at org.netbeans.libs.git.jgit.commands.RenameTest.testRenameToIgnoredFile(RenameTest.java:504)
2025-05-23T23:39:55.7552037Z [junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2025-05-23T23:39:55.7553208Z [junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
2025-05-23T23:39:55.7554614Z [junit] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2025-05-23T23:39:55.7555835Z [junit] at org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:84)
2025-05-23T23:39:55.7556728Z [junit] at org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:489)
2025-05-23T23:39:55.7557881Z [junit] at org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:410)
2025-05-23T23:39:55.7558664Z [junit] at java.base/java.lang.Thread.run(Thread.java:840)
2025-05-23T23:39:55.7559234Z [junit]
2025-05-23T23:39:55.7559568Z [junit]
2025-05-23T23:39:55.7560457Z [junit] Testcase: testRenameToIgnored(org.netbeans.libs.git.jgit.commands.RenameTest): FAILED
2025-05-23T23:39:55.7561322Z [junit] expected:<false> but was:<true>
2025-05-23T23:39:55.7562043Z [junit] junit.framework.AssertionFailedError: expected:<false> but was:<true>
2025-05-23T23:39:55.7563152Z [junit] at org.netbeans.libs.git.jgit.AbstractGitTestCase.assertStatus(AbstractGitTestCase.java:139)
2025-05-23T23:39:55.7564403Z [junit] at org.netbeans.libs.git.jgit.commands.RenameTest.testRenameToIgnored(RenameTest.java:486)
2025-05-23T23:39:55.7565582Z [junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2025-05-23T23:39:55.7566822Z [junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
2025-05-23T23:39:55.7568271Z [junit] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2025-05-23T23:39:55.7569442Z [junit] at org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:84)
2025-05-23T23:39:55.7570586Z [junit] at org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:489)
2025-05-23T23:39:55.7571447Z [junit] at org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:410)
2025-05-23T23:39:55.7572214Z [junit] at java.base/java.lang.Thread.run(Thread.java:840)
2025-05-23T23:39:55.7572770Z [junit]
2025-05-23T23:39:55.7573093Z [junit]
2025-05-23T23:39:55.7901472Z [junit] Test org.netbeans.libs.git.jgit.commands.RenameTest FAILED
2025-05-23T23:40:18.2069960Z [junit] ------------- ---------------- ---------------
2025-05-23T23:40:18.2070965Z [junit] Testcase: testAddSymlink(org.netbeans.libs.git.jgit.commands.AddTest): FAILED
2025-05-23T23:40:18.2071758Z [junit] expected:<0> but was:<11>
2025-05-23T23:40:18.2072432Z [junit] junit.framework.AssertionFailedError: expected:<0> but was:<11>
2025-05-23T23:40:18.2073445Z [junit] at org.netbeans.libs.git.jgit.commands.AddTest.testAddSymlink(AddTest.java:543)
2025-05-23T23:40:18.2074526Z [junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2025-05-23T23:40:18.2075737Z [junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
2025-05-23T23:40:18.2077164Z [junit] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2025-05-23T23:40:18.2078362Z [junit] at org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:84)
2025-05-23T23:40:18.2079217Z [junit] at org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:489)
2025-05-23T23:40:18.2080254Z [junit] at org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:410)
2025-05-23T23:40:18.2081290Z [junit] at java.base/java.lang.Thread.run(Thread.java:840)
2025-05-23T23:40:18.2081849Z [junit]
2025-05-23T23:40:18.2082160Z [junit]
2025-05-23T23:40:18.2818896Z [junit] Test org.netbeans.libs.git.jgit.commands.AddTest FAILED
2025-05-23T23:40:18.4073266Z [junit] WARNING: package com.apple.eio not in java.desktop
This one is most probably flaky (from the name it checks garbadge collection and this is unstable by definition):
2025-05-23T23:33:11.9078978Z [junit] Testcase: testInstanceCollected(org.netbeans.modules.git.ui.repository.RepositoryInfoTest): FAILED
2025-05-23T23:33:11.9079612Z [junit] Not collected
2025-05-23T23:33:11.9080137Z [junit] junit.framework.AssertionFailedError: Not collected
2025-05-23T23:33:11.9080787Z [junit] at org.netbeans.modules.git.ui.repository.RepositoryInfoTest.testInstanceCollected(RepositoryInfoTest.java:93)
2025-05-23T23:33:11.9081519Z [junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2025-05-23T23:33:11.9082189Z [junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
2025-05-23T23:33:11.9083108Z [junit] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2025-05-23T23:33:11.9083776Z [junit] at org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:84)
2025-05-23T23:33:11.9084248Z [junit] at org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:489)
2025-05-23T23:33:11.9084721Z [junit] at org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:410)
2025-05-23T23:33:11.9085149Z [junit] at java.base/java.lang.Thread.run(Thread.java:840)