You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@zookeeper.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/12/23 05:53:00 UTC
[jira] [Updated] (ZOOKEEPER-4033) Remove unnecessary judgment of
null
[ https://issues.apache.org/jira/browse/ZOOKEEPER-4033?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ASF GitHub Bot updated ZOOKEEPER-4033:
--------------------------------------
Labels: pull-request-available (was: )
> 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
> Time Spent: 10m
> 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)