Skip to content
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

Hi I am facing this issue while using repair command #335

Closed
DnvSaiteja opened this issue Jan 19, 2021 · 6 comments · Fixed by #591
Closed

Hi I am facing this issue while using repair command #335

DnvSaiteja opened this issue Jan 19, 2021 · 6 comments · Fixed by #591
Labels
bug Something isn't working

Comments

@DnvSaiteja
Copy link

DnvSaiteja commented Jan 19, 2021

java -jar sorald/target/sorald-1.1-SNAPSHOT-jar-with-dependencies.jar repair --original-files-path sorald/src/test/resources/processor_test_files/2095_UnclosedResources/ZipFolder.java --rule-keys 2095 --workspace outputdir

After executng above command, I am getting the below error

]
INFO Configured Java source version (sonar.java.source): 14
INFO JavaClasspath initialization
INFO JavaClasspath initialization (done) | time=36ms
INFO JavaTestClasspath initialization
INFO JavaTestClasspath initialization (done) | time=1ms
INFO Java Main Files AST scan
INFO 1 source files to be analyzed
INFO 1/1 source files have been analyzed
INFO Java Main Files AST scan (done) | time=2490ms
INFO Java Test Files AST scan
INFO 0 source files to be analyzed
INFO Java Test Files AST scan (done) | time=1ms
INFO Java Generated Files AST scan
INFO 0/0 source files have been analyzed
INFO 0 source files to be analyzed
INFO Java Generated Files AST scan (done) | time=0ms
INFO 0/0 source files have been analyzed
java.lang.IllegalArgumentException: 'other' is different type of Path
at java.base/sun.nio.fs.WindowsPath.relativize(WindowsPath.java:400)
at java.base/sun.nio.fs.WindowsPath.relativize(WindowsPath.java:42)
at sorald.event.models.WarningLocation.(WarningLocation.java:16)
at sorald.event.models.miner.MinedViolationEvent.(MinedViolationEvent.java:24)
at sorald.Repair.lambda$mineViolations$2(Repair.java:138)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at sorald.Repair.mineViolations(Repair.java:136)
at sorald.Repair.getRuleViolations(Repair.java:105)
at sorald.Repair.repair(Repair.java:88)
at sorald.cli.RepairCommand.call(RepairCommand.java:121)
at sorald.cli.RepairCommand.call(RepairCommand.java:27)
at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
at picocli.CommandLine.access$1200(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
at picocli.CommandLine.execute(CommandLine.java:2058)
at sorald.Main.main(Main.java:7)

@slarse
Copy link
Collaborator

slarse commented Jan 19, 2021

Hi @DnvSaiteja, and thanks for the bug report!

My gut feeling is that this is caused by insufficient Windows support from our side. We don't yet fully support Windows, although that is in the works (#273). It could be something else though, it's hard to say without the files you're trying to repair.

Could you provide the file(s) you are trying to repair? That way, we can try to reproduce the problem. Any file with which this problem occurs is enough, it doesn't necessarily have to be the ones you're actually trying to repair in this instance.

Nevermind, I see that you actually put the file in the initial post!

@slarse
Copy link
Collaborator

slarse commented Jan 19, 2021

Are you using Windows? It looks like you are as WindowsPath is being used, but the paths you're specifying on the command line are Unix paths.

If on Windows, try to change the paths like so:

java -jar sorald\target\sorald-1.1-SNAPSHOT-jar-with-dependencies.jar repair --original-files-path sorald\src\test\resources\processor_test_files\2095_UnclosedResources\ZipFolder.java --rule-keys 2095 --workspace outputdir

@DnvSaiteja
Copy link
Author

Hi, did anybody found a workaround for how to make sorald work for windows

@slarse
Copy link
Collaborator

slarse commented Jan 26, 2021

@DnvSaiteja Did you try the things I suggested with the paths? You appear to be supplying Unix-style paths (using / as a path separator) on a Windows system (where \ is the path separator), which probably won't work out.

There are circumstances where Sorald will fail on Windows, and this might be one of those. We are working on Windows support (#273), but it probably won't be ready for another couple of months as we currently have other tasks with higher priority at the moment.

@khaes-kth Can you try to replicate this crash on your system?

@slarse slarse added the bug Something isn't working label Jan 26, 2021
@khesoem
Copy link
Collaborator

khesoem commented Feb 23, 2021

Hi @slarse

I just remembered this issue. Sorry for being too late.

I get the same error:

INFO  1 source files to be analyzed
INFO  1/1 source files have been analyzed
java.lang.IllegalArgumentException: 'other' is different type of Path
        at java.base/sun.nio.fs.WindowsPath.relativize(WindowsPath.java:400)
        at java.base/sun.nio.fs.WindowsPath.relativize(WindowsPath.java:42)
        at sorald.event.models.WarningLocation.<init>(WarningLocation.java:16)
        at sorald.event.models.miner.MinedViolationEvent.<init>(MinedViolationEvent.java:24)
        at sorald.Repair.lambda$mineViolations$2(Repair.java:138)
        at java.base/java.lang.Iterable.forEach(Iterable.java:75)
        at sorald.Repair.mineViolations(Repair.java:136)
        at sorald.Repair.getRuleViolations(Repair.java:105)
        at sorald.Repair.repair(Repair.java:88)
        at sorald.cli.RepairCommand.call(RepairCommand.java:121)
        at sorald.cli.RepairCommand.call(RepairCommand.java:27)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
        at picocli.CommandLine.access$1200(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
        at picocli.CommandLine.execute(CommandLine.java:2058)
        at sorald.Main.main(Main.java:7)

The command:
java -jar sorald.jar repair --original-files-path ..\sorald\src\test\resources\processor_test_files\2095_UnclosedResources\ --rule-keys 2095 --workspace outputdir

Actually, that is the main issue I always face in Windows. That's why I added #273

@slarse
Copy link
Collaborator

slarse commented Feb 23, 2021

@khaes-kth thanks for taking a look.

This would then probably be fixed by fixing #166. I will get on that most likely next week as I've faced several difficult-to-debug bugs in the past week simply because of paths being represented by strings a little here and there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

3 participants