0 Replies Latest reply on Apr 12, 2017 6:39 PM by charlesmccree003

    Jboss RestEasy logging of multipart/form-data

    charlesmccree003

      I've implemented a JBoss rest service using JBoss RestEasy on JBoss EAP7 .

       

      I've implemented a ContainerRequestFilter that is going to log the incoming request as follows:

       

      public void filter(ContainerRequestContext containerRequestContext) throws IOException {

       

              //Get request headers

              final MultivaluedMap<String, String> headers = containerRequestContext.getHeaders();

             

              String httpMethod = containerRequestContext.getRequest().getMethod();

       

              logger.info(httpMethod.toUpperCase() + " " + uriInfo.getPath());

             

              InputStream is = containerRequestContext.getEntityStream();

             

              MessageBodyReader messageBodyReader = providers.getMessageBodyReader(Form.class, Form.class, new Annotation[0], MediaType.APPLICATION_FORM_URLENCODED_TYPE);

              boolean isReadAble = messageBodyReader.isReadable(Form.class, Form.class, new Annotation[0], MediaType.MULTIPART_FORM_DATA_TYPE);

              Form form = (Form) messageBodyReader.readFrom(Form.class, Form.class, new Annotation[0], MediaType.MULTIPART_FORM_DATA_TYPE, headers, is);

       

      I have 2 problems.

      1) When the messageBodyReader.readFrom(Form.class, Form.class, new Annotation[0], MediaType.MULTIPART_FORM_DATA_TYPE, headers, is); line is called for the first time I'm getting an ArrayIndexOutOfBounds Exception.  Any subsequent calls work do not return the exception. 

      2)  When the messageBodyReader.readFrom method completed successfully I get returned a javax.ws.rs.core.Form but there is no form data in the  parameters MultivaluedMap.

       

      Any help would be appreciated.