Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-547

Throw a IllegalArgumentException instead of NullPointerException in FileSystemUtils.freeSpaceWindows()

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 2.6
    • Component/s: None
    • Labels:
    • Environment:

      Windows OS

    • Flags:
      Important

      Description

      In FileSystemutils.freeSpaceWindows(String path,long timeout) , path cannot be null. In this function for following assignment
      path = FilenameUtils.normalize(path,bool), path is assigned null value when
      (1) path argument is null.
      (2) path argument is illegal/invalid path as per windows system.

      public class FileSystemutilTest {
      	public static void main(String args[]){
      		FileSystemUtils fsuobj = new FileSystemUtils();
                      String path = ":\\Users\\nikhil\\Desktop\\tests";  /* Invalid path, causes Nullpointer Exception*/
      		try {
      			long space = fsuobj.freeSpace(path);
      		} catch (IOException e) {
      			e.printStackTrace();
      		}
      	}
      }
      

      For above test case, as path is illegal for windows system, Nullpointer exception occurs. A check for validity of path as per windows file system, will resolve this bug.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              nikshinde1996 Nikhil Shinde
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: