harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Petrenko" <alexey.a.petre...@gmail.com>
Subject Re: [classlib][nio]the conflict of RI and spec?
Date Fri, 21 Jul 2006 07:01:27 GMT
No, temp files are not controlled by OS.

2006/7/21, Jimmy, Jing Lv <firepure@gmail.com>:
> Anton Luht wrote:
> > Jimmy,
> >
> > Please add readFile.delete() and writeFile.delete() in the end of test
> > or .deleteOnExit() in any place. Files created by createTempFile are
> > not cleaned up automatically.
> >
>
> Ah yes, sorry for that, thanks!
> So temp files may not controlled by OS itself even they are in temp
> directory of OS?
>
> > On 7/19/06, Jimmy, Jing Lv <firepure@gmail.com> wrote:
> >> Hi:
> >>
> >>      I find a conflict that RI does not behave as spec says in
> >> java.nio.channels.FileChannel.transforFrom(ReadableByteChannel src,
> >>                               long position,long count).
> >>      The spec says:"...Fewer than the requested number of bytes will be
> >> transferred if the source channel has fewer than count bytes
> >> remaining..."[1]. As expected, invoking this method with a count larger
> >> than the number of bytes remaining in the ReadableByteChannel, RI should
> >> return a number of bytes exactly transfered. But in fact, RI throws an
> >> IOException. I run the test[2] on windowsXP SP2 with RI1.5.0_01 and
> >> RI1.5.0_06, and on Linux(redhat 9) with RI1.5.0_02 and RI1.5.0_06, and
> >> get the same result.
> >>      Currently Harmony behave well on this. I guess this is a bug of RI,
> >> and Harmony implementation is good. If no objection, I suggest add this
> >> test to Harmony.
> >>      Any opinions? Thanks!
> >>
> >>
> >> [1] spec of FileChannel:
> >> http://java.sun.com/j2se/1.5.0/docs/api/java/nio/channels/FileChannel.html
> >>
> >> [2] the test:
> >>      public void test_transferFromLReadableByteChannelJJ_overflow()
> >>              throws Exception {
> >>          String content = "test content";
> >>          int length = content.length();
> >>          File readFile = File.createTempFile("testfile1", "tmp");
> >>          File writeFile = File.createTempFile("testfile2", "tmp");
> >>          FileOutputStream fos = new FileOutputStream(readFile);
> >>          try {
> >>              fos.write(content.getBytes());
> >>          } finally {
> >>              fos.close();
> >>          }
> >>          FileChannel fc1 = new FileInputStream(readFile).getChannel();
> >>          FileChannel fc2 = new FileOutputStream(writeFile).getChannel();
> >>          try {
> >>              long result = fc2.transferFrom(fc1, 0, length * 2);
> >>              assertEquals(length, result);
> >>          } finally {
> >>              fc1.close();
> >>              fc2.close();
> >>          }
> >>      }
> >>
> >> --
> >>
> >> Best Regards!
> >>
> >> Jimmy, Jing Lv
> >> China Software Development Lab, IBM
> >>
> >> ---------------------------------------------------------------------
> >> Terms of use : http://incubator.apache.org/harmony/mailing.html
> >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >>
> >>
> >
> >
>
>
> --
>
> Best Regards!
>
> Jimmy, Jing Lv
> China Software Development Lab, IBM
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Alexey A. Petrenko
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Mime
View raw message