activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From michaelpea...@apache.org
Subject [activemq-artemis] 02/08: ARTEMIS-2320 'while' statement does not loop
Date Mon, 29 Apr 2019 10:28:08 GMT
This is an automated email from the ASF dual-hosted git repository.

michaelpearce pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit 781e4c460d7e6751b75d603f853949641a894b1b
Author: Jiri Danek <jdanek@redhat.com>
AuthorDate: Thu Apr 25 16:14:27 2019 +0200

    ARTEMIS-2320 'while' statement does not loop
---
 .../activemq/artemis/core/server/impl/QueueImpl.java   | 14 +++++---------
 .../activemq/artemis/common/SpawnedJMSServer.java      | 18 ++++++++----------
 2 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
index fac18ef..1b49e08 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
@@ -3748,16 +3748,12 @@ public class QueueImpl extends CriticalComponentImpl implements Queue
{
             }
 
          }
-         while (true) {
-            if (messagesIterator != null && messagesIterator.hasNext()) {
-               MessageReference msg = messagesIterator.next();
-               if (msg.isPaged()) {
-                  previouslyBrowsed.add(((PagedReference) msg).getPosition());
-               }
-               return msg;
-            } else {
-               break;
+         if (messagesIterator != null && messagesIterator.hasNext()) {
+            MessageReference msg = messagesIterator.next();
+            if (msg.isPaged()) {
+               previouslyBrowsed.add(((PagedReference) msg).getPosition());
             }
+            return msg;
          }
          if (getPagingIterator() != null) {
             while (getPagingIterator().hasNext()) {
diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/SpawnedJMSServer.java
b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/SpawnedJMSServer.java
index 3e559e8..d80d9c9 100644
--- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/SpawnedJMSServer.java
+++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/SpawnedJMSServer.java
@@ -48,16 +48,14 @@ public class SpawnedJMSServer {
 
          System.out.println("OK");
 
-         String line = null;
-         while ((line = br.readLine()) != null) {
-            if ("STOP".equals(line.trim())) {
-               stopServer();
-               System.out.println("Server stopped");
-               System.exit(0);
-            } else {
-               // stop anyway but with an error status
-               System.exit(1);
-            }
+         String line = br.readLine();
+         if (line != null && "STOP".equals(line.trim())) {
+            stopServer();
+            System.out.println("Server stopped");
+            System.exit(0);
+         } else {
+            // stop anyway but with an error status
+            System.exit(1);
          }
       } catch (Throwable t) {
          t.printStackTrace();


Mime
View raw message