@@ -405,38 +405,37 @@ public JDWPOptions apply(String s) {
405
405
final String [] options = s .split ("," );
406
406
String transport = null ;
407
407
String host = null ;
408
- String port = null ;
408
+ int port = 0 ;
409
409
boolean server = false ;
410
410
boolean suspend = true ;
411
411
412
412
for (String keyValue : options ) {
413
- String [] parts = keyValue .split ( "=" );
414
- if (parts . length != 2 ) {
413
+ int equalsIndex = keyValue .indexOf ( '=' );
414
+ if (equalsIndex <= 0 ) {
415
415
throw new IllegalArgumentException ("JDWP options must be a comma separated list of key=value pairs." );
416
416
}
417
- String key = parts [ 0 ] ;
418
- String value = parts [ 1 ] ;
417
+ String key = keyValue . substring ( 0 , equalsIndex ) ;
418
+ String value = keyValue . substring ( equalsIndex + 1 ) ;
419
419
switch (key ) {
420
420
case "address" :
421
- parts = value .split (":" );
422
421
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." );
437
437
}
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 ;
440
439
}
441
440
host = inputHost ;
442
441
port = inputPort ;
0 commit comments