title: HandlerInterceptor has an Object hander parameter, what types will get passed into the interceptor?
body: <p>The <code>HandlerInterceptor</code> interface has a parameter <code>Object handler</code>, which means implementing code has to do type checking on the handler object in order to use it, and cast it as appropriate.</p>
  <p>Code snippets I've found seem to assume the handler is always a <code>HandlerMethod</code> object and return true if this isn't the case, but I want to understand why this seems to be a common implementation to make a robust implementation.</p>
  <p>A standard way of implementing this interface seems to be:</p>
  <pre class="lang-java prettyprint-override"><code>import org.springframework.web.method.HandlerMethod;
  import org.springframework.web.servlet.HandlerInterceptor;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  public class MyInterceptor implements HandlerInterceptor {
      @Override
      public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
          if (handler instanceof HandlerMethod) {
              // ...
              return x; // whether or not to proceed with execution
          }
          return true; // fallback value in case handler wasn't a HandlerMethod
      }
  }
  </code></pre>
  <p>The Spring javadoc seems to ignore the fact that the interface has an Object type in it, it's very unhelpful for my understanding of this interface.</p>
  <p>Some questions that might aid my understanding of how this interface is supposed to be implemented:</p>
  <ul>
  <li>Why is <code>true</code> a sensible default if we get a handler that's not the object we expect it to be?</li>
  <li>Which types can an <code>HandlerInterceptor</code> take for its <code>handler</code> parameter?</li>
  <li>Under what circumstances could <code>handler</code> be a different type, if any?</li>
  <li>Why is it an <code>Object</code>, not a <code>HandlerMethod</code>, parameter?</li>
  </ul>