[
https://issues.apache.org/jira/browse/PROTON-2697?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jiri Daněk updated PROTON-2697:
-------------------------------
Description:
I'm doing this
{code}
final Delivery delivery;
delivery = receiver.receive(timeout, TimeUnit.SECONDS);
{code}
The problem is that protonj2 does the unit transform before checking for the -1
magic value, so I end up passing -1000 and not -1 to it.
{code}
ClientDelivery delivery = deliveryQueue.dequeue(units.toMillis(timeout));
{code}
And I get exception.
{noformat}
java.lang.IllegalArgumentException: timeout value is negative
at java.base/java.lang.Object.wait(Native Method)
at
org.apache.qpid.protonj2.client.util.FifoDeliveryQueue.dequeue(FifoDeliveryQueue.java:90)
at
org.apache.qpid.protonj2.client.impl.ClientReceiver.receive(ClientReceiver.java:70)
at com.redhat.mqe.CliProtonJ2Receiver.call(CliProtonJ2Receiver.java:268)
{noformat}
I was following the doc comment for the Receiver.receive() method, which did
not provide me with a hint that the TimeUnit has to be
{{TimeUnit.MILLISECONDS}} for the magic value to work correctly.
{noformat}
/**
* Blocking receive method that waits the given time interval for the
remote to provide a
* {@link Delivery} for consumption. The amount of time this method blocks
is based on the
* timeout value. If timeout is equal to <code>-1</code> then it blocks
until a Delivery is
* received. If timeout is equal to zero then it will not block and simply
return a
* {@link Delivery} if one is available locally. If timeout value is
greater than zero then it
* blocks up to timeout amount of time.
[...]
{noformat}
I suggest either explaining in the docs that only -1 MILLISECONDS work this
way, or doing the -1 check before the TimeUnit is applied, so that -1 of any
TimeUnit works.
was:
I'm doing this
{code}
final Delivery delivery;
delivery = receiver.receive(timeout, TimeUnit.SECONDS);
{code}
The problem is that protonj2 later does this, so I end up passing -1000 and not
-1 to it.
{code}
ClientDelivery delivery = deliveryQueue.dequeue(units.toMillis(timeout));
{code}
And I get exception.
{noformat}
java.lang.IllegalArgumentException: timeout value is negative
at java.base/java.lang.Object.wait(Native Method)
at
org.apache.qpid.protonj2.client.util.FifoDeliveryQueue.dequeue(FifoDeliveryQueue.java:90)
at
org.apache.qpid.protonj2.client.impl.ClientReceiver.receive(ClientReceiver.java:70)
at com.redhat.mqe.CliProtonJ2Receiver.call(CliProtonJ2Receiver.java:268)
{noformat}
I was following the doc comment for the Receiver.receive() method, which did
not provide me with a hint that the TimeUnit has to be
{{TimeUnit.MILLISECONDS}} for the magic value to work correctly.
{noformat}
/**
* Blocking receive method that waits the given time interval for the
remote to provide a
* {@link Delivery} for consumption. The amount of time this method blocks
is based on the
* timeout value. If timeout is equal to <code>-1</code> then it blocks
until a Delivery is
* received. If timeout is equal to zero then it will not block and simply
return a
* {@link Delivery} if one is available locally. If timeout value is
greater than zero then it
* blocks up to timeout amount of time.
[...]
{noformat}
I suggest either explaining in the docs that only -1 MILLISECONDS work this
way, or doing the -1 check before the TimeUnit is applied, so that -1 of any
TimeUnit works.
> Receiver.receive() throws java.lang.IllegalArgumentException: timeout value
> is negative
> ---------------------------------------------------------------------------------------
>
> Key: PROTON-2697
> URL: https://issues.apache.org/jira/browse/PROTON-2697
> Project: Qpid Proton
> Issue Type: Bug
> Components: protonj2
> Affects Versions: protonj2-1.0.0-M12
> Reporter: Jiri Daněk
> Assignee: Timothy A. Bish
> Priority: Major
>
> I'm doing this
> {code}
> final Delivery delivery;
> delivery = receiver.receive(timeout, TimeUnit.SECONDS);
> {code}
> The problem is that protonj2 does the unit transform before checking for the
> -1 magic value, so I end up passing -1000 and not -1 to it.
> {code}
> ClientDelivery delivery = deliveryQueue.dequeue(units.toMillis(timeout));
> {code}
> And I get exception.
> {noformat}
> java.lang.IllegalArgumentException: timeout value is negative
> at java.base/java.lang.Object.wait(Native Method)
> at
> org.apache.qpid.protonj2.client.util.FifoDeliveryQueue.dequeue(FifoDeliveryQueue.java:90)
> at
> org.apache.qpid.protonj2.client.impl.ClientReceiver.receive(ClientReceiver.java:70)
> at com.redhat.mqe.CliProtonJ2Receiver.call(CliProtonJ2Receiver.java:268)
> {noformat}
> I was following the doc comment for the Receiver.receive() method, which did
> not provide me with a hint that the TimeUnit has to be
> {{TimeUnit.MILLISECONDS}} for the magic value to work correctly.
> {noformat}
> /**
> * Blocking receive method that waits the given time interval for the
> remote to provide a
> * {@link Delivery} for consumption. The amount of time this method
> blocks is based on the
> * timeout value. If timeout is equal to <code>-1</code> then it blocks
> until a Delivery is
> * received. If timeout is equal to zero then it will not block and
> simply return a
> * {@link Delivery} if one is available locally. If timeout value is
> greater than zero then it
> * blocks up to timeout amount of time.
> [...]
> {noformat}
> I suggest either explaining in the docs that only -1 MILLISECONDS work this
> way, or doing the -1 check before the TimeUnit is applied, so that -1 of any
> TimeUnit works.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]