From Java 7 ,Closeable
interface has been retrofitted to extend AutoCloseable
interface so that all classes implementing Closeable
interface can work with try-with-resources
statement. Till now,Closeable interface was free to throw any exception including InterrruptedException.
However,with Java 7 any instance of Closeable interface used in try-with-resources
statement might throw InterruptedException when there is automatic invocation of close method after exiting the try block and its InterruptedException
might get suppressed by implicit call to Throwable.addSuppressed(InterruptedException);
So does this break the backward compatibility rule of Java considering that somebody might have its exception unknowingly suppressed and program not behaving as it should