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

Fix ParsingException in cases of null file parameter #1643

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

jepst
Copy link
Contributor

@jepst jepst commented Mar 6, 2024

The comment for the constructor indicates that the file parameter can be null, but the constructMessage method will NPE if file is null.

This fixes the following: the 5.0 build crashes for me when running under OpenJDK 22 as follows:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.io.File.toString()" because "file" is null
	at de.jplag.ParsingException.constructMessage(ParsingException.java:79)
	at de.jplag.ParsingException.<init>(ParsingException.java:31)
	at de.jplag.java.JavacAdapter.lambda$processErrors$1(JavacAdapter.java:80)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:212)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:194)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1709)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:556)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:546)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:622)
	at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:291)
	at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:631)
	at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:637)
	at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:642)
	at de.jplag.java.JavacAdapter.processErrors(JavacAdapter.java:81)
	at de.jplag.java.JavacAdapter.parseFiles(JavacAdapter.java:58)
	at de.jplag.java.Parser.parse(Parser.java:24)
	at de.jplag.java.JavaLanguage.parse(JavaLanguage.java:48)
	at de.jplag.Submission.parse(Submission.java:255)
	at de.jplag.SubmissionSet.parseSubmissions(SubmissionSet.java:159)
	at de.jplag.SubmissionSet.parseAllSubmissions(SubmissionSet.java:111)
	at de.jplag.SubmissionSet.<init>(SubmissionSet.java:49)
	at de.jplag.SubmissionSetBuilder.buildSubmissionSet(SubmissionSetBuilder.java:102)
	at de.jplag.JPlag.run(JPlag.java:73)
	at de.jplag.cli.CLI.runJPlag(CLI.java:132)
	at de.jplag.cli.CLI.main(CLI.java:92)

The comment for the constructor indicates that the file parameter
can be null, but the constructMessage method will NPE if file is
null.
@tsaglam tsaglam added bug Issue/PR that involves a bug minor Minor issue/feature/contribution/change labels Mar 11, 2024
Copy link

Quality Gate Passed Quality Gate passed for 'JPlag Plagiarism Detector'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link
Member

@tsaglam tsaglam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for your fix.

@tsaglam tsaglam changed the base branch from main to develop March 11, 2024 08:32
@tsaglam tsaglam merged commit 93a0420 into jplag:develop Mar 11, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue/PR that involves a bug minor Minor issue/feature/contribution/change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants