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

commit 925d3bf372044b9299b039eb3d026f1f58a15042
Author: Timothy Bish <[email protected]>
AuthorDate: Tue May 20 17:32:33 2025 -0400

    PROTON-2887 Fix some build warnings and other minor cleanups
    
    Fixes some warnings and cleans up some code.
---
 pom.xml                                            |  3 ++-
 .../client/impl/ClientNextReceiverSelector.java    |  3 ---
 .../client/util/ReconnectLocationPool.java         | 24 +++++++++-------------
 .../qpid/protonj2/engine/util/UnsettledMap.java    |  4 +---
 4 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/pom.xml b/pom.xml
index 174c391d..4e7addf5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,6 +62,8 @@
     
<netty-transport-native-epoll-classifier>linux-x86_64</netty-transport-native-epoll-classifier>
     
<netty-transport-native-kqueue-classifier>osx-x86_64</netty-transport-native-kqueue-classifier>
 
+    <jacoco-config></jacoco-config>
+
     <!-- surefire forked jvm arguments -->
     <argLine>-Xmx2g -enableassertions ${jacoco-config}</argLine>
 
@@ -219,7 +221,6 @@
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
-          <optimize>true</optimize>
           <showDeprecation>true</showDeprecation>
           <showWarnings>true</showWarnings>
         </configuration>
diff --git 
a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientNextReceiverSelector.java
 
b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientNextReceiverSelector.java
index 8d8e8619..a6f04b5c 100644
--- 
a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientNextReceiverSelector.java
+++ 
b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientNextReceiverSelector.java
@@ -162,7 +162,6 @@ final class ClientNextReceiverSelector {
         return result != null ? result : selectFirstAvailable();
     }
 
-    @SuppressWarnings("resource")
     private ClientReceiver selectFirstAvailable() {
         return session.getProtonSession().receivers().stream()
                 .filter((r) -> r.getLinkedResource() instanceof ClientReceiver 
&&
@@ -172,7 +171,6 @@ final class ClientNextReceiverSelector {
                 .orElse(null);
     }
 
-    @SuppressWarnings("resource")
     private ClientReceiver selectLargestBacklog() {
         return session.getProtonSession().receivers().stream()
                 .filter((r) -> r.getLinkedResource() instanceof ClientReceiver 
&&
@@ -182,7 +180,6 @@ final class ClientNextReceiverSelector {
                 .orElse(null);
     }
 
-    @SuppressWarnings("resource")
     private ClientReceiver selectSmallestBacklog() {
         return session.getProtonSession().receivers().stream()
                 .filter((r) -> r.getLinkedResource() instanceof ClientReceiver 
&&
diff --git 
a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/util/ReconnectLocationPool.java
 
b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/util/ReconnectLocationPool.java
index d4d5d3d0..c86fa637 100644
--- 
a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/util/ReconnectLocationPool.java
+++ 
b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/util/ReconnectLocationPool.java
@@ -48,9 +48,7 @@ public class ReconnectLocationPool {
         this.entries = new LinkedList<ReconnectLocation>();
 
         if (backups != null) {
-            for (ReconnectLocation entry : backups) {
-                this.add(entry);
-            }
+            backups.forEach(entry -> add(entry));
         }
     }
 
@@ -80,7 +78,7 @@ public class ReconnectLocationPool {
      * @return the next entry that should be used for a connection attempt.
      */
     public ReconnectLocation getNext() {
-       ReconnectLocation next = null;
+        ReconnectLocation next = null;
         synchronized (entries) {
             if (!entries.isEmpty()) {
                 next = entries.removeFirst();
@@ -125,9 +123,7 @@ public class ReconnectLocationPool {
     public void addAll(List<ReconnectLocation> additions) {
         if (additions != null && !additions.isEmpty()) {
             synchronized (entries) {
-                for (ReconnectLocation entry : additions) {
-                    add(entry);
-                }
+                additions.forEach(entry -> add(entry));
             }
         }
     }
@@ -161,13 +157,13 @@ public class ReconnectLocationPool {
      */
     public boolean remove(ReconnectLocation entry) {
         if (entry != null) {
-               synchronized (entries) {
-                   for (ReconnectLocation candidate : entries) {
-                       if (compareEntries(entry, candidate)) {
-                           return entries.remove(candidate);
-                       }
-                   }
-               }
+            synchronized (entries) {
+                for (ReconnectLocation candidate : entries) {
+                    if (compareEntries(entry, candidate)) {
+                        return entries.remove(candidate);
+                    }
+                }
+            }
         }
 
         return false;
diff --git 
a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/util/UnsettledMap.java 
b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/util/UnsettledMap.java
index b4f49e0d..27fc14fa 100644
--- 
a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/util/UnsettledMap.java
+++ 
b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/util/UnsettledMap.java
@@ -93,9 +93,7 @@ public class UnsettledMap<Delivery> implements 
Map<UnsignedInteger, Delivery> {
 
     @Override
     public void putAll(Map<? extends UnsignedInteger, ? extends Delivery> 
source) {
-        for (Entry<? extends UnsignedInteger, ? extends Delivery> entry : 
source.entrySet()) {
-            put(entry.getKey(), entry.getValue());
-        }
+        source.entrySet().forEach(entry -> put(entry.getKey(), 
entry.getValue()));
     }
 
     @Override


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to