You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My application uses thread interruption to signal that work should be aborted. When a thread is interrupted before making a call to anything that tries to publish a message to a NATS Connection, the call to publish throws an IllegalMonitorStateException.
Here's an example exception stack from a call to KeyValue.create().
java.lang.IllegalMonitorStateException(null)
java.lang.IllegalMonitorStateException
at java.base/java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:175)
at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1007)
at java.base/java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:494)
at io.nats.client.impl.MessageQueue.push(MessageQueue.java:187)
at io.nats.client.impl.MessageQueue.push(MessageQueue.java:139)
at io.nats.client.impl.NatsConnectionWriter.queue(NatsConnectionWriter.java:233)
at io.nats.client.impl.NatsConnection.queueOutgoing(NatsConnection.java:1678)
at io.nats.client.impl.NatsConnection.publishInternal(NatsConnection.java:990)
at io.nats.client.impl.NatsConnection.requestFutureInternal(NatsConnection.java:1339)
at io.nats.client.impl.NatsConnection.requestInternal(NatsConnection.java:1229)
at io.nats.client.impl.NatsJetStreamImpl.makeInternalRequestResponseRequired(NatsJetStreamImpl.java:242)
at io.nats.client.impl.NatsJetStream.publishSyncInternal(NatsJetStream.java:155)
at io.nats.client.impl.NatsJetStream.publish(NatsJetStream.java:83)
at io.nats.client.impl.NatsKeyValue._write(NatsKeyValue.java:238)
at io.nats.client.impl.NatsKeyValue.update(NatsKeyValue.java:189)
at io.nats.client.impl.NatsKeyValue.create(NatsKeyValue.java:168)
Expected behavior
Calls to NATS should either:
(Strongly Preferred) Store the message into queueOutgoing and return successfully. Make no fuss about the calling thread being interrupted.
Propagate a different exception out and restore the thread's interrupted flag.
Propagate an InterruptedException out
Server and client version
Nats Server: 2.10.20
Nats Java client: 2.20.2
Host environment
Amazon Linux 2 within docker on c5a.2xlarge EC2 instance. Container limited to 2GiB RAM and 3vCPU.
davidmcote
changed the title
Intermittent java.lang.IllegalMonitorStateException during NatsJetStream.publish()
java.lang.IllegalMonitorStateException if thread is interrupted during NatsConnection.publish()
Nov 7, 2024
Observed behavior
My application uses thread interruption to signal that work should be aborted. When a thread is interrupted before making a call to anything that tries to publish a message to a NATS Connection, the call to publish throws an IllegalMonitorStateException.
Here's an example exception stack from a call to
KeyValue.create()
.Expected behavior
Calls to NATS should either:
Server and client version
Nats Server: 2.10.20
Nats Java client: 2.20.2
Host environment
Amazon Linux 2 within docker on c5a.2xlarge EC2 instance. Container limited to 2GiB RAM and 3vCPU.
Steps to reproduce
The text was updated successfully, but these errors were encountered: