Skip to content

Fixed normalized paths bug that prevented copying class in IDE. Issue 8497 #8499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FolsomHunter
Copy link

@FolsomHunter FolsomHunter commented May 10, 2025

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:

  1. Was this PR correctly labeled, did the right tests run? When did they run?
  2. Is this PR squashed?
  3. Are author name / email address correct? Are co-authors correctly listed? Do the commit messages need updates?
  4. 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)

@FolsomHunter
Copy link
Author

FolsomHunter commented May 10, 2025

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)

@FolsomHunter FolsomHunter force-pushed the dev-HSS-gitMoveTreeCommandSymLinkBugFix branch from 98b4a6e to 452a7f7 Compare May 11, 2025 00:42
@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) git [ci] enable versioning job and removed Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) labels May 12, 2025
@mbien mbien added this to the NB27 milestone May 22, 2025
… 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.

Signed-off-by: Hunter Schoonover <hunter@skoonie.com>
@FolsomHunter FolsomHunter force-pushed the dev-HSS-gitMoveTreeCommandSymLinkBugFix branch from 452a7f7 to 15dbcee Compare May 23, 2025 23:14
@FolsomHunter
Copy link
Author

@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?

@matthiasblaesing
Copy link
Contributor

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)

@apache apache locked and limited conversation to collaborators Jul 18, 2025
@apache apache unlocked this conversation Jul 18, 2025
@ebarboni ebarboni modified the milestones: NB27, NB28 Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
git [ci] enable versioning job
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Netbeans IDE Unexpected Exception occurs when performing refactor copy to a new package with a new class name.
4 participants