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

Sean Busbey commented on HBASE-13273:
-------------------------------------

{code}
+      throw new IllegalStateException("Invoking #copyFrom() on EMPTY_RESULT 
isn't allowed!");
{code}

use UnsupportedOperationException please.

{code}
+  /**
+   * Verifies that one can't call copyFrom on instance of EMPTY_RESULT.
+   */
+  public void testCopyFromOnEmptyResult() {
+    try {
+      Result emptyResult = Result.EMPTY_RESULT;
+      Result otherResult = new Result();
+      emptyResult.copyFrom(otherResult);
+      fail("IllegalStateException should have been thrown when trying to" +
+        "call copyFrom on EMPTY_RESULT!");
+    } catch (RuntimeException ex) {
+      assertTrue(ex instanceof IllegalStateException);
+    }
+  }
{code}

we can't use the {{@Test(expected=}} notation because this is still using the 
old TestCase form, right? I'd just like to confirm.

{code}
+    } catch (RuntimeException ex) {
+      assertTrue(ex instanceof IllegalStateException);
+    }
{code}

catch the desired exception directly and just log a debug statement about how 
everything is fine.

> Make Result.EMPTY_RESULT read-only; currently it can be modified
> ----------------------------------------------------------------
>
>                 Key: HBASE-13273
>                 URL: https://issues.apache.org/jira/browse/HBASE-13273
>             Project: HBase
>          Issue Type: Bug
>    Affects Versions: 0.98.0, 1.0.0
>            Reporter: stack
>            Assignee: Mikhail Antonov
>              Labels: beginner
>             Fix For: 2.0.0, 1.0.1, 1.1.0, 0.98.13
>
>         Attachments: HBASE-13273.patch, HBASE-13273.patch
>
>
> Again from [~larsgeorge]
>     Result result2 = Result.EMPTY_RESULT;
>     System.out.println(result2);
>     result2.copyFrom(result1);
>     System.out.println(result2);
> "What do you think happens when result1 has cells? Yep, you just modified the 
> shared public EMPTY_RESULT to be not empty anymore."
> Fix. Result should be non-modifiable post-construction.



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

Reply via email to