Skip to main content

Java 1.7: InterruptedIOException

3 replies [Last post]
mindless
Offline
Joined: 2007-10-30

I've noticed a change in behavior with interrupting I/O:

<br />
import java.io.*;<br />
public class interrupt {<br />
    public static void main(String... args) throws Exception {<br />
        FileOutputStream out = new FileOutputStream(args[0]);<br />
        byte[] data = "test".getBytes();<br />
        Thread.currentThread().interrupt();<br />
        for (int i = 0; i < 1000; i++) out.write(data);<br />
        out.close();<br />
        System.out.println("Done.");<br />
    }<br />
}<br />

In most java versions this will terminate with java.io.InterruptedIOException. I'm pretty sure even early JDK 1.7 builds did, but with b50 and b54 it completes writing the file and prints "Done."

Is this expected or a bug?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mindless
Offline
Joined: 2007-10-30

hm, no replies? should I file this as a bug elsewhere?

kutzi
Offline
Joined: 2005-03-29

Did you test this on Solaris? Maybe it has something to do with the UseVMInterruptibleIO flags - its default setting changed to false in jdk7:
http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2008-November...

Could you try it with -XX:+UseVMInterruptibleIO?

mindless
Offline
Joined: 2007-10-30

That was it, thanks. Adding that flag does get the same behavior as earlier JREs.