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

Mingliang Liu commented on HBASE-21138:
---------------------------------------

{quote}
We should keep the same behavior.
{quote}
Make sense.

I checked the test source file and thought that, for those local variables we 
can actually make them test case variable. That way, we can close it in 
{{tearDown()}} in a standard way, and each test can focus on the real 
meaningful test by avoiding try-finally clause. In a few cases where the test 
method needs to the region itself, it's fine {{tearDown()}} closes it again as 
long as we set the {{region}} to null value. The reason is that, 
{{HBaseTestingUtility.closeRegionAndWAL()}} will be a no-op if region is null.

So the plan is to review all the test methods: 1) use the test field {{region}} 
if possible 2) close in {{tearDown()}}, 3) remove the duplicate close in each 
test method {{finally}} clause unless it may relate to other resource (e.g. 
{{wals}} close). Sounds good? Thanks,

> Close HRegion instance at the end of every test in TestHRegion
> --------------------------------------------------------------
>
>                 Key: HBASE-21138
>                 URL: https://issues.apache.org/jira/browse/HBASE-21138
>             Project: HBase
>          Issue Type: Test
>            Reporter: Ted Yu
>            Assignee: Mingliang Liu
>            Priority: Major
>         Attachments: HBASE-21138.000.patch
>
>
> TestHRegion has over 100 tests.
> The following is from one subtest:
> {code}
>   public void testCompactionAffectedByScanners() throws Exception {
>     byte[] family = Bytes.toBytes("family");
>     this.region = initHRegion(tableName, method, CONF, family);
> {code}
> this.region is not closed at the end of the subtest.
> testToShowNPEOnRegionScannerReseek is another example.
> Every subtest should use the following construct toward the end:
> {code}
>     } finally {
>       HBaseTestingUtility.closeRegionAndWAL(this.region);
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to