@@ -405,38 +405,37 @@ public JDWPOptions apply(String s) {
405405 final String [] options = s .split ("," );
406406 String transport = null ;
407407 String host = null ;
408- String port = null ;
408+ int port = 0 ;
409409 boolean server = false ;
410410 boolean suspend = true ;
411411
412412 for (String keyValue : options ) {
413- String [] parts = keyValue .split ( "=" );
414- if (parts . length != 2 ) {
413+ int equalsIndex = keyValue .indexOf ( '=' );
414+ if (equalsIndex <= 0 ) {
415415 throw new IllegalArgumentException ("JDWP options must be a comma separated list of key=value pairs." );
416416 }
417- String key = parts [ 0 ] ;
418- String value = parts [ 1 ] ;
417+ String key = keyValue . substring ( 0 , equalsIndex ) ;
418+ String value = keyValue . substring ( equalsIndex + 1 ) ;
419419 switch (key ) {
420420 case "address" :
421- parts = value .split (":" );
422421 String inputHost = null ;
423- String inputPort ;
424- if (parts .length == 1 ) {
425- inputPort = parts [0 ];
426- } else if (parts .length == 2 ) {
427- inputHost = parts [0 ];
428- inputPort = parts [1 ];
429- } else {
430- throw new IllegalArgumentException ("Invalid JDWP option, address: " + value + ". Not a 'host:port' pair." );
431- }
432- long realValue ;
433- try {
434- realValue = Long .valueOf (inputPort );
435- if (realValue < 0 || realValue > 65535 ) {
436- throw new IllegalArgumentException ("Invalid JDWP option, address: " + value + ". Must be in the 0 - 65535 range." );
422+ int inputPort = 0 ;
423+ if (!value .isEmpty ()) {
424+ int colonIndex = value .indexOf (':' );
425+ if (colonIndex > 0 ) {
426+ inputHost = value .substring (0 , colonIndex );
427+ }
428+ String portStr = value .substring (colonIndex + 1 );
429+ long realValue ;
430+ try {
431+ realValue = Long .valueOf (portStr );
432+ if (realValue < 0 || realValue > 65535 ) {
433+ throw new IllegalArgumentException ("Invalid JDWP option, address: " + value + ". Must be in the 0 - 65535 range." );
434+ }
435+ } catch (NumberFormatException ex ) {
436+ throw new IllegalArgumentException ("Invalid JDWP option, address: " + value + ". Port is not a number. Must be a number in the 0 - 65535 range." );
437437 }
438- } catch (NumberFormatException ex ) {
439- throw new IllegalArgumentException ("Invalid JDWP option, address is not a number. Must be a number in the 0 - 65535 range." );
438+ inputPort = (int ) realValue ;
440439 }
441440 host = inputHost ;
442441 port = inputPort ;
0 commit comments