diff --git a/solace-spring-cloud-stream-binder/solace-spring-cloud-stream-binder-core/src/main/java/com/solace/spring/cloud/stream/binder/util/FlowReceiverContainer.java b/solace-spring-cloud-stream-binder/solace-spring-cloud-stream-binder-core/src/main/java/com/solace/spring/cloud/stream/binder/util/FlowReceiverContainer.java index f08c3a1b..ff9999b0 100644 --- a/solace-spring-cloud-stream-binder/solace-spring-cloud-stream-binder-core/src/main/java/com/solace/spring/cloud/stream/binder/util/FlowReceiverContainer.java +++ b/solace-spring-cloud-stream-binder/solace-spring-cloud-stream-binder-core/src/main/java/com/solace/spring/cloud/stream/binder/util/FlowReceiverContainer.java @@ -123,7 +123,10 @@ public void unbind() { LOGGER.info("Unbinding flow receiver container {}", id); flowReceiverReference.getStaleMessagesFlag().set(true); flowReceiverReference.get().close(); - Optional.ofNullable(flowReceiverReference.getTransactedSession()).ifPresent(TransactedSession::close); + TransactedSession transactedSession = flowReceiverReference.getTransactedSession(); + if (transactedSession != null) { + transactedSession.close(); + } } } finally { writeLock.unlock();