< prev index next >

src/jdk.naming.dns/share/classes/sun/net/spi/nameservice/dns/DNSNameService.java

Print this page
rev 10947 : 8055723: Replace concat String to append in StringBuilder parameters

@@ -461,26 +461,26 @@
     }
 
 
     // ---------
 
-    private static void appendIfLiteralAddress(String addr, StringBuffer sb) {
+    private static void appendIfLiteralAddress(String addr, StringBuilder sb) {
         if (IPAddressUtil.isIPv4LiteralAddress(addr)) {
-            sb.append("dns://" + addr + " ");
+            sb.append("dns://").append(addr).append(' ');
         } else {
             if (IPAddressUtil.isIPv6LiteralAddress(addr)) {
-                sb.append("dns://[" + addr + "] ");
+                sb.append("dns://[").append(addr).append("] ");
             }
         }
     }
 
     /*
      * @return String containing the JNDI-DNS provider URL
      *         corresponding to the supplied List of nameservers.
      */
     private static String createProviderURL(List<String> nsList) {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         for (String s: nsList) {
             appendIfLiteralAddress(s, sb);
         }
         return sb.toString();
     }

@@ -489,11 +489,11 @@
      * @return String containing the JNDI-DNS provider URL
      *         corresponding to the list of nameservers
      *         contained in the provided str.
      */
     private static String createProviderURL(String str) {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         StringTokenizer st = new StringTokenizer(str, ",");
         while (st.hasMoreTokens()) {
             appendIfLiteralAddress(st.nextToken(), sb);
         }
         return sb.toString();
< prev index next >