gemmellr commented on a change in pull request #3365:
URL: https://github.com/apache/activemq-artemis/pull/3365#discussion_r535997735



##########
File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/CompositeAddress.java
##########
@@ -41,12 +41,36 @@ public static SimpleString toFullyQualified(SimpleString 
address, SimpleString q
       return result;
    }
 
+   /**
+    * Checks whether a given string complies the fully qualified queue name 
(FQQN) standard or not.
+    *
+    * @param address The string to check for FQQN standard compliance.
+    * @return boolean
+    */
    public static boolean isFullyQualified(String address) {
-      return address == null ? false : address.contains(SEPARATOR);
+      if (address == null) {
+         return false;
+      }
+
+      // If address length is incapable of holding the separator and two more 
characters
+      if (address.length() < SEPARATOR.length() + 2) {

Review comment:
       Sicne the separator is a constant, the right hand side here is 
effectively a constant, "2+2=4" in this case. @franz1981 Will the JVM quickly 
figure that out since the SEPARATOR constant value is a String and thus final, 
or would declaring a constant for the calculation make sense?

##########
File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/CompositeAddress.java
##########
@@ -41,12 +41,36 @@ public static SimpleString toFullyQualified(SimpleString 
address, SimpleString q
       return result;
    }
 
+   /**
+    * Checks whether a given string complies the fully qualified queue name 
(FQQN) standard or not.
+    *
+    * @param address The string to check for FQQN standard compliance.
+    * @return boolean
+    */
    public static boolean isFullyQualified(String address) {
-      return address == null ? false : address.contains(SEPARATOR);
+      if (address == null) {
+         return false;
+      }
+
+      // If address length is incapable of holding the separator and two more 
characters
+      if (address.length() < SEPARATOR.length() + 2) {
+         return false;
+      }
+
+      int index = address.indexOf(SEPARATOR, 1);
+
+      // If separator is not found, at the start or end of string then this is 
not a FQQN
+      return index != -1 && index != 0 && index != address.length() - 2;

Review comment:
       Middle check seems superfluous, i.e can index ever be 0 given the search 
starts at 1?

##########
File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/CompositeAddress.java
##########
@@ -41,12 +41,36 @@ public static SimpleString toFullyQualified(SimpleString 
address, SimpleString q
       return result;
    }
 
+   /**
+    * Checks whether a given string complies the fully qualified queue name 
(FQQN) standard or not.
+    *
+    * @param address The string to check for FQQN standard compliance.
+    * @return boolean
+    */
    public static boolean isFullyQualified(String address) {
-      return address == null ? false : address.contains(SEPARATOR);
+      if (address == null) {
+         return false;
+      }
+
+      // If address length is incapable of holding the separator and two more 
characters
+      if (address.length() < SEPARATOR.length() + 2) {
+         return false;
+      }
+
+      int index = address.indexOf(SEPARATOR, 1);
+
+      // If separator is not found, at the start or end of string then this is 
not a FQQN

Review comment:
       Adding " or is " instead of the comma might make the comment clearer. 
I'd also move the comment above the indexOf call since the result is dependent 
on that beginning at position 1 in order to carry out the start-of-string check.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to