FULL PRODUCT VERSION :
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Client VM (build 24.51-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.2.9200]
Windows Server 2012 Standard
64-bit Operating System, x64-based processor
A DESCRIPTION OF THE PROBLEM :
We are using the FileStore.getUsableSpace() function to check for the free disk space in the machine. In Window Server 2012, this function is returning 0 while the Volume Shadow Copy is running on the drive.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I have copy a test program below. Please save it on a file "DiskUsageTestv2.java" and compile the program.
1. Run the program in the C: drive as follows:
java DiskUsageTestv2 c:
The program will continuously displays the following information:
Date, Total(KB), Used(KB), Avail(KB)
The last column "Avail(KB)" displays the free disk space using the FileStore.getUsableSpace() function. The DiskUsageTestv2 will exit if the value for usable space is less than 512MB.
2. To run the Volume Shadow Copy, access the Properties of C: drive and click the Shadow Copies tab.
On the Shadow Copies window, click on "Create Now" few times one time after another â creating a copy takes around 2 seconds.
But after second/third consecutive execution, DiskUsageTestv2 will exit with SYSTEM BREAK error. Because the function returns 0 for getUsableSpace().
Depending on the timing, the function will return 0 on the first "Create Now" run.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
We are expecting that the function FileStore.getUsableSpace() will always return the correct value even the Volume Shadow Copy is running.
ACTUAL -
The function FileStore.getUsableSpace() returns 0 when running the Volume Shadow Copy.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.io.IOException;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
/**
* Example utility that works like the df(1M) program to print out disk space
* information
*/
public class DiskUsageTestv2 {
private static final long oneKB = 1024l;
private static final long oneMB = oneKB * 1024;
private static long printFileStore(FileStore store, String formattedDate) throws IOException {
long total = store.getTotalSpace();
long used = (store.getTotalSpace() - store.getUnallocatedSpace());
long avail = store.getUsableSpace();
System.out.format("%-20s %12d %12d %12d\n", formattedDate, total/oneKB, used/oneKB, avail/oneKB);
return avail;
}
public static void main(String[] args) throws IOException {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = null;
System.out.format("%-20s %12s %12s %12s\n", "Date", "Total(KB)", "Used(KB)", "Avail(KB)");
if (args.length == 0) {
System.err.println("Supported parameter [1]: File Path");
} else {
for (String file: args) {
FileStore store = Files.getFileStore(Paths.get(file));
while (true) {
date = new Date();
long freeSpace = printFileStore(store, dateFormat.format(date).toString());
if (freeSpace < (512 * oneMB)) {
System.out.println("SYSTEM BREAK!!! Left space is " + freeSpace + " bytes");
break;
}
}
}
}
}
}
---------- END SOURCE ----------
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Client VM (build 24.51-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.2.9200]
Windows Server 2012 Standard
64-bit Operating System, x64-based processor
A DESCRIPTION OF THE PROBLEM :
We are using the FileStore.getUsableSpace() function to check for the free disk space in the machine. In Window Server 2012, this function is returning 0 while the Volume Shadow Copy is running on the drive.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I have copy a test program below. Please save it on a file "DiskUsageTestv2.java" and compile the program.
1. Run the program in the C: drive as follows:
java DiskUsageTestv2 c:
The program will continuously displays the following information:
Date, Total(KB), Used(KB), Avail(KB)
The last column "Avail(KB)" displays the free disk space using the FileStore.getUsableSpace() function. The DiskUsageTestv2 will exit if the value for usable space is less than 512MB.
2. To run the Volume Shadow Copy, access the Properties of C: drive and click the Shadow Copies tab.
On the Shadow Copies window, click on "Create Now" few times one time after another â creating a copy takes around 2 seconds.
But after second/third consecutive execution, DiskUsageTestv2 will exit with SYSTEM BREAK error. Because the function returns 0 for getUsableSpace().
Depending on the timing, the function will return 0 on the first "Create Now" run.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
We are expecting that the function FileStore.getUsableSpace() will always return the correct value even the Volume Shadow Copy is running.
ACTUAL -
The function FileStore.getUsableSpace() returns 0 when running the Volume Shadow Copy.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.io.IOException;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
/**
* Example utility that works like the df(1M) program to print out disk space
* information
*/
public class DiskUsageTestv2 {
private static final long oneKB = 1024l;
private static final long oneMB = oneKB * 1024;
private static long printFileStore(FileStore store, String formattedDate) throws IOException {
long total = store.getTotalSpace();
long used = (store.getTotalSpace() - store.getUnallocatedSpace());
long avail = store.getUsableSpace();
System.out.format("%-20s %12d %12d %12d\n", formattedDate, total/oneKB, used/oneKB, avail/oneKB);
return avail;
}
public static void main(String[] args) throws IOException {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = null;
System.out.format("%-20s %12s %12s %12s\n", "Date", "Total(KB)", "Used(KB)", "Avail(KB)");
if (args.length == 0) {
System.err.println("Supported parameter [1]: File Path");
} else {
for (String file: args) {
FileStore store = Files.getFileStore(Paths.get(file));
while (true) {
date = new Date();
long freeSpace = printFileStore(store, dateFormat.format(date).toString());
if (freeSpace < (512 * oneMB)) {
System.out.println("SYSTEM BREAK!!! Left space is " + freeSpace + " bytes");
break;
}
}
}
}
}
}
---------- END SOURCE ----------