LiAoNan created ZOOKEEPER-4033: ---------------------------------- Summary: Remove unnecessary judgment of null Key: ZOOKEEPER-4033 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4033 Project: ZooKeeper Issue Type: Improvement Reporter: LiAoNan
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)