You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2006/02/08 18:29:48 UTC
DO NOT REPLY [Bug 38574] New: - [io] FileSystemUtils returns incorrect free space on Linux
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38574>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=38574
Summary: [io] FileSystemUtils returns incorrect free space on
Linux
Product: Commons
Version: 1.1.0
Platform: Other
OS/Version: other
Status: NEW
Severity: normal
Priority: P2
Component: IO
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: niall@switchfire.com
Re: Commons-IO class FileSystemUtils
The method freeSpace(String path) returns free disk space in bytes on Windows,
and returns free disk space in kilobytes (not bytes) on Linux (possibly Unix /
Mac OS etc. also).
The internal method freeSpaceUnix javadoc reads "Find free space on the *nix
platform using the 'df' command." The value returned by df is read in to a
variable called bytes and returned. Man pages for df on Linux (Fedora Core 4)
read "Disk space is shown in 1K blocks by default". So method
freeSpaceUnix is returning the number of kilobytes free space, not bytes.
A simple fix could be to add line "bytes = bytes * 1024;" after bytes are read in.
The javadocs for this class could be improved also. Comment "@return the amount
of free drive space on the volume" could read "@return the amount of free drive
space on the volume in bytes".
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 38574] - [io] FileSystemUtils returns incorrect free space on Linux
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38574>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=38574
niall@switchfire.com changed:
What |Removed |Added
----------------------------------------------------------------------------
OS/Version|other |Linux
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [io] Help with testing on Unix - FileSystemUtils returns incorrect
free space on Linux
Posted by Stephen Colebourne <sc...@btopenworld.com>.
I've made the change.
Stephen
Phil Steitz wrote:
> Found the source of the test failures for me. I think the code and
> test cases are correct, but somehow the clock precision or something
> else is messing up the chronology for me. The tests all pass if I
> make spin wait until a full second has elapsed:
>
> private void spin(long now) {
> while (System.currentTimeMillis() <= now + 1000); <-- add a sec.
> }
>
> That slows down the tests a bit, but makes them pass. Has this been
> reported before?
>
> Phil
>
> On 3/4/06, Phil Steitz <ph...@gmail.com> wrote:
>
>>Works4me on RH FC 2, with both Kb and original method returning kbytes.
>>
>>Looks like there is a cut and paste error in the javadoc for the new
>>method, though. The "Kb" seems to be missing from the examples.
>>
>>I am also getting test failures for the FileFilterTestCase. The
>>newfile tests are failing. I will look at this some more.
>>
>>Phil
>>
>>On 3/4/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
>>
>>>If anyone has the ability to test FileSystemUtils.freeSpaceKb() on boxes
>>>other than WindowsXP I'd like to know if the results tally what you'd
>>>expect by calling dir/df directly.
>>>
>>>thanks
>>>Stephen
>>>
>>>
>>>bugzilla@apache.org wrote:
>>>
>>>>http://issues.apache.org/bugzilla/show_bug.cgi?id=38574
>>>>------- Additional Comments From scolebourne@joda.org 2006-03-04 20:16 -------
>>>>FileSystemUtils.freeSpaceKb(drive)
>>>>New method that unifies result to be in kilobytes
>>>>
>>>>Please reopen if you believe that the new method returns the wrong result (I can
>>>>on test on Windows)
>>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [io] Help with testing on Unix - FileSystemUtils returns incorrect free space on Linux
Posted by Niall Pemberton <ni...@gmail.com>.
On 3/6/06, Phil Steitz <ph...@gmail.com> wrote:
> and the tests pass. Could be I am missing something or there is
> something funny going on with the .lastModified impl.
I found on w2k the last modified was being rounded up to the nearest
second. Looks like on your platform its being rounded down. According
to the java.io.File javadoc for the setLastModified() method "all
platforms support file-modification times to the nearest second, but
some provide more precision".
So looks like my patch only partially fixed the issue - and your
solution to add a second ensures that the files created are correctly
sequenced wrt to age regardless of the impl.
Anyway, sorry for the noise - I only just noticed that Stephen and
Sandy had already conspired to fix this - I thought it was still an
ongoing issue.
http://svn.apache.org/viewcvs.cgi?rev=383224&view=rev
http://svn.apache.org/viewcvs.cgi?rev=383450&view=rev
Niall
> Phil
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [io] Help with testing on Unix - FileSystemUtils returns incorrect free space on Linux
Posted by Phil Steitz <ph...@gmail.com>.
>
> http://svn.apache.org/viewcvs.cgi?rev=369049&view=rev
> http://issues.apache.org/bugzilla/show_bug.cgi?id=38130
>
> Maybe theres an issue with the patch I submitted - could you post the
> results of the tests without your change to add a sec?
>
> Niall
Reverting the spin() change, I get
Testcase: testAgeFilter(org.apache.commons.io.filefilter.FileFilterTestCase): FAILED
Filter(File) org.apache.commons.io.filefilter.AgeFileFilter not false
for /home/phil/trunks-proper/io/test/io/new.txt
junit.framework.AssertionFailedError: Filter(File)
org.apache.commons.io.filefilter.AgeFileFilter not false for
/home/phil/trunks-proper/io/test/io/new.txt
at org.apache.commons.io.filefilter.FileFilterTestCase.assertFiltering(FileFilterTestCase.java:60)
at org.apache.commons.io.filefilter.FileFilterTestCase.testAgeFilter(FileFilterTestCase.java:491)
blah blah
The first failure is the first of the following lines in testAgeFilter,
all of which fail
assertFiltering(filter1, newFile, false);
assertFiltering(filter2, newFile, false);
assertFiltering(filter3, newFile, true);
assertFiltering(filter4, newFile, false);
assertFiltering(filter5, newFile, false);
assertFiltering(filter6, newFile, true);
assertFiltering(filter7, newFile, false);
assertFiltering(filter8, newFile, false);
assertFiltering(filter9, newFile, true);
When I do the this:
+++ src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java (working
copy)
@@ -462,7 +462,9 @@
File oldFile = new File(getTestDirectory(), "old.txt");
createFile(oldFile, 0);
spin(oldFile.lastModified());
+ System.out.println("oldFile.lastModified(): " +
oldFile.lastModified());
long now = System.currentTimeMillis();
+ System.out.println("now: " + now);
IOFileFilter filter1 = FileFilterUtils.ageFileFilter(now);
IOFileFilter filter2 = FileFilterUtils.ageFileFilter(now, true);
IOFileFilter filter3 = FileFilterUtils.ageFileFilter(now, false);
@@ -472,12 +474,14 @@
IOFileFilter filter6 = FileFilterUtils.ageFileFilter(date, false);
File reference = new File(getTestDirectory(), "reference.txt");
createFile(reference, 0);
+ System.out.println("reference.lastModified(): " +
reference.lastModified());
IOFileFilter filter7 = FileFilterUtils.ageFileFilter(reference);
IOFileFilter filter8 = FileFilterUtils.ageFileFilter(reference, true);
IOFileFilter filter9 = FileFilterUtils.ageFileFilter(reference, false);
spin(reference.lastModified());
File newFile = new File(getTestDirectory(), "new.txt");
createFile(newFile, 0);
+ System.out.println("newFile.lastModified(): " +
newFile.lastModified());
I get this to the console:
oldFile.lastModified(): 1141618573000
now: 1141618573368
reference.lastModified(): 1141618573000
newFile.lastModified(): 1141618573000
Does not look correct to me, given the sequence. Making spin wait a
full second changes this to:
oldFile.lastModified(): 1141618907000
now: 1141618908002
reference.lastModified(): 1141618908000
newFile.lastModified(): 1141618909000
and the tests pass. Could be I am missing something or there is
something funny going on with the .lastModified impl.
Phil
>
> > Phil
> >
> > On 3/4/06, Phil Steitz <ph...@gmail.com> wrote:
> > > Works4me on RH FC 2, with both Kb and original method returning kbytes.
> > >
> > > Looks like there is a cut and paste error in the javadoc for the new
> > > method, though. The "Kb" seems to be missing from the examples.
> > >
> > > I am also getting test failures for the FileFilterTestCase. The
> > > newfile tests are failing. I will look at this some more.
> > >
> > > Phil
> > >
> > > On 3/4/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
> > > > If anyone has the ability to test FileSystemUtils.freeSpaceKb() on boxes
> > > > other than WindowsXP I'd like to know if the results tally what you'd
> > > > expect by calling dir/df directly.
> > > >
> > > > thanks
> > > > Stephen
> > > >
> > > >
> > > > bugzilla@apache.org wrote:
> > > > > http://issues.apache.org/bugzilla/show_bug.cgi?id=38574
> > > > > ------- Additional Comments From scolebourne@joda.org 2006-03-04 20:16 -------
> > > > > FileSystemUtils.freeSpaceKb(drive)
> > > > > New method that unifies result to be in kilobytes
> > > > >
> > > > > Please reopen if you believe that the new method returns the wrong result (I can
> > > > > on test on Windows)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [io] Help with testing on Unix - FileSystemUtils returns incorrect free space on Linux
Posted by Niall Pemberton <ni...@gmail.com>.
On 3/4/06, Phil Steitz <ph...@gmail.com> wrote:
> Found the source of the test failures for me. I think the code and
> test cases are correct, but somehow the clock precision or something
> else is messing up the chronology for me. The tests all pass if I
> make spin wait until a full second has elapsed:
>
> private void spin(long now) {
> while (System.currentTimeMillis() <= now + 1000); <-- add a sec.
> }
>
> That slows down the tests a bit, but makes them pass. Has this been
> reported before?
This was modified only recently:
http://svn.apache.org/viewcvs.cgi?rev=369049&view=rev
http://issues.apache.org/bugzilla/show_bug.cgi?id=38130
Maybe theres an issue with the patch I submitted - could you post the
results of the tests without your change to add a sec?
Niall
> Phil
>
> On 3/4/06, Phil Steitz <ph...@gmail.com> wrote:
> > Works4me on RH FC 2, with both Kb and original method returning kbytes.
> >
> > Looks like there is a cut and paste error in the javadoc for the new
> > method, though. The "Kb" seems to be missing from the examples.
> >
> > I am also getting test failures for the FileFilterTestCase. The
> > newfile tests are failing. I will look at this some more.
> >
> > Phil
> >
> > On 3/4/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
> > > If anyone has the ability to test FileSystemUtils.freeSpaceKb() on boxes
> > > other than WindowsXP I'd like to know if the results tally what you'd
> > > expect by calling dir/df directly.
> > >
> > > thanks
> > > Stephen
> > >
> > >
> > > bugzilla@apache.org wrote:
> > > > http://issues.apache.org/bugzilla/show_bug.cgi?id=38574
> > > > ------- Additional Comments From scolebourne@joda.org 2006-03-04 20:16 -------
> > > > FileSystemUtils.freeSpaceKb(drive)
> > > > New method that unifies result to be in kilobytes
> > > >
> > > > Please reopen if you believe that the new method returns the wrong result (I can
> > > > on test on Windows)
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [io] Help with testing on Unix - FileSystemUtils returns incorrect free space on Linux
Posted by Sandy McArthur <sa...@apache.org>.
On 3/5/06, Jörg Schaible <jo...@gmx.de> wrote:
> Hmmm. Even with this change the test fails for me from within Eclipse on
> Linux.
Is the cwd the base dir of the checked out sources? The unit tests
make some assumptions about preexisting directories that are created
when you check out the sources from svn.
--
Sandy McArthur
"He who dares not offend cannot be honest."
- Thomas Paine
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [io] Help with testing on Unix - FileSystemUtils returns incorrect free space on Linux
Posted by Phil Steitz <ph...@gmail.com>.
Which tests, exactly? The newFile tests in FileFilterUtilsTest? I
found that the lastModified times of files created sequentially during
execution of the test did not go in expected chronological order. I
thought this was due to clock precision (things were off by < 100 ms),
but I am no expert on how the OS and jdk play together here. Adding
the delay in the spin, which is intended to force sequencing of
events, fixed the problem for me on RH FC2 running tests from maven.
Phil
On 3/5/06, Jörg Schaible <jo...@gmx.de> wrote:
> Hi Phil,
>
> Phil Steitz wrote:
>
> > Found the source of the test failures for me. I think the code and
> > test cases are correct, but somehow the clock precision or something
> > else is messing up the chronology for me. The tests all pass if I
> > make spin wait until a full second has elapsed:
> >
> > private void spin(long now) {
> > while (System.currentTimeMillis() <= now + 1000); <-- add a sec.
> > }
> >
> > That slows down the tests a bit, but makes them pass. Has this been
> > reported before?
>
> Hmmm. Even with this change the test fails for me from within Eclipse on
> Linux.
>
> - Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [io] Help with testing on Unix - FileSystemUtils returns incorrect free space on Linux
Posted by Jörg Schaible <jo...@gmx.de>.
Hi Phil,
Phil Steitz wrote:
> Found the source of the test failures for me. I think the code and
> test cases are correct, but somehow the clock precision or something
> else is messing up the chronology for me. The tests all pass if I
> make spin wait until a full second has elapsed:
>
> private void spin(long now) {
> while (System.currentTimeMillis() <= now + 1000); <-- add a sec.
> }
>
> That slows down the tests a bit, but makes them pass. Has this been
> reported before?
Hmmm. Even with this change the test fails for me from within Eclipse on
Linux.
- Jörg
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [io] Help with testing on Unix - FileSystemUtils returns incorrect free space on Linux
Posted by Phil Steitz <ph...@gmail.com>.
Found the source of the test failures for me. I think the code and
test cases are correct, but somehow the clock precision or something
else is messing up the chronology for me. The tests all pass if I
make spin wait until a full second has elapsed:
private void spin(long now) {
while (System.currentTimeMillis() <= now + 1000); <-- add a sec.
}
That slows down the tests a bit, but makes them pass. Has this been
reported before?
Phil
On 3/4/06, Phil Steitz <ph...@gmail.com> wrote:
> Works4me on RH FC 2, with both Kb and original method returning kbytes.
>
> Looks like there is a cut and paste error in the javadoc for the new
> method, though. The "Kb" seems to be missing from the examples.
>
> I am also getting test failures for the FileFilterTestCase. The
> newfile tests are failing. I will look at this some more.
>
> Phil
>
> On 3/4/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
> > If anyone has the ability to test FileSystemUtils.freeSpaceKb() on boxes
> > other than WindowsXP I'd like to know if the results tally what you'd
> > expect by calling dir/df directly.
> >
> > thanks
> > Stephen
> >
> >
> > bugzilla@apache.org wrote:
> > > http://issues.apache.org/bugzilla/show_bug.cgi?id=38574
> > > ------- Additional Comments From scolebourne@joda.org 2006-03-04 20:16 -------
> > > FileSystemUtils.freeSpaceKb(drive)
> > > New method that unifies result to be in kilobytes
> > >
> > > Please reopen if you believe that the new method returns the wrong result (I can
> > > on test on Windows)
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [io] Help with testing on Unix - FileSystemUtils returns incorrect free space on Linux
Posted by Phil Steitz <ph...@gmail.com>.
Works4me on RH FC 2, with both Kb and original method returning kbytes.
Looks like there is a cut and paste error in the javadoc for the new
method, though. The "Kb" seems to be missing from the examples.
I am also getting test failures for the FileFilterTestCase. The
newfile tests are failing. I will look at this some more.
Phil
On 3/4/06, Stephen Colebourne <sc...@btopenworld.com> wrote:
> If anyone has the ability to test FileSystemUtils.freeSpaceKb() on boxes
> other than WindowsXP I'd like to know if the results tally what you'd
> expect by calling dir/df directly.
>
> thanks
> Stephen
>
>
> bugzilla@apache.org wrote:
> > http://issues.apache.org/bugzilla/show_bug.cgi?id=38574
> > ------- Additional Comments From scolebourne@joda.org 2006-03-04 20:16 -------
> > FileSystemUtils.freeSpaceKb(drive)
> > New method that unifies result to be in kilobytes
> >
> > Please reopen if you believe that the new method returns the wrong result (I can
> > on test on Windows)
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[io] Help with testing on Unix - FileSystemUtils returns incorrect
free space on Linux
Posted by Stephen Colebourne <sc...@btopenworld.com>.
If anyone has the ability to test FileSystemUtils.freeSpaceKb() on boxes
other than WindowsXP I'd like to know if the results tally what you'd
expect by calling dir/df directly.
thanks
Stephen
bugzilla@apache.org wrote:
> http://issues.apache.org/bugzilla/show_bug.cgi?id=38574
> ------- Additional Comments From scolebourne@joda.org 2006-03-04 20:16 -------
> FileSystemUtils.freeSpaceKb(drive)
> New method that unifies result to be in kilobytes
>
> Please reopen if you believe that the new method returns the wrong result (I can
> on test on Windows)
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 38574] - [io] FileSystemUtils returns incorrect free space on Linux
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38574>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=38574
scolebourne@joda.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
------- Additional Comments From scolebourne@joda.org 2006-03-04 20:16 -------
FileSystemUtils.freeSpaceKb(drive)
New method that unifies result to be in kilobytes
Please reopen if you believe that the new method returns the wrong result (I can
on test on Windows)
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org