@@ -2404,20 +2404,18 @@ public int getOwnerIdOf(File file) {
2404
2404
"%u" ,
2405
2405
file .getAbsolutePath ()});
2406
2406
int attempts = this .attempts ;
2407
- boolean exited = false ;
2408
- String line ;
2409
- BufferedReader reader = new BufferedReader (new InputStreamReader (process .getInputStream (), "UTF-8" ));
2410
- try {
2411
- line = reader .readLine ();
2412
- } finally {
2413
- //reader.close();
2414
- }
2407
+ String line = null ;
2415
2408
do {
2416
2409
try {
2417
2410
if (process .exitValue () != 0 ) {
2418
2411
throw new IllegalStateException ("Error while executing stat" );
2419
2412
}
2420
- exited = true ;
2413
+ BufferedReader reader = new BufferedReader (new InputStreamReader (process .getInputStream (), "UTF-8" ));
2414
+ try {
2415
+ line = reader .readLine ();
2416
+ } finally {
2417
+ reader .close ();
2418
+ }
2421
2419
break ;
2422
2420
} catch (IllegalThreadStateException ignored ) {
2423
2421
try {
@@ -2428,7 +2426,7 @@ public int getOwnerIdOf(File file) {
2428
2426
}
2429
2427
}
2430
2428
} while (--attempts > 0 );
2431
- if (! exited ) {
2429
+ if (line == null ) {
2432
2430
process .destroy ();
2433
2431
throw new IllegalStateException ("Command for stat did not exit in time" );
2434
2432
}
@@ -2484,23 +2482,23 @@ public int getOwnerIdOf(File file) {
2484
2482
try {
2485
2483
Process process = Runtime .getRuntime ().exec (new String []{"istat" , file .getAbsolutePath ()});
2486
2484
int attempts = this .attempts ;
2487
- boolean exited = false ;
2488
- StringBuilder output = new StringBuilder ();
2489
- BufferedReader reader = new BufferedReader (new InputStreamReader (process .getInputStream (), "UTF-8" ));
2490
- try {
2491
- String line ;
2492
- while ((line = reader .readLine ()) != null ) {
2493
- output .append (line ).append ("\n " );
2494
- }
2495
- } finally {
2496
- //reader.close();
2497
- }
2485
+ String lines = null ;
2498
2486
do {
2499
2487
try {
2500
2488
if (process .exitValue () != 0 ) {
2501
2489
throw new IllegalStateException ("Error while executing istat" );
2502
2490
}
2503
- exited = true ;
2491
+ StringBuilder output = new StringBuilder ();
2492
+ BufferedReader reader = new BufferedReader (new InputStreamReader (process .getInputStream (), "UTF-8" ));
2493
+ try {
2494
+ String line ;
2495
+ while ((line = reader .readLine ()) != null ) {
2496
+ output .append (line ).append ("\n " );
2497
+ }
2498
+ } finally {
2499
+ reader .close ();
2500
+ }
2501
+ lines = output .toString ();
2504
2502
break ;
2505
2503
} catch (IllegalThreadStateException ignored ) {
2506
2504
try {
@@ -2511,15 +2509,15 @@ public int getOwnerIdOf(File file) {
2511
2509
}
2512
2510
}
2513
2511
} while (--attempts > 0 );
2514
- if (! exited ) {
2512
+ if (lines == null ) {
2515
2513
process .destroy ();
2516
2514
throw new IllegalStateException ("Command for istat did not exit in time" );
2517
2515
}
2518
- Matcher matcher = AIX_OWNER_PATTERN .matcher (output . toString () );
2516
+ Matcher matcher = AIX_OWNER_PATTERN .matcher (lines );
2519
2517
if (matcher .find ()) {
2520
2518
return Integer .parseInt (matcher .group (1 ));
2521
2519
} else {
2522
- throw new IllegalStateException ("Unable to parse response from istat command: " + output );
2520
+ throw new IllegalStateException ("Unable to parse response from istat command: " + lines );
2523
2521
}
2524
2522
} catch (IOException exception ) {
2525
2523
throw new IllegalStateException ("Unable to execute istat command" , exception );
@@ -2572,20 +2570,18 @@ public int getOwnerIdOf(File file) {
2572
2570
"%u" ,
2573
2571
file .getAbsolutePath ()});
2574
2572
int attempts = this .attempts ;
2575
- boolean exited = false ;
2576
- String line ;
2577
- BufferedReader reader = new BufferedReader (new InputStreamReader (process .getInputStream (), "UTF-8" ));
2578
- try {
2579
- line = reader .readLine ();
2580
- } finally {
2581
- //reader.close();
2582
- }
2573
+ String line = null ;
2583
2574
do {
2584
2575
try {
2585
2576
if (process .exitValue () != 0 ) {
2586
2577
throw new IllegalStateException ("Error while executing stat" );
2587
2578
}
2588
- exited = true ;
2579
+ BufferedReader reader = new BufferedReader (new InputStreamReader (process .getInputStream (), "UTF-8" ));
2580
+ try {
2581
+ line = reader .readLine ();
2582
+ } finally {
2583
+ reader .close ();
2584
+ }
2589
2585
break ;
2590
2586
} catch (IllegalThreadStateException ignored ) {
2591
2587
try {
@@ -2596,7 +2592,7 @@ public int getOwnerIdOf(File file) {
2596
2592
}
2597
2593
}
2598
2594
} while (--attempts > 0 );
2599
- if (! exited ) {
2595
+ if (line == null ) {
2600
2596
process .destroy ();
2601
2597
throw new IllegalStateException ("Command for stat did not exit in time" );
2602
2598
}
0 commit comments