-
Notifications
You must be signed in to change notification settings - Fork 75
Description
Describe the problem
In the hid4java wiki, there are recommendations to run the test/example programs using Maven commands of the form:
mvn clean test exec:java -Dexec.classpathScope="test" -Dexec.mainClass="org.hid4java.examples.UsbHidEnumerationExample"
I am running on an Intel machine with Ubuntu 24.04.2 LTS installed, when run any of the examples I find that the shutdown is delayed, and only completes after warnings and exceptions are logged (see log messages below).
You may find that this issue has arisen before, so here is a checklist of useful links to provide assistance and potentially avoid duplicate issues:
- I have read the Troubleshooting Guide and this is not covered
- I have done a quick search of previous issues and this needs addressing
Please provide a clear and concise description of what the problem is below:
Platform
Knowing the platform greatly narrows down the potential causes of the problem.
- Platform:
linux-x86-64 - OS version
Ubuntu 22.04.2 LTS hid4javaversions:0.8.0,developmvn --versionoutput:
Apache Maven 3.8.7
Maven home: /usr/share/maven
Java version: 17.0.14, vendor: Ubuntu, runtime: /usr/lib/jvm/java-17-openjdk-amd64
Default locale: en_AU, platform encoding: UTF-8
OS name: "linux", version: "6.8.0-53-lowlatency", arch: "amd64", family: "unix"
To Reproduce
Steps to reproduce the behavior:
sudo mvn clean test exec:java -Dexec.classpathScope="test" -Dexec.mainClass="org.hid4java.examples.UsbHidEnumerationExample"
NB sudo is required on my environment because I am choosing not to put udev rules in place before the application I am working on has reached the stage of needing an installer.
Expected behavior
On completion of the enumerated device report, the following two lines should appear, 30 seconds apart.
Waiting 30s to demonstrate attach/detach handling. Watch for slow response after write if configured.
Triggering shutdown...
The program should exit immediately after the second line appears.
Actual behaviour
The following two lines appear:
Waiting 30s to demonstrate attach/detach handling. Watch for slow response after write if configured.
Triggering shutdown...
but the program does not exit for some time (probably 15 seconds, haven't measured it).
Before the program does exit it prints the following lines:
[WARNING] thread Thread[hid4java event worker,5,org.hid4java.examples.UsbHidEnumerationExample] was interrupted but is still alive after waiting at least 15000msecs
[WARNING] thread Thread[hid4java event worker,5,org.hid4java.examples.UsbHidEnumerationExample] will linger despite being asked to die via interruption
[WARNING] thread Thread[hid4java event worker,5,org.hid4java.examples.UsbHidEnumerationExample] will linger despite being asked to die via interruption
[WARNING] thread Thread[hid4java event worker,5,org.hid4java.examples.UsbHidEnumerationExample] will linger despite being asked to die via interruption
[WARNING] NOTE: 3 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=org.hid4java.examples.UsbHidEnumerationExample,maxpri=10]
java.lang.IllegalThreadStateException
at java.lang.ThreadGroup.destroy (ThreadGroup.java:803)
at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:330)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:298)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:569)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
Additional information
I believe that this behaviour may be the result of a problem with Maven, described in this StackOverflow response:
https://stackoverflow.com/a/77783869
I have a local copy of a linux-specific shell script to invoke the tests without using mvn as a wrapper. With this script the problem does not occur.
I am happy to do a pull request with this tomorrow if it would be welcome.