[ 
https://issues.apache.org/jira/browse/HDFS-10185?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15204427#comment-15204427
 ] 

John Zhuge commented on HDFS-10185:
-----------------------------------

bq. Yes, my new code is used to check if {{Thread.currentThread().interrupt()}} 
works. Because the original code {{assertTrue(Thread.interrupted())}} of 
checking this is not executed.

Sorry I don't understand, hasn't the unit test of Java Thread package already 
tested it?

If you think the code {{assertTrue(Thread.interrupted())}} can never be 
reached, use {{Assert.fail}}:
{code}
      Thread.currentThread().interrupt();
      try {
        stm.hflush();
        Assert.fail("Not interrupted as expected");
      } catch (InterruptedIOException ie) {
        System.out.println("Got expected exception during flush");
      }
{code}

However, do you think this comment is no longer true?
{quote}
        // If we made it past the hflush(), then that means that the ack made 
it back
        // from the pipeline before we got to the wait() call. In that case we 
should
        // still have interrupted status.
{quote}

> TestHFlushInterrupted verifies interrupt state incorrectly
> ----------------------------------------------------------
>
>                 Key: HDFS-10185
>                 URL: https://issues.apache.org/jira/browse/HDFS-10185
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: test
>            Reporter: Lin Yiqun
>            Assignee: Lin Yiqun
>         Attachments: HDFS-10185.001.patch
>
>
> In unit test {{TestHFlush#testHFlushInterrupted}}, there were some places 
> verifying interrupt state incorrectly. As follow:
> {code}
>       Thread.currentThread().interrupt();
>       try {
>         stm.hflush();
>         // If we made it past the hflush(), then that means that the ack made 
> it back
>        // from the pipeline before we got to the wait() call. In that case we 
> should
>         // still have interrupted status.
>         assertTrue(Thread.interrupted());
>       } catch (InterruptedIOException ie) {
>         System.out.println("Got expected exception during flush");
>       }
> {code}
> When stm do the {{hflush}} operation, it will throw interrupted exception and 
> the {{assertTrue(Thread.interrupted())}} will not be execute. And if you put 
> this before the {{hflush}}, this method will clear interrupted state and the 
> expected exception will not be throw. The similar problem also appears after 
> in stm.close.
> So we should use a way to get state without clearing interrupted state like 
> {{Thread.currentThread().isInterrupted()}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to