-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from bugsnag/release-v3.6.2
Release v3.6.2
- Loading branch information
Showing
9 changed files
with
87 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
bugsnag/src/main/java/com/bugsnag/util/DaemonThreadFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.bugsnag.util; | ||
|
||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.ThreadFactory; | ||
|
||
/** | ||
* Wraps {@link Executors#defaultThreadFactory()} to return daemon threads | ||
* This is to prevent applications from hanging waiting for the sessions scheduled task | ||
* because daemon threads will be terminated on application shutdown | ||
*/ | ||
public class DaemonThreadFactory implements ThreadFactory { | ||
private final ThreadFactory defaultThreadFactory; | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public DaemonThreadFactory() { | ||
defaultThreadFactory = Executors.defaultThreadFactory(); | ||
} | ||
|
||
@Override | ||
public Thread newThread(Runnable runner) { | ||
Thread daemonThread = defaultThreadFactory.newThread(runner); | ||
daemonThread.setName("bugsnag-daemon-" + daemonThread.getId()); | ||
|
||
// Set the threads to daemon to allow the app to shutdown properly | ||
if (!daemonThread.isDaemon()) { | ||
daemonThread.setDaemon(true); | ||
} | ||
return daemonThread; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
bugsnag/src/test/java/com/bugsnag/DaemonThreadFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.bugsnag; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import com.bugsnag.util.DaemonThreadFactory; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
|
||
/** | ||
* Tests for the Daemon thread factory internal logic | ||
*/ | ||
public class DaemonThreadFactoryTest { | ||
|
||
private DaemonThreadFactory daemonThreadFactory; | ||
|
||
/** | ||
* Create the daemonThreadFactory before the tests | ||
*/ | ||
@Before | ||
public void createFactory() { | ||
daemonThreadFactory = new DaemonThreadFactory(); | ||
} | ||
|
||
@Test | ||
public void testDaemonThreadFactory() { | ||
Thread testThread = daemonThreadFactory.newThread(null); | ||
|
||
// Check that the thread is as expected | ||
assertTrue(testThread.isDaemon()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version=3.6.1 | ||
version=3.6.2 | ||
group=com.bugsnag | ||
|
||
# Default properties | ||
|