Skip to content

Commit a50a49d

Browse files
Update SQSConnection to avoid race condition
Fixing a potential bug: SQSSessionCallbackScheduler left threads in waiting state infinitely. Update Pom
1 parent 2875e62 commit a50a49d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.amazonaws</groupId>
88
<artifactId>amazon-sqs-java-messaging-lib</artifactId>
9-
<version>1.0.8</version>
9+
<version>1.0.9</version>
1010
<packaging>jar</packaging>
1111
<name>Amazon SQS Java Messaging Library</name>
1212
<description>The Amazon SQS Java Messaging Library holds the Java Message Service compatible classes, that are used

src/main/java/com/amazon/sqs/javamessaging/SQSConnection.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,14 @@ public Session createSession(boolean transacted, int acknowledgeMode) throws JMS
197197
throw new JMSException("Unrecognized acknowledgeMode. Cannot create Session.");
198198
}
199199
synchronized (stateLock) {
200-
checkClosing();
200+
if (closing) {
201+
/**
202+
* SQSSession's constructor has already started a SQSSessionCallbackScheduler which should be closed
203+
* before leaving sqsSession object.
204+
*/
205+
sqsSession.close();
206+
throw new IllegalStateException("Connection is closed or closing");
207+
}
201208
sessions.add(sqsSession);
202209

203210
/**

0 commit comments

Comments
 (0)