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

Set to crated threads property daemon #8

Closed
dmytrokarimov opened this issue Feb 19, 2015 · 2 comments
Closed

Set to crated threads property daemon #8

dmytrokarimov opened this issue Feb 19, 2015 · 2 comments
Labels

Comments

@dmytrokarimov
Copy link

Set to create threads property 'daemon'
Without it program can't terminated normally

@dmytrokarimov
Copy link
Author

diff --git a/src/main/java/org/graylog2/gelfclient/transport/AbstractGelfTransport.java b/src/main/java/org/graylog2/gelfclient/transport/AbstractGelfTransport.java
index b377099..f0d5be4 100644
--- a/src/main/java/org/graylog2/gelfclient/transport/AbstractGelfTransport.java
+++ b/src/main/java/org/graylog2/gelfclient/transport/AbstractGelfTransport.java
@@ -18,14 +18,16 @@

 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.nio.NioEventLoopGroup;
-import org.graylog2.gelfclient.GelfConfiguration;
-import org.graylog2.gelfclient.GelfMessage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import io.netty.util.concurrent.DefaultThreadFactory;

 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
+
+import org.graylog2.gelfclient.GelfConfiguration;
+import org.graylog2.gelfclient.GelfMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;

 /**
  * An abstract {@link GelfTransport} implementation serving as parent for the concrete implementations.
@@ -37,7 +39,7 @@
     protected final GelfConfiguration config;
     protected final BlockingQueue<GelfMessage> queue;

-    private final EventLoopGroup workerGroup = new NioEventLoopGroup();
+    private final EventLoopGroup workerGroup = new NioEventLoopGroup(0, new DefaultThreadFactory(getClass(), true));

     /**
      * Creates a new GELF transport with the given configuration and {@link java.util.concurrent.BlockingQueue}.
diff --git a/src/main/java/org/graylog2/gelfclient/transport/GelfSenderThread.java b/src/main/java/org/graylog2/gelfclient/transport/GelfSenderThread.java
index ae079de..709d80f 100644
--- a/src/main/java/org/graylog2/gelfclient/transport/GelfSenderThread.java
+++ b/src/main/java/org/graylog2/gelfclient/transport/GelfSenderThread.java
@@ -17,15 +17,16 @@
 package org.graylog2.gelfclient.transport;

 import io.netty.channel.Channel;
-import org.graylog2.gelfclient.GelfMessage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;

 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.ReentrantLock;
+
+import org.graylog2.gelfclient.GelfMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;

 /**
  * The main event thread used by the {@link org.graylog2.gelfclient.transport.GelfTransport}s.
@@ -92,7 +93,9 @@
                 LOG.debug("GelfSenderThread exiting!");
             }
         });
-
+        
+        this.senderThread.setDaemon(true);
+        
         this.senderThread.setName("GelfSenderThread-" + senderThread.getId());
     }

@bernd
Copy link
Member

bernd commented Jun 19, 2015

Thanks, I will test this.

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

No branches or pull requests

2 participants