tomasbjerre / violation-comments-lib

Library for commenting things with violations from static code analysis.
Apache License 2.0
12 stars 6 forks source link

NPE in PatchParser #1

Closed winterDroid closed 7 years ago

winterDroid commented 7 years ago

Recently I saw an NPE in the PatchParser:

java.lang.NullPointerException
14:47:20 [checks]   at se.bjurr.violations.comments.lib.PatchParser.findLineToComment(PatchParser.java:18)
14:47:20 [checks]   at se.bjurr.violations.comments.github.lib.GitHubCommentsProvider.shouldComment(GitHubCommentsProvider.java:147)
14:47:20 [checks]   at se.bjurr.violations.comments.lib.CommentsCreator.filterChanged(CommentsCreator.java:120)
14:47:20 [checks]   at se.bjurr.violations.comments.lib.CommentsCreator.<init>(CommentsCreator.java:41)
14:47:20 [checks]   at se.bjurr.violations.comments.lib.CommentsCreator.createComments(CommentsCreator.java:25)
14:47:20 [checks]   at se.bjurr.violations.comments.github.lib.ViolationCommentsToGitHubApi.toPullRequest(ViolationCommentsToGitHubApi.java:129)
14:47:20 [checks]   at se.bjurr.violations.comments.github.plugin.gradle.ViolationCommentsToGitHubTask.gitChangelogPluginTasks(ViolationCommentsToGitHubTask.java:142)
14:47:20 [checks]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:47:20 [checks]   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
14:47:20 [checks]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
14:47:20 [checks]   at java.lang.reflect.Method.invoke(Method.java:498)
14:47:20 [checks]   at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
14:47:20 [checks]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)
14:47:20 [checks]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
14:47:20 [checks]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
14:47:20 [checks]   at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:692)
14:47:20 [checks]   at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:675)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:115)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:109)
14:47:20 [checks]   at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
14:47:20 [checks]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
14:47:20 [checks]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:109)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:90)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:68)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.SkipCachedTaskExecuter.execute(SkipCachedTaskExecuter.java:94)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.ResolveBuildCacheKeyExecuter.execute(ResolveBuildCacheKeyExecuter.java:51)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:47)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
14:47:20 [checks]   at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
14:47:20 [checks]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
14:47:20 [checks]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
14:47:20 [checks]   at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
14:47:20 [checks]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
14:47:20 [checks]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
14:47:20 [checks]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
14:47:20 [checks]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
14:47:20 [checks]   at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
14:47:20 [checks]   at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
14:47:20 [checks]   at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
14:47:20 [checks]   at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
14:47:20 [checks]   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
14:47:20 [checks]   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
14:47:20 [checks]   at java.lang.Thread.run(Thread.java:745)
tomasbjerre commented 7 years ago

Do you have more stack trace? Would be interesting to see who calls the method and why it does not have a patchString to parse.

winterDroid commented 7 years ago

No that's all sorry.

tomasbjerre commented 7 years ago

There is a fix for this released now. The fix will just ignore a null-value and will not find any line to comment in that case.