title: Should I do `Thread.currentThread().interrupt()` before `throw new InterruptedIOException()`?
body: <p>I implement <code>MyInputStream.read()</code> and notice that an <code>InterruptedException</code> may happen within this function. After some searching I have found that it is common to catch the <code>InterruptedException</code> and re-throw an <code>InterruptedIOException</code>, something like:</p>
  
  <pre><code>    try {
          ...
      } catch (InterruptedException e) {
          //Thread.currentThread().interrupt(); // &lt;=== ???
          throw new InterruptedIOException();
      }
  </code></pre>
  
  <p>but only about 50% of code samples do <code>Thread.currentThread().interrupt()</code>.
  Well, it is agreed that <a href="http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html" rel="noreferrer">the worst thing you can do with <code>InterruptedException</code> is swallow it</a>, but <strong><em>should I reinterrupt the current thread before throwing a different exception?</em></strong></p>
  
  <p>PRO: a single interruption request may have multiple "recipients."</p>
  
  <p>CONTRA: some functionality <a href="http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4329256" rel="noreferrer">like logging</a> may be not working before the interrupt status is cleared, which may cause subtle bugs.</p>
  
  <p>CONTRA: we get two notifications about the interrupt request: the thread's interrupted status and the exception. Initially, there is only one notification: either the thread's interrupted status is true or an <code>InterruptedException</code> is thrown, but not both.</p>
  
  <p>PRO: nobody really tests the code against i/o exceptions that may be thrown, and the <code>InterruptedIOException</code> is different from other i/o exceptions; a <code>catch(IOException)</code> clause may swallow the interrupted status.</p>
  
  <p>PS It looks like whatever I do, the problem that <code>InterruptedIOException</code> is a very special kind of <code>IOException</code> requiring a special handler will not be solved.</p>
  
  <p>PPS (EDIT)
  I cannot let the original <code>InterruptedException</code> propagate because <code>InputStream.read()</code> cannot throw <code>InterruptedException</code> (it <code>throws IOException</code> and does not throw anything else).
  And I cannot predict the context in which <code>MyInputStream.read()</code> will be called: an instance of <code>MyInputStream</code> may be passed to any Java or 3rd-party library function that takes an <code>InputStream</code> argument.</p>
  
  <p>As to <a href="http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4329256" rel="noreferrer">the old bug</a>, it looks like it was just closed, not fixed; and the very idea of the interrupted status is that the code would behave differently.</p>