This is an automated email from the ASF dual-hosted git repository. tabish pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git
The following commit(s) were added to refs/heads/main by this push: new 49814c9 PROTON-2420 Fixes for some additional warnings from errorprone 49814c9 is described below commit 49814c9ba6e56e9cb36b6317902b06d4b733a28d Author: Timothy Bish <tabish...@gmail.com> AuthorDate: Mon Aug 30 14:54:27 2021 -0400 PROTON-2420 Fixes for some additional warnings from errorprone Adds some fixes and cleanups to reduce errorprone warnings. --- .../qpid/protonj2/client/ConnectionOptions.java | 9 +- .../qpid/protonj2/client/ReconnectLocation.java | 148 ++++++++++----------- .../client/futures/BalancedClientFuture.java | 2 - .../client/futures/ConservativeClientFuture.java | 2 - .../qpid/protonj2/client/impl/ClientReceiver.java | 2 +- .../client/impl/ClientReceiverBuilder.java | 4 +- .../protonj2/client/impl/ClientSenderBuilder.java | 4 +- .../protonj2/client/impl/ClientSessionBuilder.java | 2 +- .../protonj2/client/impl/ClientStreamReceiver.java | 2 +- .../protonj2/client/util/FifoDeliveryQueue.java | 14 +- .../qpid/protonj2/client/util/ExternalMessage.java | 6 +- .../protonj2/buffer/ProtonNettyByteBuffer.java | 10 +- .../codec/decoders/ProtonStreamDecoder.java | 14 +- .../protonj2/engine/impl/ProtonConnection.java | 1 + .../engine/impl/ProtonFrameDecodingHandler.java | 2 +- .../engine/impl/ProtonTransactionController.java | 2 +- .../protonj2/types/transactions/Coordinator.java | 2 +- .../apache/qpid/protonj2/types/transport/Open.java | 12 +- .../engine/impl/ProtonOutgoingDeliveryTest.java | 3 +- 19 files changed, 122 insertions(+), 119 deletions(-) diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/ConnectionOptions.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/ConnectionOptions.java index d0170a6..a08105f 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/ConnectionOptions.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/ConnectionOptions.java @@ -17,7 +17,9 @@ package org.apache.qpid.protonj2.client; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; @@ -34,7 +36,10 @@ public class ConnectionOptions { /** * Default value for the AMQP desired capabilities set in the Open frame. */ - public static final String[] DEFAULT_DESIRED_CAPABILITIES = new String[] { "ANONYMOUS-RELAY" }; + private static final String[] DEFAULT_DESIRED_CAPABILITIES_ARRAY = new String[] { "ANONYMOUS-RELAY" }; + + public static final List<String> DEFAULT_DESIRED_CAPABILITIES = + Collections.unmodifiableList(Arrays.asList( DEFAULT_DESIRED_CAPABILITIES_ARRAY )); public static final long INFINITE = -1; public static final long DEFAULT_OPEN_TIMEOUT = 15000; @@ -63,7 +68,7 @@ public class ConnectionOptions { private int channelMax = DEFAULT_CHANNEL_MAX; private int maxFrameSize = DEFAULT_MAX_FRAME_SIZE; private String[] offeredCapabilities; - private String[] desiredCapabilities = DEFAULT_DESIRED_CAPABILITIES; + private String[] desiredCapabilities = DEFAULT_DESIRED_CAPABILITIES_ARRAY; private Map<String, Object> properties; private String virtualHost; private boolean traceFrames; diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/ReconnectLocation.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/ReconnectLocation.java index e876523..2effa67 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/ReconnectLocation.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/ReconnectLocation.java @@ -26,78 +26,78 @@ import java.util.Objects; */ public class ReconnectLocation { - private final String host; - private final int port; - - /** - * Creates a new {@link ReconnectLocation} instance with the fixed host and port values. - * - * @param host - * The remote host where the connection will be made - * @param port - * The port on the remote where the connection attempt will be made. - */ - public ReconnectLocation(String host, int port) { - Objects.requireNonNull(host, "Cannot create a reconnect entry with a null host value"); - - if (host.isBlank()) { - throw new IllegalArgumentException("Cannot create a reconnect entry with a blank host value"); - } - - this.host = host; - this.port = port; - } - - /** - * @return the host where the reconnect should attempt its reconnection. - */ - public String getHost() { - return host; - } - - /** - * @return the port where the reconnect should attempt its connection. - */ - public int getPort() { - return port; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((host == null) ? 0 : host.hashCode()); - result = prime * result + port; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj == null) { - return false; - } - - if (getClass() != obj.getClass()) { - return false; - } - - ReconnectLocation other = (ReconnectLocation) obj; - if (host == null) { - if (other.host != null) { - return false; - } - } else if (!host.equalsIgnoreCase(other.host)) { - return false; - } - - if (port != other.port) { - return false; - } - - return true; - } + private final String host; + private final int port; + + /** + * Creates a new {@link ReconnectLocation} instance with the fixed host and port values. + * + * @param host + * The remote host where the connection will be made + * @param port + * The port on the remote where the connection attempt will be made. + */ + public ReconnectLocation(String host, int port) { + Objects.requireNonNull(host, "Cannot create a reconnect entry with a null host value"); + + if (host.isBlank()) { + throw new IllegalArgumentException("Cannot create a reconnect entry with a blank host value"); + } + + this.host = host; + this.port = port; + } + + /** + * @return the host where the reconnect should attempt its reconnection. + */ + public String getHost() { + return host; + } + + /** + * @return the port where the reconnect should attempt its connection. + */ + public int getPort() { + return port; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((host == null) ? 0 : host.hashCode()); + result = prime * result + port; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj == null) { + return false; + } + + if (!(obj instanceof ReconnectLocation)) { + return false; + } + + ReconnectLocation other = (ReconnectLocation) obj; + if (host == null) { + if (other.host != null) { + return false; + } + } else if (!host.equalsIgnoreCase(other.host)) { + return false; + } + + if (port != other.port) { + return false; + } + + return true; + } } diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/futures/BalancedClientFuture.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/futures/BalancedClientFuture.java index c6f8185..7328649 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/futures/BalancedClientFuture.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/futures/BalancedClientFuture.java @@ -55,8 +55,6 @@ public class BalancedClientFuture<V> extends ClientFuture<V> { public V get(long amount, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { if (isNotComplete() && amount > 0) { final long timeout = unit.toNanos(amount); - long maxParkNanos = timeout / 8; - maxParkNanos = maxParkNanos > 0 ? maxParkNanos : timeout; final long startTime = System.nanoTime(); int idleCount = 0; diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/futures/ConservativeClientFuture.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/futures/ConservativeClientFuture.java index 8c9def8..3758ce4 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/futures/ConservativeClientFuture.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/futures/ConservativeClientFuture.java @@ -51,8 +51,6 @@ public class ConservativeClientFuture<V> extends ClientFuture<V> { public V get(long amount, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { if (isNotComplete() && amount > 0) { final long timeout = unit.toNanos(amount); - long maxParkNanos = timeout / 8; - maxParkNanos = maxParkNanos > 0 ? maxParkNanos : timeout; final long startTime = System.nanoTime(); while (isNotComplete()) { diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientReceiver.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientReceiver.java index 21a057a..480e6dc 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientReceiver.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientReceiver.java @@ -617,7 +617,7 @@ public final class ClientReceiver implements Receiver { } } - protected void checkClosedOrFailed() throws ClientException { + private void checkClosedOrFailed() throws ClientException { if (isClosed()) { throw new ClientIllegalStateException("The Receiver was explicitly closed", failureCause); } else if (failureCause != null) { diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientReceiverBuilder.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientReceiverBuilder.java index c563046..a191fcd 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientReceiverBuilder.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientReceiverBuilder.java @@ -46,8 +46,8 @@ final class ClientReceiverBuilder { private final SessionOptions sessionOptions; private final AtomicInteger receiverCounter = new AtomicInteger(); - private ReceiverOptions defaultReceiverOptions; - private StreamReceiverOptions defaultStreamReceiverOptions; + private volatile ReceiverOptions defaultReceiverOptions; + private volatile StreamReceiverOptions defaultStreamReceiverOptions; ClientReceiverBuilder(ClientSession session) { this.session = session; diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientSenderBuilder.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientSenderBuilder.java index 494c0b6..8fe6e94 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientSenderBuilder.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientSenderBuilder.java @@ -46,8 +46,8 @@ final class ClientSenderBuilder { private final SessionOptions sessionOptions; private final AtomicInteger senderCounter = new AtomicInteger(); - private SenderOptions defaultSenderOptions; - private StreamSenderOptions defaultStreamSenderOptions; + private volatile SenderOptions defaultSenderOptions; + private volatile StreamSenderOptions defaultStreamSenderOptions; ClientSenderBuilder(ClientSession session) { this.session = session; diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientSessionBuilder.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientSessionBuilder.java index 1660a2e..23f3a3d 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientSessionBuilder.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientSessionBuilder.java @@ -30,7 +30,7 @@ final class ClientSessionBuilder { private final ClientConnection connection; private final ConnectionOptions connectionOptions; - private SessionOptions defaultSessionOptions; + private volatile SessionOptions defaultSessionOptions; ClientSessionBuilder(ClientConnection connection) { this.connection = connection; diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientStreamReceiver.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientStreamReceiver.java index f8b685e..3e51e19 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientStreamReceiver.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientStreamReceiver.java @@ -643,7 +643,7 @@ public final class ClientStreamReceiver implements StreamReceiver { } } - protected void checkClosedOrFailed() throws ClientException { + private void checkClosedOrFailed() throws ClientException { if (isClosed()) { throw new ClientIllegalStateException("The Receiver was explicitly closed", failureCause); } else if (failureCause != null) { diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/util/FifoDeliveryQueue.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/util/FifoDeliveryQueue.java index 0404b53..634b1ec 100644 --- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/util/FifoDeliveryQueue.java +++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/util/FifoDeliveryQueue.java @@ -31,19 +31,19 @@ import org.apache.qpid.protonj2.client.impl.ClientDelivery; */ public final class FifoDeliveryQueue implements DeliveryQueue { - protected static final AtomicIntegerFieldUpdater<FifoDeliveryQueue> STATE_FIELD_UPDATER = + private static final AtomicIntegerFieldUpdater<FifoDeliveryQueue> STATE_FIELD_UPDATER = AtomicIntegerFieldUpdater.newUpdater(FifoDeliveryQueue.class, "state"); - protected static final int CLOSED = 0; - protected static final int STOPPED = 1; - protected static final int RUNNING = 2; + private static final int CLOSED = 0; + private static final int STOPPED = 1; + private static final int RUNNING = 2; private volatile int state = STOPPED; - protected final ReentrantLock lock = new ReentrantLock(); - protected final Condition condition = lock.newCondition(); + private final ReentrantLock lock = new ReentrantLock(); + private final Condition condition = lock.newCondition(); - protected final Deque<ClientDelivery> queue; + private final Deque<ClientDelivery> queue; /** * Creates a new first in / first out message queue with the given queue depth diff --git a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/util/ExternalMessage.java b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/util/ExternalMessage.java index 61d12b1..0053e5c 100644 --- a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/util/ExternalMessage.java +++ b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/util/ExternalMessage.java @@ -238,7 +238,7 @@ public class ExternalMessage<E> implements Message<E> { @Override public long absoluteExpiryTime() { - return properties != null ? properties.getAbsoluteExpiryTime() : null; + return properties != null ? properties.getAbsoluteExpiryTime() : 0; } @Override @@ -249,7 +249,7 @@ public class ExternalMessage<E> implements Message<E> { @Override public long creationTime() { - return properties != null ? properties.getCreationTime() : null; + return properties != null ? properties.getCreationTime() : 0; } @Override @@ -271,7 +271,7 @@ public class ExternalMessage<E> implements Message<E> { @Override public int groupSequence() { - return properties != null ? (int) properties.getGroupSequence() : null; + return properties != null ? (int) properties.getGroupSequence() : 0; } @Override diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/buffer/ProtonNettyByteBuffer.java b/protonj2/src/main/java/org/apache/qpid/protonj2/buffer/ProtonNettyByteBuffer.java index ff77b48..92a6c4e 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/buffer/ProtonNettyByteBuffer.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/buffer/ProtonNettyByteBuffer.java @@ -667,7 +667,7 @@ public final class ProtonNettyByteBuffer implements ProtonBuffer { //----- Internal Bounds Checking Utilities - protected final void checkReadableBytes(int minimumReadableBytes) { + private final void checkReadableBytes(int minimumReadableBytes) { if (minimumReadableBytes < 0) { throw new IllegalArgumentException("minimumReadableBytes: " + minimumReadableBytes + " (expected: >= 0)"); } @@ -685,18 +685,18 @@ public final class ProtonNettyByteBuffer implements ProtonBuffer { } } - protected static boolean isOutOfBounds(int index, int length, int capacity) { + private static boolean isOutOfBounds(int index, int length, int capacity) { return (index | length | (index + length) | (capacity - (index + length))) < 0; } - protected final void checkIndex(int index, int fieldLength) { + private final void checkIndex(int index, int fieldLength) { if (isOutOfBounds(index, fieldLength, capacity())) { throw new IndexOutOfBoundsException(String.format( "index: %d, length: %d (expected: range(0, %d))", index, fieldLength, capacity())); } } - protected final void checkSourceIndex(int index, int length, int srcIndex, int srcCapacity) { + private final void checkSourceIndex(int index, int length, int srcIndex, int srcCapacity) { checkIndex(index, length); if (isOutOfBounds(srcIndex, length, srcCapacity)) { throw new IndexOutOfBoundsException(String.format( @@ -704,7 +704,7 @@ public final class ProtonNettyByteBuffer implements ProtonBuffer { } } - protected final void checkDestinationIndex(int index, int length, int dstIndex, int dstCapacity) { + private final void checkDestinationIndex(int index, int length, int dstIndex, int dstCapacity) { checkIndex(index, length); if (isOutOfBounds(dstIndex, length, dstCapacity)) { throw new IndexOutOfBoundsException(String.format( diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/ProtonStreamDecoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/ProtonStreamDecoder.java index ba1e4ce..32b26ed 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/ProtonStreamDecoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/ProtonStreamDecoder.java @@ -280,12 +280,12 @@ public final class ProtonStreamDecoder implements StreamDecoder { throw new DecodeException("Expected Descriptor type but found encoding: " + EncodingCodes.toString(encodingCode)); } - StreamTypeDecoder<?> StreamTypeDecoder = describedTypeDecoders.get(descriptor); - if (StreamTypeDecoder == null) { - StreamTypeDecoder = handleUnknownDescribedType(descriptor); + StreamTypeDecoder<?> streamTypeDecoder = describedTypeDecoders.get(descriptor); + if (streamTypeDecoder == null) { + streamTypeDecoder = handleUnknownDescribedType(descriptor); } - return StreamTypeDecoder; + return streamTypeDecoder; } @Override @@ -943,7 +943,7 @@ public final class ProtonStreamDecoder implements StreamDecoder { } private StreamTypeDecoder<?> handleUnknownDescribedType(final Object descriptor) { - StreamTypeDecoder<?> StreamTypeDecoder = new UnknownDescribedTypeDecoder() { + StreamTypeDecoder<?> streamTypeDecoder = new UnknownDescribedTypeDecoder() { @Override public Object getDescriptor() { @@ -951,8 +951,8 @@ public final class ProtonStreamDecoder implements StreamDecoder { } }; - describedTypeDecoders.put(descriptor, (UnknownDescribedTypeDecoder) StreamTypeDecoder); + describedTypeDecoders.put(descriptor, (UnknownDescribedTypeDecoder) streamTypeDecoder); - return StreamTypeDecoder; + return streamTypeDecoder; } } diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonConnection.java b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonConnection.java index e581718..16fa318 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonConnection.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonConnection.java @@ -94,6 +94,7 @@ public class ProtonConnection extends ProtonEndpoint<Connection> implements Conn * Create a new unbound Connection instance. * * @param engine + * Parent engine that created and owns this {@link Connection} insatnce. */ ProtonConnection(ProtonEngine engine) { super(engine); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonFrameDecodingHandler.java b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonFrameDecodingHandler.java index 11c3022..0c01e4d 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonFrameDecodingHandler.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonFrameDecodingHandler.java @@ -394,7 +394,7 @@ public class ProtonFrameDecodingHandler implements EngineHandler, SaslPerformati * If parsing fails the parser enters the failed state and remains there always throwing the given exception * if additional parsing is requested. */ - private class ParsingErrorStage implements FrameParserStage { + private static class ParsingErrorStage implements FrameParserStage { private final ProtonException parsingError; diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonTransactionController.java b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonTransactionController.java index 367aac2..22cba1c 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonTransactionController.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonTransactionController.java @@ -514,7 +514,7 @@ public class ProtonTransactionController extends ProtonEndpoint<TransactionContr //----- The Controller specific Transaction implementation - private final class ProtonControllerTransaction extends ProtonTransaction<TransactionController> implements Transaction<TransactionController> { + private static final class ProtonControllerTransaction extends ProtonTransaction<TransactionController> implements Transaction<TransactionController> { private final ProtonTransactionController controller; diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/types/transactions/Coordinator.java b/protonj2/src/main/java/org/apache/qpid/protonj2/types/transactions/Coordinator.java index 9374c76..361d4b0 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/types/transactions/Coordinator.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/types/transactions/Coordinator.java @@ -33,7 +33,7 @@ public final class Coordinator implements Terminus { super(); } - protected Coordinator(Coordinator other) { + private Coordinator(Coordinator other) { if (other.capabilities != null) { this.capabilities = other.capabilities.clone(); } diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/types/transport/Open.java b/protonj2/src/main/java/org/apache/qpid/protonj2/types/transport/Open.java index 651d486..53c2d85 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/types/transport/Open.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/types/transport/Open.java @@ -228,20 +228,20 @@ public final class Open implements Performative { return idleTimeout; } - public Open setIdleTimeout(int idleTimeOut) { + public Open setIdleTimeout(int idleTimeout) { modified |= IDLE_TIMEOUT; - this.idleTimeout = Integer.toUnsignedLong(idleTimeOut); + this.idleTimeout = Integer.toUnsignedLong(idleTimeout); return this; } - public Open setIdleTimeout(long idleTimeOut) { - if (idleTimeOut < 0 || idleTimeOut > UINT_MAX) { - throw new IllegalArgumentException("The Idle Timeout value given is out of range: " + idleTimeOut); + public Open setIdleTimeout(long idleTimeout) { + if (idleTimeout < 0 || idleTimeout > UINT_MAX) { + throw new IllegalArgumentException("The Idle Timeout value given is out of range: " + idleTimeout); } else { modified |= IDLE_TIMEOUT; } - this.idleTimeout = idleTimeOut; + this.idleTimeout = idleTimeout; return this; } diff --git a/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonOutgoingDeliveryTest.java b/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonOutgoingDeliveryTest.java index 8a1ca46..09ff02b 100644 --- a/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonOutgoingDeliveryTest.java +++ b/protonj2/src/test/java/org/apache/qpid/protonj2/engine/impl/ProtonOutgoingDeliveryTest.java @@ -19,6 +19,7 @@ package org.apache.qpid.protonj2.engine.impl; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import org.apache.qpid.protonj2.types.UnsignedInteger; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -54,7 +55,7 @@ public class ProtonOutgoingDeliveryTest extends ProtonEngineTestSupport { assertEquals(newFormat, delivery.getMessageFormat(), "Unexpected message format"); // Highest value - newFormat = (1 << 32) - 1; + newFormat = UnsignedInteger.MAX_VALUE.intValue(); delivery.setMessageFormat(newFormat); assertEquals(newFormat, delivery.getMessageFormat(), "Unexpected message format"); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org