You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@zookeeper.apache.org by "Damien Diederen (Jira)" <ji...@apache.org> on 2020/12/24 17:14:00 UTC

[jira] [Resolved] (ZOOKEEPER-4033) Remove unnecessary judgment of null

     [ https://issues.apache.org/jira/browse/ZOOKEEPER-4033?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Damien Diederen resolved ZOOKEEPER-4033.
----------------------------------------
    Fix Version/s: 3.7.0
       Resolution: Fixed

Issue resolved by pull request 1562
[https://github.com/apache/zookeeper/pull/1562]

> Remove unnecessary judgment of null
> -----------------------------------
>
>                 Key: ZOOKEEPER-4033
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4033
>             Project: ZooKeeper
>          Issue Type: Improvement
>            Reporter: LiAoNan
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 3.7.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> in the method of `QuorumPeerMain.runFromConfig`
> {code:java}
>         try {
>             metricsProvider = MetricsProviderBootstrap.startMetricsProvider(
>                 config.getMetricsProviderClassName(),
>                 config.getMetricsProviderConfiguration());
>         } catch (MetricsProviderLifeCycleException error) {
>             throw new IOException("Cannot boot MetricsProvider " + config.getMetricsProviderClassName(), error);
>         }
> {code}
> causing exception or metricsProvider will never be null
> {code:java}
>         try {
>              ...
>         } finally {
>             if (metricsProvider != null) {
>                 try {
>                     metricsProvider.stop();
>                 } catch (Throwable error) {
>                     LOG.warn("Error while stopping metrics", error);
>                 }
>             }
>         }
> {code}
> So there's no need to check again in the finally code block.
>  remove it
> {code:java}
> finally {
>             try {
>                 metricsProvider.stop();
>             } catch (Throwable error) {
>                 LOG.warn("Error while stopping metrics", error);
>             }
>         }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)