Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-4033

Remove unnecessary judgment of null

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.7.0
    • None

    Description

      in the method of `QuorumPeerMain.runFromConfig`

              try {
                  metricsProvider = MetricsProviderBootstrap.startMetricsProvider(
                      config.getMetricsProviderClassName(),
                      config.getMetricsProviderConfiguration());
              } catch (MetricsProviderLifeCycleException error) {
                  throw new IOException("Cannot boot MetricsProvider " + config.getMetricsProviderClassName(), error);
              }
      

      causing exception or metricsProvider will never be null

              try {
                   ...
              } finally {
                  if (metricsProvider != null) {
                      try {
                          metricsProvider.stop();
                      } catch (Throwable error) {
                          LOG.warn("Error while stopping metrics", error);
                      }
                  }
              }
      

      So there's no need to check again in the finally code block.
      remove it

      finally {
                  try {
                      metricsProvider.stop();
                  } catch (Throwable error) {
                      LOG.warn("Error while stopping metrics", error);
                  }
              }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              lan_ok LiAoNan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m