This is an automated email from the ASF dual-hosted git repository.
jbertram pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new d00b9ad014 NO-JIRA artemis-core-client: minor SecurityFormatter
improvement
d00b9ad014 is described below
commit d00b9ad014b4e616787c171672e56f5c69367e98
Author: Alexey Markevich <[email protected]>
AuthorDate: Tue Jun 6 23:27:23 2023 +0200
NO-JIRA artemis-core-client: minor SecurityFormatter improvement
---
.../apache/activemq/artemis/utils/SecurityFormatter.java | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java
index 08c414d0ed..14d2b20c5b 100644
---
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java
+++
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java
@@ -16,10 +16,11 @@
*/
package org.apache.activemq.artemis.utils;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.StringTokenizer;
import org.apache.activemq.artemis.core.security.Role;
@@ -65,15 +66,11 @@ public class SecurityFormatter {
return roles;
}
+ @SuppressWarnings("unchecked")
private static List<String> toList(final String commaSeparatedString) {
- List<String> list = new ArrayList<>();
- if (commaSeparatedString == null || commaSeparatedString.trim().length()
== 0) {
- return list;
+ if (commaSeparatedString == null ||
commaSeparatedString.trim().isEmpty()) {
+ return Collections.emptyList();
}
- String[] values = commaSeparatedString.split(",");
- for (String value : values) {
- list.add(value.trim());
- }
- return list;
+ return List.class.cast(Collections.list(new
StringTokenizer(commaSeparatedString, ", ")));
}
}