public Long incrementCounter(String name, long increment) {
    Long value = null;
    synchronized(metrics) {
      if (!metrics.hasKey(name)) {
        value = Long.valueOf(increment);
        set(name, value);
      } else {
        try {
          value = ((Long)get(name)) + increment;
          set(name, value);
        } catch (JMException e) {
          LOG.warn("Could not find counter value for " + name
              + ", increment operation skipped.", e);
        }
      }
    }
    return value;
  }
Closes scope if open, and reopens it
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/common/metrics/LegacyMetrics.java