BUG-1382: do not instantiate prefixed QNames
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / xml / codec / RandomPrefix.java
index 1349e1ece314f1368fd547475c2869d375b53f9b..0ad701b72e2795f3c166ffc9168c9b97e1159d04 100644 (file)
@@ -29,19 +29,15 @@ final class RandomPrefix {
     String encodeQName(final QName qname) {
         String prefix = prefixes.get(qname.getNamespace());
         if (prefix == null) {
-            prefix = qname.getPrefix();
-            if (prefix == null || prefix.isEmpty() || prefixes.containsValue(prefix)) {
-                final ThreadLocalRandom random = ThreadLocalRandom.current();
-                do {
-                    final StringBuilder sb = new StringBuilder();
-                    for (int i = 0; i < 4; i++) {
-                        sb.append((char)('a' + random.nextInt(25)));
-                    }
-
-                    prefix = sb.toString();
-                } while (prefixes.containsValue(prefix));
-            }
-
+            final ThreadLocalRandom random = ThreadLocalRandom.current();
+            do {
+                final StringBuilder sb = new StringBuilder();
+                for (int i = 0; i < 4; i++) {
+                    sb.append((char)('a' + random.nextInt(25)));
+                }
+
+                prefix = sb.toString();
+            } while (prefixes.containsValue(prefix));
             prefixes.put(qname.getNamespace(), prefix);
         }