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

[java] ImplicitSwitchFallThrough NPE in PMD 7.0.0-rc1 #4505

Closed
oowekyala opened this issue Apr 24, 2023 · 0 comments · Fixed by #4506
Closed

[java] ImplicitSwitchFallThrough NPE in PMD 7.0.0-rc1 #4505

oowekyala opened this issue Apr 24, 2023 · 0 comments · Fixed by #4506
Labels
a:bug PMD crashes or fails to analyse a file.
Milestone

Comments

@oowekyala
Copy link
Member

oowekyala commented Apr 24, 2023

The exceptions from my initial post #4499 are corrected with PMD 7 and the snapshot maven plugin.

However, I get a different set of exceptions with PMD 7.0.0:

[WARNING] Exception applying rule ImplicitSwitchFallThrough on file file:///home/luc/sources/eclipse/hipparchus/hipparchus-ode/src/main/java/org/hipparchus/ode/events/FilterType.java, continuing with next rule
org.apache.commons.lang3.exception.ContextedRuntimeException: java.lang.NullPointerException
Exception Context:
	[1:Rule applied on node=!debug only! [SwitchStatement:152:17]switch (previous) {
                    case UNINITIALIZED :
                        // we are initializing the first point
               (truncated)]
---------------------------------
    at net.sourceforge.pmd.util.AssertionUtil.contexted (AssertionUtil.java:232)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex (RuleApplicator.java:77)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply (RuleApplicator.java:55)
    at net.sourceforge.pmd.RuleSets.apply (RuleSets.java:158)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource (PmdRunnable.java:140)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.run (PmdRunnable.java:80)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)
Caused by: java.lang.NullPointerException
    at java.util.Objects.requireNonNull (Objects.java:208)
    at net.sourceforge.pmd.lang.java.rule.internal.DataflowPass$DataflowResult.switchBranchFallsThrough (DataflowPass.java:263)
    at net.sourceforge.pmd.lang.java.rule.errorprone.ImplicitSwitchFallThroughRule.visit (ImplicitSwitchFallThroughRule.java:39)
    at net.sourceforge.pmd.lang.java.ast.ASTSwitchStatement.acceptVisitor (ASTSwitchStatement.java:20)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.acceptVisitor (AbstractJavaNode.java:38)
    at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.apply (AbstractJavaRule.java:24)
    at net.sourceforge.pmd.lang.rule.AbstractDelegateRule.apply (AbstractDelegateRule.java:238)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex (RuleApplicator.java:75)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply (RuleApplicator.java:55)
    at net.sourceforge.pmd.RuleSets.apply (RuleSets.java:158)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource (PmdRunnable.java:140)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.run (PmdRunnable.java:80)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)
[WARNING] Exception occurred on node !debug only! [SwitchStatement:152:17]switch (previous) {
                    case UNINITIALIZED :
                        // we are initializing the first point
               (truncated)
[WARNING] Exception applying rule ImplicitSwitchFallThrough on file file:///home/luc/sources/eclipse/hipparchus/hipparchus-ode/src/main/java/org/hipparchus/ode/events/FilterType.java, continuing with next rule
org.apache.commons.lang3.exception.ContextedRuntimeException: java.lang.NullPointerException
Exception Context:
	[1:Rule applied on node=!debug only! [SwitchStatement:275:17]switch (previous) {
                    case UNINITIALIZED :
                        // we are initializing the first point
               (truncated)]
---------------------------------
    at net.sourceforge.pmd.util.AssertionUtil.contexted (AssertionUtil.java:232)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex (RuleApplicator.java:77)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply (RuleApplicator.java:55)
    at net.sourceforge.pmd.RuleSets.apply (RuleSets.java:158)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource (PmdRunnable.java:140)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.run (PmdRunnable.java:80)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)
Caused by: java.lang.NullPointerException
    at java.util.Objects.requireNonNull (Objects.java:208)
    at net.sourceforge.pmd.lang.java.rule.internal.DataflowPass$DataflowResult.switchBranchFallsThrough (DataflowPass.java:263)
    at net.sourceforge.pmd.lang.java.rule.errorprone.ImplicitSwitchFallThroughRule.visit (ImplicitSwitchFallThroughRule.java:39)
    at net.sourceforge.pmd.lang.java.ast.ASTSwitchStatement.acceptVisitor (ASTSwitchStatement.java:20)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.acceptVisitor (AbstractJavaNode.java:38)
    at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.apply (AbstractJavaRule.java:24)
    at net.sourceforge.pmd.lang.rule.AbstractDelegateRule.apply (AbstractDelegateRule.java:238)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex (RuleApplicator.java:75)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply (RuleApplicator.java:55)
    at net.sourceforge.pmd.RuleSets.apply (RuleSets.java:158)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource (PmdRunnable.java:140)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.run (PmdRunnable.java:80)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)
[WARNING] Exception occurred on node !debug only! [SwitchStatement:275:17]switch (previous) {
                    case UNINITIALIZED :
                        // we are initializing the first point
               (truncated)
[WARNING] Exception applying rule ImplicitSwitchFallThrough on file file:///home/luc/sources/eclipse/hipparchus/hipparchus-ode/src/main/java/org/hipparchus/ode/events/FilterType.java, continuing with next rule
org.apache.commons.lang3.exception.ContextedRuntimeException: java.lang.NullPointerException
Exception Context:
	[1:Rule applied on node=!debug only! [SwitchStatement:97:17]switch (previous) {
                    case UNINITIALIZED :
                        // we are initializing the first point
               (truncated)]
---------------------------------
    at net.sourceforge.pmd.util.AssertionUtil.contexted (AssertionUtil.java:232)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex (RuleApplicator.java:77)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply (RuleApplicator.java:55)
    at net.sourceforge.pmd.RuleSets.apply (RuleSets.java:158)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource (PmdRunnable.java:140)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.run (PmdRunnable.java:80)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)
Caused by: java.lang.NullPointerException
    at java.util.Objects.requireNonNull (Objects.java:208)
    at net.sourceforge.pmd.lang.java.rule.internal.DataflowPass$DataflowResult.switchBranchFallsThrough (DataflowPass.java:263)
    at net.sourceforge.pmd.lang.java.rule.errorprone.ImplicitSwitchFallThroughRule.visit (ImplicitSwitchFallThroughRule.java:39)
    at net.sourceforge.pmd.lang.java.ast.ASTSwitchStatement.acceptVisitor (ASTSwitchStatement.java:20)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.acceptVisitor (AbstractJavaNode.java:38)
    at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.apply (AbstractJavaRule.java:24)
    at net.sourceforge.pmd.lang.rule.AbstractDelegateRule.apply (AbstractDelegateRule.java:238)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex (RuleApplicator.java:75)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply (RuleApplicator.java:55)
    at net.sourceforge.pmd.RuleSets.apply (RuleSets.java:158)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource (PmdRunnable.java:140)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.run (PmdRunnable.java:80)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)
[WARNING] Exception occurred on node !debug only! [SwitchStatement:97:17]switch (previous) {
                    case UNINITIALIZED :
                        // we are initializing the first point
               (truncated)
[WARNING] Exception applying rule ImplicitSwitchFallThrough on file file:///home/luc/sources/eclipse/hipparchus/hipparchus-ode/src/main/java/org/hipparchus/ode/events/FilterType.java, continuing with next rule
org.apache.commons.lang3.exception.ContextedRuntimeException: java.lang.NullPointerException
Exception Context:
	[1:Rule applied on node=!debug only! [SwitchStatement:330:17]switch (previous) {
                    case UNINITIALIZED :
                        // we are initializing the first point
               (truncated)]
---------------------------------
    at net.sourceforge.pmd.util.AssertionUtil.contexted (AssertionUtil.java:232)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex (RuleApplicator.java:77)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply (RuleApplicator.java:55)
    at net.sourceforge.pmd.RuleSets.apply (RuleSets.java:158)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource (PmdRunnable.java:140)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.run (PmdRunnable.java:80)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)
Caused by: java.lang.NullPointerException
    at java.util.Objects.requireNonNull (Objects.java:208)
    at net.sourceforge.pmd.lang.java.rule.internal.DataflowPass$DataflowResult.switchBranchFallsThrough (DataflowPass.java:263)
    at net.sourceforge.pmd.lang.java.rule.errorprone.ImplicitSwitchFallThroughRule.visit (ImplicitSwitchFallThroughRule.java:39)
    at net.sourceforge.pmd.lang.java.ast.ASTSwitchStatement.acceptVisitor (ASTSwitchStatement.java:20)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.acceptVisitor (AbstractJavaNode.java:38)
    at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.apply (AbstractJavaRule.java:24)
    at net.sourceforge.pmd.lang.rule.AbstractDelegateRule.apply (AbstractDelegateRule.java:238)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.applyOnIndex (RuleApplicator.java:75)
    at net.sourceforge.pmd.lang.rule.internal.RuleApplicator.apply (RuleApplicator.java:55)
    at net.sourceforge.pmd.RuleSets.apply (RuleSets.java:158)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.processSource (PmdRunnable.java:140)
    at net.sourceforge.pmd.lang.impl.PmdRunnable.run (PmdRunnable.java:80)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:833)
[WARNING] Exception occurred on node !debug only! [SwitchStatement:330:17]switch (previous) {
                    case UNINITIALIZED :
                        // we are initializing the first point
               (truncated)
[WARNING] There are 4 PMD processing errors:
[WARNING] /home/luc/sources/eclipse/hipparchus/hipparchus-ode/src/main/java/org/hipparchus/ode/events/FilterType.java: ContextedRuntimeException: java.lang.NullPointerException
Exception Context:
	[1:Rule applied on node=!debug only! [SwitchStatement:152:17]switch (previous) {
                    case UNINITIALIZED :
                        // we are initializing the first point
               (truncated)]
---------------------------------
/home/luc/sources/eclipse/hipparchus/hipparchus-ode/src/main/java/org/hipparchus/ode/events/FilterType.java: ContextedRuntimeException: java.lang.NullPointerException
Exception Context:
	[1:Rule applied on node=!debug only! [SwitchStatement:275:17]switch (previous) {
                    case UNINITIALIZED :
                        // we are initializing the first point
               (truncated)]
---------------------------------
/home/luc/sources/eclipse/hipparchus/hipparchus-ode/src/main/java/org/hipparchus/ode/events/FilterType.java: ContextedRuntimeException: java.lang.NullPointerException
Exception Context:
	[1:Rule applied on node=!debug only! [SwitchStatement:97:17]switch (previous) {
                    case UNINITIALIZED :
                        // we are initializing the first point
               (truncated)]
---------------------------------
/home/luc/sources/eclipse/hipparchus/hipparchus-ode/src/main/java/org/hipparchus/ode/events/FilterType.java: ContextedRuntimeException: java.lang.NullPointerException
Exception Context:
	[1:Rule applied on node=!debug only! [SwitchStatement:330:17]switch (previous) {
                    case UNINITIALIZED :
                        // we are initializing the first point
               (truncated)]
---------------------------------
[INFO] PMD version: 7.0.0-SNAPSHOT

Note that I did not fix the warnings from my 6.x.x version of mpd-ruleset.xml before running the check, but I doubt these warning are related to the exceptions.

Originally posted by @maisonobe in #4499 (comment)

See source file: https://github.com/Hipparchus-Math/hipparchus/blob/update-build-dependencies/hipparchus-ode/src/main/java/org/hipparchus/ode/events/FilterType.java

@oowekyala oowekyala added the a:bug PMD crashes or fails to analyse a file. label Apr 24, 2023
@oowekyala oowekyala added this to the 7.0.0 milestone Apr 24, 2023
@jsotuyod jsotuyod added in:type-resolution Affects the type resolution code and removed in:type-resolution Affects the type resolution code labels Apr 24, 2023
adangel added a commit to adangel/pmd that referenced this issue Apr 25, 2023
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