4646public class HttpCommandProcessor implements CommandProcessor {
4747
4848 private String pathToServlet ;
49- private String browserStartCommand ;
50- private String browserURL ;
49+ private final String browserStartCommand ;
50+ private final String browserURL ;
5151 private String sessionId ;
5252 private String extensionJs ;
5353 private String rcServerLocation ;
@@ -65,8 +65,7 @@ public class HttpCommandProcessor implements CommandProcessor {
6565 */
6666 public HttpCommandProcessor (String serverHost , int serverPort , String browserStartCommand ,
6767 String browserURL ) {
68- rcServerLocation = serverHost +
69- ":" + Integer .toString (serverPort );
68+ rcServerLocation = serverHost + ":" + serverPort ;
7069 this .pathToServlet = "http://" + rcServerLocation + "/selenium-server/driver/" ;
7170 this .browserStartCommand = browserStartCommand ;
7271 this .browserURL = browserURL ;
@@ -131,7 +130,7 @@ public String executeCommandOnServlet(String command) {
131130 }
132131
133132 private String stringContentsOfInputStream (Reader rdr ) throws IOException {
134- StringBuffer sb = new StringBuffer ();
133+ StringBuilder sb = new StringBuilder ();
135134 int c ;
136135 try {
137136 while ((c = rdr .read ()) != -1 ) {
@@ -219,7 +218,7 @@ protected void closeResources(HttpURLConnection conn, Writer wr, Reader rdr) {
219218 }
220219
221220 private String buildCommandBody (String command ) {
222- StringBuffer sb = new StringBuffer ();
221+ StringBuilder sb = new StringBuilder ();
223222 sb .append (command );
224223 if (sessionId != null ) {
225224 sb .append ("&sessionId=" );
@@ -307,13 +306,13 @@ public String[] getStringArray(String commandName, String[] args) {
307306 */
308307 public static String [] parseCSV (String input ) {
309308 List <String > output = new ArrayList <>();
310- StringBuffer sb = new StringBuffer ();
309+ StringBuilder sb = new StringBuilder ();
311310 for (int i = 0 ; i < input .length (); i ++) {
312311 char c = input .charAt (i );
313312 switch (c ) {
314313 case ',' :
315314 output .add (sb .toString ());
316- sb = new StringBuffer ();
315+ sb = new StringBuilder ();
317316 continue ;
318317 case '\\' :
319318 i ++;
@@ -324,7 +323,7 @@ public static String[] parseCSV(String input) {
324323 }
325324 }
326325 output .add (sb .toString ());
327- return output .toArray (new String [output . size () ]);
326+ return output .toArray (new String [0 ]);
328327 }
329328
330329 @ Override
@@ -338,7 +337,7 @@ public Number getNumber(String commandName, String[] args) {
338337 }
339338 if (n instanceof Long && n .intValue () == n .longValue ()) {
340339 // SRC-315 we should return Integers if possible
341- return Integer . valueOf ( n .intValue () );
340+ return n .intValue ();
342341 }
343342 return n ;
344343 }
0 commit comments