Github user revans2 commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2743#discussion_r198996031
  
    --- Diff: 
storm-server/src/main/java/org/apache/storm/metric/timed/TimerDecorated.java ---
    @@ -0,0 +1,50 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.
    + * See the NOTICE file distributed with this work for additional 
information regarding copyright ownership.
    + * The ASF licenses this file to you under the Apache License, Version 2.0 
(the "License");
    + * you may not use this file except in compliance with the License.  You 
may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an "AS IS" 
BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and 
limitations under the License.
    + */
    +
    +package org.apache.storm.metric.timed;
    +
    +import com.codahale.metrics.Timer;
    +
    +import java.util.concurrent.atomic.AtomicReference;
    +
    +public interface TimerDecorated extends AutoCloseable {
    +    public boolean hasStopped();
    +
    +    default boolean hasStopped(final AtomicReference<Timer.Context> 
timing) {
    +        return timing.get() == null;
    +    }
    +
    +    public long stopTiming();
    +
    +    /**
    +     * Stop the timer for measured object. Should be executed only once.
    +     *
    +     * @return Time a object is in use, or under measurement, in 
nanoseconds.
    +     * @throws NullPointerException this method is called more than once.
    +     */
    +    default long stopTiming(final AtomicReference<Timer.Context> 
timingRef) throws NullPointerException {
    --- End diff --
    
    The high level type hierarchy for Throwable for this purpose looks like
    
    ```
    Error extends Throwable
    Exception extends Throwable
    RuntimeException extends Exception
    ```
    
    Errors come from the runtime and don't have to be declared.  They typically 
mean something is wrong with the JVM.
    
    Exceptions are things that you expect to see happen when the code is 
running and most of these have to be declared when thrown except for 
RuntimeException and its subclasses.
    
    RuntimeException is a select group of exceptions where someone decided that 
they happen enough that it would be a real pain to force everyone to declare 
them all the time.  Null Pointer Dereference and Divide by 0 are examples of 
these.  For good or bad they don't have to be declared and by convention they 
don't get declared.


---

Reply via email to