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 11 console app hangs if event in flight #1138

Closed
bruno-garcia opened this issue Dec 24, 2020 · 4 comments
Closed

Java 11 console app hangs if event in flight #1138

bruno-garcia opened this issue Dec 24, 2020 · 4 comments

Comments

@bruno-garcia
Copy link
Member

Running a Java 11 console app, init and capture 1 event just hangs:

package io.benchmark;

import io.sentry.Sentry;

public class App 
{
    public static void main(String[] args) throws Exception
    {
        Sentry.init(o -> {
            o.setDsn("http://key@localhost:5000/1");
        });

        Sentry.captureMessage("hi");
    }
}

If I init but don't capture, it exists quickly. If I capture message, over 10 seconds hanging, then spits out some warnings and errors:

Output ``` ➜ java git:(main) ✗ mvn compile exec:java

[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< io.benchmark:App >--------------------------
[INFO] Building benchmark 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ App ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/bruno/git/sdk-transport-throughput/java/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ App ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- exec-maven-plugin:3.0.0:java (default-cli) @ App ---
[WARNING] thread Thread[SentryAsyncConnection-0,5,io.benchmark.App] was interrupted but is still alive after waiting at least 15000msecs
[WARNING] thread Thread[SentryAsyncConnection-0,5,io.benchmark.App] 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=io.benchmark.App,maxpri=10]
java.lang.IllegalThreadStateException: Has threads
at java.lang.ThreadGroup.destroyImpl (ThreadGroup.java:274)
at java.lang.ThreadGroup.destroy (ThreadGroup.java:256)
at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:293)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
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:305)
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:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.699 s
[INFO] Finished at: 2020-12-23T22:37:20-05:00
[INFO] ------------------------------------------------------------------------
➜ java git:(main) ✗

</details>

@bruno-garcia bruno-garcia added the Type: Bug Something isn't working label Dec 24, 2020
@maciejwalkowiak
Copy link
Contributor

I am not able to reproduce it using Maven 3.6.3 with AdoptOpenJDK Java 11.0.9 HotSpot and AdoptOpenJDK Java 11.0.9 J9. Could you please specify exactly which Java version do you use? Are you able to reproduce it each time you run the code?

@bruno-garcia
Copy link
Member Author

Yeah it was repro on each run. If I removed capture it would exit immediately.
Not sure what was wrong, I believe I was on JDK 11.

If you can't repro lets leave it, next time I get to this sample I'll try again and update this issue.

@bruno-garcia bruno-garcia removed the Type: Bug Something isn't working label Dec 29, 2020
@maciejwalkowiak
Copy link
Contributor

I think I've found an issue. It's due to the nature of Maven exec plugin. Add <cleanupDaemonThreads>false</cleanupDaemonThreads> to the configuration and problem should be gone. We use the same property in getsentry/examples project.

@bruno-garcia
Copy link
Member Author

Thanks @maciejwalkowiak !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants