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

Mingliang Liu commented on HDFS-9237:
-------------------------------------

In unit test methods we assume the {{cluster}} is not null as {{setup}} method 
is called before each test. This works just fine since the unit test methods 
won't run if {{setup}} throws an exception when constructing {{cluster}} and 
other resources.

However, the @After annotated methods are guaranteed to run even if a @Before 
or @Test method throws an exception. Thus we'd better check the {{cluster}} 
before using it in {{tearDown}}.

Another approach is to make the {{teadDown}} method throw an exception. This 
patch looks good to me.

> NPE at TestDataNodeVolumeFailureToleration#tearDown
> ---------------------------------------------------
>
>                 Key: HDFS-9237
>                 URL: https://issues.apache.org/jira/browse/HDFS-9237
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: test
>            Reporter: Brahma Reddy Battula
>            Assignee: Brahma Reddy Battula
>         Attachments: HDFS-9237.patch
>
>
> {noformat}
> Stack Trace:
> java.lang.NullPointerException: null
> at 
> org.apache.hadoop.hdfs.server.datanode.TestDataNodeVolumeFailureToleration.tearDown(TestDataNodeVolumeFailureToleration.java:79)
> {noformat}



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

Reply via email to