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

[core] Can't analyze sources in zip files #4248

Closed
adangel opened this issue Dec 1, 2022 · 1 comment · Fixed by #4249
Closed

[core] Can't analyze sources in zip files #4248

adangel opened this issue Dec 1, 2022 · 1 comment · Fixed by #4249
Labels
a:bug PMD crashes or fails to analyse a file.
Milestone

Comments

@adangel
Copy link
Member

adangel commented Dec 1, 2022

Affects PMD Version: since 6.44.0

Description:

When specifying a zip file to analyze, PMD fails with the following exception:

Exception Stacktrace:

FINE: java.nio.file.ProviderNotFoundException: Provider "zip" not found
	at java.base/java.nio.file.FileSystems.getFileSystem(FileSystems.java:238)
	at net.sourceforge.pmd.lang.document.FileCollector.addZipFile(FileCollector.java:319)
	at net.sourceforge.pmd.internal.util.FileCollectionUtil.addRoot(FileCollectionUtil.java:132)
	at net.sourceforge.pmd.internal.util.FileCollectionUtil.collectFiles(FileCollectionUtil.java:97)
	at net.sourceforge.pmd.internal.util.FileCollectionUtil.collectFiles(FileCollectionUtil.java:70)
	at net.sourceforge.pmd.PmdAnalysis.create(PmdAnalysis.java:113)
	at net.sourceforge.pmd.PMD.doPMD(PMD.java:247)
	at net.sourceforge.pmd.PMD.runPmd(PMD.java:505)
	at net.sourceforge.pmd.PMD.runPmd(PMD.java:472)
	at net.sourceforge.pmd.PMD.main(PMD.java:418)

Code Sample demonstrating the issue:

$ ~/PMD/binaries/pmd-bin-6.51.0/bin/run.sh pmd -d target/maven-pmd-plugin-it-Smoke-1.0-SNAPSHOT-sources.jar -R rulesets/java/quickstart.xml -f text
Nov 24, 2022 9:53:36 AM net.sourceforge.pmd.util.log.internal.SimpleMessageReporter logImpl
SEVERE: Cannot open zip file target/maven-pmd-plugin-it-Smoke-1.0-SNAPSHOT-sources.jar: Provider "zip" not found
Nov 24, 2022 9:53:37 AM net.sourceforge.pmd.PMD encourageToUseIncrementalAnalysis
WARNING: This analysis could be faster, please consider using Incremental Analysis: https://pmd.github.io/pmd-6.51.0/pmd_userdocs_incremental_analysis.html

Running PMD through: [CLI]

Note: found in #4214 (comment)

@adangel adangel added the a:bug PMD crashes or fails to analyse a file. label Dec 1, 2022
@adangel adangel added this to the 6.53.0 milestone Dec 1, 2022
@adangel adangel changed the title [core] Can't analyze sources in zip file [core] Can't analyze sources in zip files Dec 1, 2022
@jsotuyod
Copy link
Member

jsotuyod commented Dec 1, 2022

As per this docs it seems that:

  1. the scheme should not be zip, but jar
  2. we may need to call FileSystems.newFileSystem(zipUri, Collections.emptyMap()) instead of FileSystems.getFileSystem(zipUri)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug PMD crashes or fails to analyse a file.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants