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 a041637c..cd8bff06 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 @@ -157,42 +157,23 @@ public MessageContainer receive() throws JCSMPException, UnboundFlowReceiverCont * @see FlowReceiver#receive(int) */ public MessageContainer receive(Integer timeoutInMillis) throws JCSMPException, UnboundFlowReceiverContainerException { - final Long expiry = timeoutInMillis != null ? timeoutInMillis + System.currentTimeMillis() : null; - - Integer realTimeout; FlowReceiverReference flowReceiverReference = flowReceiverAtomicReference.get(); if (flowReceiverReference == null) { throw new UnboundFlowReceiverContainerException( String.format("Flow receiver container %s is not bound", id)); } - if (expiry != null) { - try { - realTimeout = Math.toIntExact(expiry - System.currentTimeMillis()); - if (realTimeout < 0) { - realTimeout = 0; - } - } catch (ArithmeticException e) { - LOGGER.debug("Failed to compute real timeout", e); - // Always true: expiry - System.currentTimeMillis() < timeoutInMillis - // So just set it to 0 (no-wait) if we underflow - realTimeout = 0; - } - } else { - realTimeout = null; - } - // The flow's receive shouldn't be locked behind the read lock. // This lets it be interrupt-able if the flow were to be shutdown mid-receive. BytesXMLMessage xmlMessage; - if (realTimeout == null) { + if (timeoutInMillis == null) { xmlMessage = flowReceiverReference.get().receive(); - } else if (realTimeout == 0) { + } else if (timeoutInMillis == 0) { xmlMessage = flowReceiverReference.get().receiveNoWait(); } else { - // realTimeout > 0: Wait until timeout - // realTimeout < 0: Equivalent to receiveNoWait() - xmlMessage = flowReceiverReference.get().receive(realTimeout); + // timeoutInMillis > 0: Wait until timeout + // timeoutInMillis < 0: Equivalent to receiveNoWait() + xmlMessage = flowReceiverReference.get().receive(timeoutInMillis); } if (xmlMessage == null) {