@@ -66,10 +66,11 @@ public class FileSystemUtils {
6666 private static final int OS ;
6767
6868 /** The path to df */
69- private static String dfPath = "df" ;
69+ private static final String DF ;
7070
7171 static {
7272 int os = OTHER ;
73+ String dfPath = "df" ;
7374 try {
7475 String osName = System .getProperty ("os.name" );
7576 if (osName == null ) {
@@ -103,6 +104,7 @@ public class FileSystemUtils {
103104 os = INIT_PROBLEM ;
104105 }
105106 OS = os ;
107+ DF = dfPath ;
106108 }
107109
108110 /**
@@ -323,14 +325,14 @@ long freeSpaceUnix(String path, boolean kb, boolean posix) throws IOException {
323325 flags += "P" ;
324326 }
325327 String [] cmdAttribs =
326- (flags .length () > 1 ? new String [] {dfPath , flags , path } : new String [] {dfPath , path });
328+ (flags .length () > 1 ? new String [] {DF , flags , path } : new String [] {DF , path });
327329
328330 // perform the command, asking for up to 3 lines (header, interesting, overflow)
329331 List <String > lines = performCommand (cmdAttribs , 3 );
330332 if (lines .size () < 2 ) {
331333 // unknown problem, throw exception
332334 throw new IOException (
333- "Command line '" + dfPath + "' did not return info as expected " +
335+ "Command line '" + DF + "' did not return info as expected " +
334336 "for path '" + path + "'- response was " + lines );
335337 }
336338 String line2 = lines .get (1 ); // the line we're interested in
@@ -344,7 +346,7 @@ long freeSpaceUnix(String path, boolean kb, boolean posix) throws IOException {
344346 tok = new StringTokenizer (line3 , " " );
345347 } else {
346348 throw new IOException (
347- "Command line '" + dfPath + "' did not return data as expected " +
349+ "Command line '" + DF + "' did not return data as expected " +
348350 "for path '" + path + "'- check path is valid" );
349351 }
350352 } else {
@@ -370,14 +372,14 @@ long parseBytes(String freeSpace, String path) throws IOException {
370372 long bytes = Long .parseLong (freeSpace );
371373 if (bytes < 0 ) {
372374 throw new IOException (
373- "Command line '" + dfPath + "' did not find free space in response " +
375+ "Command line '" + DF + "' did not find free space in response " +
374376 "for path '" + path + "'- check path is valid" );
375377 }
376378 return bytes ;
377379
378380 } catch (NumberFormatException ex ) {
379381 throw new IOException (
380- "Command line '" + dfPath + "' did not return numeric data as expected " +
382+ "Command line '" + DF + "' did not return numeric data as expected " +
381383 "for path '" + path + "'- check path is valid" );
382384 }
383385 }
0 commit comments