如何修复maven在使用GCSUtil写入文件时关于线程组仍在运行的警告?
我编写了一个简单的程序,使用 我使用mvn:exec运行程序如何修复maven在使用GCSUtil写入文件时关于线程组仍在运行的警告?,maven,google-cloud-dataflow,Maven,Google Cloud Dataflow,我编写了一个简单的程序,使用 我使用mvn:exec运行程序 mvn exec:java -Dexec.mainClass="dataflow.GCSRunningThreads" -Dexec.args=--output=gs://my-bucket/tmp/hello_world Maven退出时出现以下错误 [WARNING] thread Thread[pool-1-thread-1,5,dataflow.GCSRunningThreads] was interrupted but i
mvn exec:java -Dexec.mainClass="dataflow.GCSRunningThreads" -Dexec.args=--output=gs://my-bucket/tmp/hello_world
Maven退出时出现以下错误
[WARNING] thread Thread[pool-1-thread-1,5,dataflow.GCSRunningThreads] was interrupted but is still alive after waiting at least 15000msecs
[WARNING] thread Thread[pool-1-thread-1,5,dataflow.GCSRunningThreads] will linger despite being asked to die via interruption
[WARNING] NOTE: 1 thread(s) did not finish despite being asked to via interruption. This is not a problem with exec:java, it is a problem with the running code. Although not serious, it should be remedied.
[WARNING] Couldn't destroy threadgroup org.codehaus.mojo.exec.ExecJavaMojo$IsolatedThreadGroup[name=dataflow.GCSRunningThreads,maxpri=10]
java.lang.IllegalThreadStateException
at java.lang.ThreadGroup.destroy(ThreadGroup.java:775)
at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:328)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] ------------------------------------------------------------------------
如何修复此问题?要修复此问题,您需要关闭GcsUtil使用的Executor服务。以下代码段有效:
GcsOptions gcsOptions = options.as(GcsOptions.class);
gcsOptions.getExecutorService().shutdown();
try {
gcsOptions.getExecutorService().awaitTermination(3, TimeUnit.MINUTES);
} catch (InterruptedException e) {
sLogger.error("Thread was interrupted waiting for execution service to shutdown.");
}
GCSUtil使用executor服务异步处理IO操作。我们需要关闭该executor服务才能干净地退出。您是否尝试在pom中设置下面的属性(或通过命令行传递它) 看看这个问题,,
这可能通过设置属性
-Dexec.cleanupDaemonThreads=false来解决。
cleanupDaemonThreads = false