Reviewer needed - just another regression test fix in IcedTea6

Jiri Vanek jvanek at redhat.com
Fri Jun 17 01:57:18 PDT 2011


On 06/16/2011 03:14 PM, Pavel Tisnovsky wrote:
> Hi all,
>
> here's another fix for one regression test which 'forget' to clean all
> its temporary files. I'd like to push this fix to IcedTea6 HEAD. Can
> anybody please review it?
>
> ChangeLog entry:
>
> 2011-06-16  Pavel Tisnovsky<ptisnovs at redhat.com>
>
>          * Makefile.am: added new patch
>          * patches/jtreg-ChannelsWrite.patch:
>          Make sure that the regression test
>          openjdk/jdk/test/java/nio/channels/Channels/Write.java
>          deletes all its work files.
>
>
> Thank you in advance,
> Pavel
>
>
>
> jtreg-ChannelsWrite.patch
>
>
> --- openjdk.orig/jdk/test/java/nio/channels/Channels/Write.java	2011-02-28 17:06:59.000000000 +0100
> +++ openjdk/jdk/test/java/nio/channels/Channels/Write.java	2011-06-16 14:14:44.000000000 +0200
> @@ -34,18 +34,37 @@
>
>       public static void main(String[] args) throws Exception {
>           byte[] bb = new byte[3];
> -        File testFile = File.createTempFile("test1", null);
> -        testFile.deleteOnExit();
> +        File testFile = null;
> +        try {
> +            testFile = File.createTempFile("test1", null);
>
> -        FileOutputStream fos = new FileOutputStream(testFile);
> -        FileChannel fc = fos.getChannel();
> -        OutputStream out = Channels.newOutputStream(fc);
> +            FileOutputStream fos = null;
> +            FileChannel fc = null;
> +            OutputStream out = null;
> +            try {
> +                fos = new FileOutputStream(testFile);
> +                fc = fos.getChannel();
> +                out = Channels.newOutputStream(fc);
>
> -        out.write(bb,0,1);
> -        out.write(bb,2,1);
> -
> -        out.close();
> -        fc.close();
> -        fos.close();
> +                out.write(bb,0,1);
> +                out.write(bb,2,1);
> +            }
> +            finally {
> +                if (out != null) {
> +                    out.close();
> +                }
> +                if (fc != null) {
> +                    fc.close();
> +                }
> +                if (fos != null) {
> +                    fos.close();
> +                }
> +            }
> +        }
> +        finally {
> +            if (testFile != null) {
> +                testFile.delete();
> +            }
> +        }
>       }
>   }



Go on. Now the closing of streams and deleting of files is much more probably then without try/catch. Although background of all this cleaning can be very usefull for us all!!!

I see just point that when the stream is not closed sucessfully, then filee will be deleted or some eexception  rise. But I do not know a fix for such a issu. (as delete on exit is useless in jtreg)

=> approved.


Regards J.



More information about the distro-pkg-dev mailing list