title: HandlerInterceptorAdapter doesn't seem to forward HttpServletRequestWrapper
body: <p>I'm trying to create a validation system for my JSON webservices.  The idea is to have an interceptor catch every Json <code>@RequestBody</code>, make a JSON object with it by means of <code>JacksonMapping</code>.  Then read <code>ValidationAnnotations</code> from it to check the data and when passes complete the regular flow otherwhise send back to sender with a modelandviewmap containing the error messages.</p>
  
  <p>Knowing this context consider this</p>
  
  <pre><code>@RequestMapping(value="/rest/contact/list/filter", method = RequestMethod.POST, consumes="application/json", produces="application/json")
  public @ResponseBody JsonContactList findFilteredContacts(@RequestBody JsonContactSelectorData selectorData, Model model) throws Exception {
      MbaLog.debugLog(logger,"Finding Contacts with selector data: " + selectorData);     
      JsonContactList result = contactService.findContacts(selectorData);
      return result;
  }
  </code></pre>
  
  <p>This is my controller method that the interceptor will be before, following is the interceptor</p>
  
  <pre><code>@Override
  public boolean preHandle(HttpServletRequest request,
          HttpServletResponse response, Object handler) throws Exception {
      ValidationRequestWrapper wrapper = new ValidationRequestWrapper(request);
      //do complex validation here 
      return super.preHandle(wrapper, response, handler);
  }
  </code></pre>
  
  <p>Next on the list is the requestwrapper</p>
  
  <pre><code>public class ValidationRequestWrapper extends HttpServletRequestWrapper {
  
      private String jsonString;
  
      public ValidationRequestWrapper(HttpServletRequest request) throws IOException {
          super(request);
          jsonString = "";
          Scanner scanner = new Scanner(request.getInputStream(), "UTF-8").useDelimiter("\\A");
          if (scanner.hasNext())
              jsonString = scanner.next();
  
          System.out.println("need a break");
      }
  
      @Override  
      public ServletInputStream getInputStream ()   
          throws IOException {   
  
          final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(jsonString.getBytes());   
          ServletInputStream inputStream = new ServletInputStream() {   
              public int read ()    
                  throws IOException {   
                  return byteArrayInputStream.read();   
              }   
          };   
          return inputStream;   
      }   
  }
  </code></pre>
  
  <p>As you can see, I grab the request input stream and then override the <code>getInputStream()</code> as is custom to do in these situations.  In the interceptor you can see me instantiate this wrapper and pass it on to the super.prehandle(...).  I expected to then enter the controller and work happily further with my jsonobject.  However the result is rather dissapointing.</p>
  
  <pre><code>java.io.EOFException: No content to map to Object due to end of input
  </code></pre>
  
  <p>The overriden inputstream method doesn't seem to be called ?  Or do I have this mechanic completly wrong?  Can I even use a <code>HandlerInterceptorAdapter</code> ?</p>