Gradle waits unconditionally for Findbugs results, without considering the state of the worker

org.gradle.api.plugins.quality.internal.findbugs.FindBugsWorkerClient#getResult is simply waiting without timeout on a blocking queue:

public FindBugsResult getResult() {
   try {
       return findbugsResults.take();
   } catch (InterruptedException e) {
       throw UncheckedException.throwAsUncheckedException(e);
   }
}

Today, a bad acting dependency introduced findbugs 2 dependencies on the compile classpath when a project was expected to be tested against findbugs 3. This resulted in an ASM error which hung the build forever:

09:41:22.002 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
09:41:22.005 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: Gradle FindBugs Worker 1.
09:41:22.014 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTED
09:41:22.014 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process 'Gradle FindBugs Worker 1’
09:41:22.014 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] waiting until streams are handled…
09:41:22.429 [DEBUG] [system.out] 09:41:22.428 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Attempting to connect to [c9f614d4-5a0d-4592-b638-7215afd0295c port:51809, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]].
09:41:22.430 [DEBUG] [system.out] 09:41:22.429 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /0:0:0:0:0:0:0:1.
09:41:22.440 [DEBUG] [system.out] 09:41:22.440 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Connected to address /0:0:0:0:0:0:0:1:51809.
09:41:22.453 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpIncomingConnector] Accepted connection from /0:0:0:0:0:0:0:1:51810 to /0:0:0:0:0:0:0:1:51809.
09:41:22.460 [DEBUG] [system.out] 09:41:22.459 [DEBUG] [org.gradle.process.internal.child.ActionExecutionWorker] Starting Gradle FindBugs Worker 1.
09:41:22.461 [DEBUG] [system.out] 09:41:22.461 [DEBUG] [org.gradle.api.plugins.quality.internal.findbugs.FindBugsWorkerServer] Executing FindBugs worker.
09:41:22.471 [DEBUG] [org.gradle.process.internal.DefaultWorkerProcess] Received connection org.gradle.messaging.remote.internal.hub.MessageHubBackedObjectConnection@1c2b43af from Gradle FindBugs Worker 1
09:41:24.958 [DEBUG] [system.out] 09:41:24.958 [DEBUG] [org.gradle.process.internal.child.ActionExecutionWorker] Stopping client connection.
09:41:24.960 [DEBUG] [system.err] 09:41:24.959 [ERROR] [system.err] java.lang.NoClassDefFoundError: org/objectweb/asm/ClassAdapter
09:41:24.960 [DEBUG] [system.err] 09:41:24.960 [ERROR] [system.err] at java.lang.ClassLoader.defineClass1(Native Method)
09:41:24.960 [DEBUG] [system.err] 09:41:24.960 [ERROR] [system.err] at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
09:41:24.960 [DEBUG] [system.err] 09:41:24.960 [ERROR] [system.err] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
09:41:24.961 [DEBUG] [system.err] 09:41:24.961 [ERROR] [system.err] at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
09:41:24.961 [DEBUG] [system.err] 09:41:24.961 [ERROR] [system.err] at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
09:41:24.961 [DEBUG] [system.err] 09:41:24.961 [ERROR] [system.err] at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
09:41:24.962 [DEBUG] [system.err] 09:41:24.961 [ERROR] [system.err] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
09:41:24.962 [DEBUG] [system.err] 09:41:24.962 [ERROR] [system.err] at java.security.AccessController.doPrivileged(Native Method)
09:41:24.962 [DEBUG] [system.err] 09:41:24.962 [ERROR] [system.err] at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
09:41:24.962 [DEBUG] [system.err] 09:41:24.962 [ERROR] [system.err] at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
09:41:24.963 [DEBUG] [system.err] 09:41:24.962 [ERROR] [system.err] at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
09:41:24.963 [DEBUG] [system.err] 09:41:24.963 [ERROR] [system.err] at edu.umd.cs.findbugs.classfile.engine.asm.ClassReaderAnalysisEngine.analyze(ClassReaderAnalysisEngine.java:47)
09:41:24.963 [DEBUG] [system.err] 09:41:24.963 [ERROR] [system.err] at edu.umd.cs.findbugs.classfile.engine.asm.ClassReaderAnalysisEngine.analyze(ClassReaderAnalysisEngine.java:34)
09:41:24.963 [DEBUG] [system.err] 09:41:24.963 [ERROR] [system.err] at edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:266)
09:41:24.964 [DEBUG] [system.err] 09:41:24.964 [ERROR] [system.err] at edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:72)
09:41:24.964 [DEBUG] [system.err] 09:41:24.964 [ERROR] [system.err] at edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:38)
09:41:24.964 [DEBUG] [system.err] 09:41:24.964 [ERROR] [system.err] at edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:266)
09:41:24.964 [DEBUG] [system.err] 09:41:24.964 [ERROR] [system.err] at edu.umd.cs.findbugs.FindBugs2.buildReferencedClassSet(FindBugs2.java:875)
09:41:24.965 [DEBUG] [system.err] 09:41:24.965 [ERROR] [system.err] at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:221)
09:41:24.965 [DEBUG] [system.err] 09:41:24.965 [ERROR] [system.err] at org.gradle.api.plugins.quality.internal.findbugs.FindBugsExecuter.runFindbugs(FindBugsExecuter.java:44)
09:41:24.965 [DEBUG] [system.err] 09:41:24.965 [ERROR] [system.err] at org.gradle.api.plugins.quality.internal.findbugs.FindBugsWorkerServer.execute(FindBugsWorkerServer.java:45)
09:41:24.965 [DEBUG] [system.err] 09:41:24.965 [ERROR] [system.err] at org.gradle.api.plugins.quality.internal.findbugs.FindBugsWorkerServer.execute(FindBugsWorkerServer.java:35)
09:41:24.966 [DEBUG] [system.err] 09:41:24.966 [ERROR] [system.err] at org.gradle.api.plugins.quality.internal.findbugs.FindBugsWorkerServer.execute(FindBugsWorkerServer.java:26)
09:41:24.966 [DEBUG] [system.err] 09:41:24.966 [ERROR] [system.err] at org.gradle.process.internal.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:78)
09:41:24.966 [DEBUG] [system.err] 09:41:24.966 [ERROR] [system.err] at org.gradle.process.internal.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:35)
09:41:24.966 [DEBUG] [system.err] 09:41:24.966 [ERROR] [system.err] at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:85)
09:41:24.967 [DEBUG] [system.err] 09:41:24.967 [ERROR] [system.err] at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:41)
09:41:24.967 [DEBUG] [system.err] 09:41:24.967 [ERROR] [system.err] at org.gradle.process.internal.child.IsolatedApplicationClassLoaderWorker.call(IsolatedApplicationClassLoaderWorker.java:48)
09:41:24.967 [DEBUG] [system.err] 09:41:24.967 [ERROR] [system.err] at org.gradle.process.internal.child.IsolatedApplicationClassLoaderWorker.call(IsolatedApplicationClassLoaderWorker.java:30)
09:41:24.967 [DEBUG] [system.err] 09:41:24.967 [ERROR] [system.err] at org.gradle.process.internal.launcher.GradleWorkerMain.run(GradleWorkerMain.java:32)
09:41:24.968 [DEBUG] [system.err] 09:41:24.968 [ERROR] [system.err] at org.gradle.process.internal.launcher.GradleWorkerMain.main(GradleWorkerMain.java:37)
09:41:24.968 [DEBUG] [system.err] 09:41:24.968 [ERROR] [system.err] Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.ClassAdapter
09:41:24.969 [DEBUG] [system.err] 09:41:24.968 [ERROR] [system.err] at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
09:41:24.969 [DEBUG] [system.err] 09:41:24.968 [ERROR] [system.err] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
09:41:24.969 [DEBUG] [system.err] 09:41:24.969 [ERROR] [system.err] at java.security.AccessController.doPrivileged(Native Method)
09:41:24.969 [DEBUG] [system.err] 09:41:24.969 [ERROR] [system.err] at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
09:41:24.970 [DEBUG] [system.err] 09:41:24.969 [ERROR] [system.err] at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
09:41:24.970 [DEBUG] [system.err] 09:41:24.970 [ERROR] [system.err] at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
09:41:24.970 [DEBUG] [system.err] 09:41:24.970 [ERROR] [system.err] … 31 more
09:41:24.985 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
09:41:24.986 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process ‘Gradle FindBugs Worker 1’ finished with exit value 1 (state: FAILED)

Which causes Gradle to hang in thread main with:

“main” prio=5 tid=0x00007f80e187d000 nid=0x1303 waiting on condition [0x0000000105f4b000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000007add2bd90> (a java.util.concurrent.SynchronousQueue$TransferStack)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:458)
at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:359)
at java.util.concurrent.SynchronousQueue.take(SynchronousQueue.java:925)
at org.gradle.api.plugins.quality.internal.findbugs.FindBugsWorkerClient.getResult(FindBugsWorkerClient.java:38)
at org.gradle.api.plugins.quality.internal.findbugs.FindBugsWorkerClient$getResult.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at org.gradle.api.plugins.quality.internal.findbugs.FindBugsWorkerManager.runWorker(FindBugsWorkerManager.groovy:33)
at org.gradle.api.plugins.quality.internal.findbugs.FindBugsWorkerManager$runWorker.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at org.gradle.api.plugins.quality.FindBugs.run(FindBugs.groovy:220)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:579)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:562)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:55)