code: public static void endTimer(Optional<Timer.Context> timer) {
      timer.transform(new Function<Timer.Context, Timer.Context>() {
        @Override
        public Timer.Context apply(@Nonnull Timer.Context input) {
          input.close();
          return input;
        }
      });
    }
docs: Ends a {@link com.codahale.metrics.Timer.Context} only if it exists.
  @param timer an Optional&lt;{@link com.codahale.metrics.Timer.Context}$gt;