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

Ted Yu commented on HBASE-20180:
--------------------------------

In ReplicationSource.java :
{code}
-    ReplicationEndpoint replicationEndpoint =
-      
Class.forName(replicationEndpointImpl).asSubclass(ReplicationEndpoint.class).newInstance();
+    try {
+      ReplicationEndpoint replicationEndpoint = 
Class.forName(replicationEndpointImpl)
{code}
The scope of replicationEndpoint changes after the patch. The local variable, 
replicationEndpoint, is eclipsed by the following field:
{code}
  private volatile ReplicationEndpoint replicationEndpoint;
{code}
Meaning, replicationEndpoint is null when the following is executed:
{code}
      ReplicationEndpoint newReplicationEndPoint =
        rsServerHost.postCreateReplicationEndPoint(replicationEndpoint);
{code}

> Avoid Class::newInstance
> ------------------------
>
>                 Key: HBASE-20180
>                 URL: https://issues.apache.org/jira/browse/HBASE-20180
>             Project: HBase
>          Issue Type: Sub-task
>            Reporter: Mike Drob
>            Assignee: Mike Drob
>            Priority: Major
>              Labels: error-prone
>         Attachments: HBASE-20180.patch, HBASE-20180.v2.patch
>
>
> Class::newInstance is deprecated starting in Java 9 - 
> https://bugs.openjdk.java.net/browse/JDK-6850612 - because it may throw 
> undeclared checked exceptions. The suggested replacement is 
> {{getDeclaredConstructor().newInstance()}}, which will wrap the checked 
> exceptions in InvocationException.
> There's even an error-prone warning about it, we should promote that to error 
> while we're fixing this.



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

Reply via email to