This is an automated email from the ASF dual-hosted git repository.

vavrtom pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git


The following commit(s) were added to refs/heads/main by this push:
     new fe26eee09f QPID-8653: [Broker-J] Code cleanup: collection type 
arguments, collection factory methods, lambdas (#198)
fe26eee09f is described below

commit fe26eee09fc106d5f5539c7bc6354b7e97adaee4
Author: Daniil Kirilyuk <daniel.kiril...@gmail.com>
AuthorDate: Mon Aug 7 09:58:54 2023 +0200

    QPID-8653: [Broker-J] Code cleanup: collection type arguments, collection 
factory methods, lambdas (#198)
---
 .../tests/protocol/AbstractFrameTransport.java     | 26 ++++++++++++----------
 .../qpid/tests/protocol/AbstractInteraction.java   |  7 +++---
 .../apache/qpid/tests/protocol/HeaderResponse.java |  4 +---
 .../apache/qpid/tests/protocol/InputHandler.java   |  8 +++----
 .../org/apache/qpid/tests/protocol/Matchers.java   |  4 ++--
 .../apache/qpid/tests/protocol/OutputHandler.java  | 19 ++++++++--------
 .../org/apache/qpid/tests/protocol/SaslUtils.java  | 14 +++++++-----
 7 files changed, 42 insertions(+), 40 deletions(-)

diff --git 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/AbstractFrameTransport.java
 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/AbstractFrameTransport.java
index 91b0454b97..1722492a23 100644
--- 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/AbstractFrameTransport.java
+++ 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/AbstractFrameTransport.java
@@ -61,7 +61,9 @@ public abstract class AbstractFrameTransport<I extends 
AbstractInteraction<I>> i
     private volatile Channel _channel;
     private volatile boolean _channelClosedSeen = false;
 
-    public AbstractFrameTransport(final InetSocketAddress brokerAddress, 
InputDecoder inputDecoder, OutputEncoder outputEncoder)
+    public AbstractFrameTransport(final InetSocketAddress brokerAddress,
+                                  final InputDecoder inputDecoder,
+                                  final OutputEncoder outputEncoder)
     {
         _brokerAddress = brokerAddress;
         _inputHandler = new InputHandler(_queue, inputDecoder);
@@ -78,14 +80,14 @@ public abstract class AbstractFrameTransport<I extends 
AbstractInteraction<I>> i
     {
         try
         {
-            Bootstrap b = new Bootstrap();
+            final Bootstrap b = new Bootstrap();
             b.group(_workerGroup);
             b.channel(NioSocketChannel.class);
             b.option(ChannelOption.SO_KEEPALIVE, true);
             b.handler(new ChannelInitializer<SocketChannel>()
             {
                 @Override
-                public void initChannel(SocketChannel ch) throws Exception
+                public void initChannel(final SocketChannel ch)
                 {
                     ChannelPipeline pipeline = ch.pipeline();
                     buildInputOutputPipeline(pipeline);
@@ -94,10 +96,10 @@ public abstract class AbstractFrameTransport<I extends 
AbstractInteraction<I>> i
 
             _channel = b.connect(_brokerAddress).sync().channel();
             _channel.closeFuture().addListener(future ->
-                                               {
-                                                   _channelClosedSeen = true;
-                                                   
_queue.add(CHANNEL_CLOSED_RESPONSE);
-                                               });
+            {
+                _channelClosedSeen = true;
+                _queue.add(CHANNEL_CLOSED_RESPONSE);
+            });
         }
         catch (InterruptedException e)
         {
@@ -129,7 +131,7 @@ public abstract class AbstractFrameTransport<I extends 
AbstractInteraction<I>> i
         }
     }
 
-    ListenableFuture<Void> sendProtocolHeader(final byte[] bytes) throws 
Exception
+    ListenableFuture<Void> sendProtocolHeader(final byte[] bytes)
     {
         return sendBytes(bytes);
     }
@@ -137,8 +139,8 @@ public abstract class AbstractFrameTransport<I extends 
AbstractInteraction<I>> i
     public ListenableFuture<Void> sendBytes(final byte[] bytes)
     {
         Preconditions.checkState(_channel != null, "Not connected");
-        ChannelPromise promise = _channel.newPromise();
-        ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer();
+        final ChannelPromise promise = _channel.newPromise();
+        final ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer();
         buffer.writeBytes(bytes);
         _channel.write(buffer, promise);
         return JdkFutureAdapters.listenInPoolThread(promise);
@@ -147,7 +149,7 @@ public abstract class AbstractFrameTransport<I extends 
AbstractInteraction<I>> i
     public ListenableFuture<Void> sendPerformative(final Object data) throws 
Exception
     {
         Preconditions.checkState(_channel != null, "Not connected");
-        ChannelPromise promise = _channel.newPromise();
+        final ChannelPromise promise = _channel.newPromise();
         _channel.write(data, promise);
         return JdkFutureAdapters.listenInPoolThread(promise);
     }
@@ -159,7 +161,7 @@ public abstract class AbstractFrameTransport<I extends 
AbstractInteraction<I>> i
 
     public void assertNoMoreResponses() throws Exception
     {
-        Response response = getNextResponse();
+        final Response response = getNextResponse();
         assertThat(response, anyOf(nullValue(), 
instanceOf(ChannelClosedResponse.class)));
     }
 
diff --git 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/AbstractInteraction.java
 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/AbstractInteraction.java
index 98b3b6f903..0a86d8d0cd 100644
--- 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/AbstractInteraction.java
+++ 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/AbstractInteraction.java
@@ -60,7 +60,7 @@ public abstract class AbstractInteraction<I extends 
AbstractInteraction<I>>
         acceptableResponseClasses.remove(null);
         if (_latestResponse != null)
         {
-            for (Class<?> acceptableResponseClass : acceptableResponseClasses)
+            for (final Class<?> acceptableResponseClass : 
acceptableResponseClasses)
             {
                 if 
(acceptableResponseClass.isAssignableFrom(_latestResponse.getBody().getClass()))
                 {
@@ -73,8 +73,7 @@ public abstract class AbstractInteraction<I extends 
AbstractInteraction<I>>
                                                       _latestResponse == null 
? null : _latestResponse.getBody()));
     }
 
-    public <T> T consume(final Class<T> expected, final Class<?>... ignore)
-            throws Exception
+    public <T> T consume(final Class<T> expected, final Class<?>... ignore) 
throws Exception
     {
         final Class<?>[] expectedResponses = Arrays.copyOf(ignore, 
ignore.length + 1);
         expectedResponses[ignore.length] = expected;
@@ -82,7 +81,7 @@ public abstract class AbstractInteraction<I extends 
AbstractInteraction<I>>
         T completed = null;
         do
         {
-            Response<?> response = 
consumeResponse(expectedResponses).getLatestResponse();
+            final Response<?> response = 
consumeResponse(expectedResponses).getLatestResponse();
             if (expected.isAssignableFrom(response.getBody().getClass()))
             {
                 completed = (T) response.getBody();
diff --git 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/HeaderResponse.java
 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/HeaderResponse.java
index 9767b40063..3b0e31b11b 100644
--- 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/HeaderResponse.java
+++ 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/HeaderResponse.java
@@ -39,8 +39,6 @@ public class HeaderResponse implements Response<byte[]>
     @Override
     public String toString()
     {
-        return "HeaderResponse{" +
-               "_header=" + Arrays.toString(_header) +
-               '}';
+        return "HeaderResponse{" + "_header=" + Arrays.toString(_header) + '}';
     }
 }
diff --git 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/InputHandler.java
 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/InputHandler.java
index 5a1de51693..a4b14ba419 100644
--- 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/InputHandler.java
+++ 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/InputHandler.java
@@ -38,7 +38,7 @@ public class InputHandler extends ChannelInboundHandlerAdapter
 
     private ByteBuffer _inputBuffer = ByteBuffer.allocate(0);
 
-    InputHandler(final BlockingQueue<Response<?>> queue, InputDecoder 
inputDecoder)
+    InputHandler(final BlockingQueue<Response<?>> queue, final InputDecoder 
inputDecoder)
     {
         _responseQueue = queue;
         _inputDecoder = inputDecoder;
@@ -47,15 +47,15 @@ public class InputHandler extends 
ChannelInboundHandlerAdapter
     @Override
     public void channelRead(final ChannelHandlerContext ctx, final Object msg) 
throws Exception
     {
-        ByteBuf buf = (ByteBuf) msg;
-        ByteBuffer byteBuffer = ByteBuffer.allocate(buf.readableBytes());
+        final ByteBuf buf = (ByteBuf) msg;
+        final ByteBuffer byteBuffer = ByteBuffer.allocate(buf.readableBytes());
         byteBuffer.put(buf.nioBuffer());
         byteBuffer.flip();
         LOGGER.debug("Incoming {} byte(s)", byteBuffer.remaining());
 
         if (_inputBuffer.hasRemaining())
         {
-            ByteBuffer old = _inputBuffer;
+            final ByteBuffer old = _inputBuffer;
             _inputBuffer = ByteBuffer.allocate(_inputBuffer.remaining() + 
byteBuffer.remaining());
             _inputBuffer.put(old);
             _inputBuffer.put(byteBuffer);
diff --git 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/Matchers.java
 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/Matchers.java
index 292ae9ad74..0557ae43ef 100644
--- 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/Matchers.java
+++ 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/Matchers.java
@@ -28,9 +28,9 @@ import org.hamcrest.Matcher;
 
 public class Matchers
 {
-    public static Matcher<Response> protocolHeader(byte[] expectedHeader)
+    public static Matcher<Response> protocolHeader(final byte[] expectedHeader)
     {
-        return new BaseMatcher<Response>()
+        return new BaseMatcher<>()
         {
             @Override
             public void describeTo(final Description description)
diff --git 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/OutputHandler.java
 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/OutputHandler.java
index 71b14a57e8..fd25577036 100644
--- 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/OutputHandler.java
+++ 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/OutputHandler.java
@@ -46,14 +46,14 @@ public class OutputHandler extends 
ChannelOutboundHandlerAdapter
     @Override
     public void write(final ChannelHandlerContext ctx, final Object msg, final 
ChannelPromise promise) throws Exception
     {
-        ByteBuffer byteBuffer = _outputEncoder.encode(msg);
+        final ByteBuffer byteBuffer = _outputEncoder.encode(msg);
         if (byteBuffer != null)
         {
             send(ctx, byteBuffer, promise);
         }
         else if (msg instanceof ByteBuf)
         {
-            ByteBuf buf = (ByteBuf) msg;
+            final ByteBuf buf = (ByteBuf) msg;
             final ByteBuffer bytes = ByteBuffer.allocate(buf.readableBytes());
             buf.readBytes(bytes.array());
             buf.release();
@@ -66,7 +66,7 @@ public class OutputHandler extends 
ChannelOutboundHandlerAdapter
         }
     }
 
-    private synchronized void send(ChannelHandlerContext ctx, final ByteBuffer 
dataByteBuffer, final ChannelPromise promise)
+    private synchronized void send(final ChannelHandlerContext ctx, final 
ByteBuffer dataByteBuffer, final ChannelPromise promise)
     {
         _cachedEncodedFramePromisePairs.add(new 
ByteBufferPromisePair(dataByteBuffer, promise));
         _encodedSize += dataByteBuffer.remaining();
@@ -77,17 +77,18 @@ public class OutputHandler extends 
ChannelOutboundHandlerAdapter
     public synchronized void flush(final ChannelHandlerContext ctx) throws 
Exception
     {
         final ChannelPromise promise = ctx.channel().newPromise();
-        byte[] data  = new byte[_encodedSize];
+        final byte[] data  = new byte[_encodedSize];
 
         int offset = 0;
-        while(offset < _encodedSize)
+        while (offset < _encodedSize)
         {
-            ByteBufferPromisePair currentPair = 
_cachedEncodedFramePromisePairs.poll();
-            int remaining = currentPair.byteBuffer.remaining();
+            final ByteBufferPromisePair currentPair = 
_cachedEncodedFramePromisePairs.poll();
+            final int remaining = currentPair.byteBuffer.remaining();
             currentPair.byteBuffer.get(data, offset, remaining) ;
             offset += remaining;
 
-            promise.addListener(future -> {
+            promise.addListener(future ->
+            {
                 if (future.isSuccess())
                 {
                     currentPair.channelPromise.setSuccess();
@@ -101,7 +102,7 @@ public class OutputHandler extends 
ChannelOutboundHandlerAdapter
 
         _encodedSize = 0;
 
-        ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer();
+        final ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer();
         buffer.writeBytes(data);
 
         try
diff --git 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/SaslUtils.java
 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/SaslUtils.java
index 2659fd30f5..d76f1294f7 100644
--- 
a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/SaslUtils.java
+++ 
b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/SaslUtils.java
@@ -30,21 +30,23 @@ public class SaslUtils
 
     private static String toHex(byte[] bin)
     {
-        StringBuilder result = new StringBuilder(2 * bin.length);
+        final StringBuilder result = new StringBuilder(2 * bin.length);
         for (byte b : bin) {
             result.append(HEX[(b >> 4) & 0xF]);
             result.append(HEX[(b & 0xF)]);
         }
         return result.toString();
     }
-    public static byte[] generateCramMD5ClientResponse(String userName, String 
userPassword, byte[] challengeBytes)
-            throws Exception
+
+    public static byte[] generateCramMD5ClientResponse(final String userName,
+                                                       final String 
userPassword,
+                                                       final byte[] 
challengeBytes) throws Exception
     {
-        String macAlgorithm = "HmacMD5";
-        Mac mac = Mac.getInstance(macAlgorithm);
+        final String macAlgorithm = "HmacMD5";
+        final Mac mac = Mac.getInstance(macAlgorithm);
         mac.init(new 
SecretKeySpec(userPassword.getBytes(StandardCharsets.UTF_8), macAlgorithm));
         final byte[] messageAuthenticationCode = mac.doFinal(challengeBytes);
-        String responseAsString = userName + " " + 
toHex(messageAuthenticationCode);
+        final String responseAsString = userName + " " + 
toHex(messageAuthenticationCode);
         return responseAsString.getBytes();
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to