Skip to content

Commit f2fb175

Browse files
author
Frohwalt Egerer
committed
Try the SO_LINGER hack to prevent deadlock.
1 parent 3744a83 commit f2fb175

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/test/java/com/notnoop/apns/AbstractApnsServerSocket.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ private void startAccept() {
4848
try {
4949
while (true) {
5050
Socket accept = serverSocket.accept();
51-
executorService.execute(new SocketHandler(accept));
51+
// Work around JVM deadlock ... https://community.oracle.com/message/10989561#10989561
52+
accept.setSoLinger(true, 1);
53+
executorService.execute(new SocketHandler(accept));
5254
}
5355
} catch (IOException ioe) {
5456
executorService.shutdown();

src/test/java/com/notnoop/apns/utils/ApnsServerStub.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public void run() {
168168
startUp.release();
169169
while (true) {
170170
Socket socket = gatewaySocket.accept();
171+
// Work around JVM deadlock ... https://community.oracle.com/message/10989561#10989561
171172
socket.setSoLinger(true, 1);
172173

173174
// Create streams to securely send and receive data to the client
@@ -226,6 +227,7 @@ public void run() {
226227
// Listen for connections
227228
startUp.release();
228229
Socket socket = feedbackSocket.accept();
230+
// Work around JVM deadlock ... https://community.oracle.com/message/10989561#10989561
229231
socket.setSoLinger(true, 1);
230232

231233
// Create streams to securely send and receive data to the client

src/test/java/com/notnoop/apns/utils/Simulator/InputOutputSocket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public InputOutputSocket(final Socket socket) throws IOException {
1919

2020
this.socket = socket;
2121

22-
// Hack ... https://community.oracle.com/message/10989561#10989561
22+
// Hack, work arond JVM deadlock ... https://community.oracle.com/message/10989561#10989561
2323
socket.setSoLinger(true, 1);
2424
outputStream = new DataOutputStream(socket.getOutputStream());
2525
inputStream = new ApnsInputStream(socket.getInputStream());

0 commit comments

Comments
 (0)