You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by GitBox <gi...@apache.org> on 2020/01/09 23:03:02 UTC

[GitHub] [cxf] andymc12 commented on a change in pull request #620: CXF-7996: TCK: Resolves FormParam-related failures

andymc12 commented on a change in pull request #620: CXF-7996: TCK: Resolves FormParam-related failures
URL: https://github.com/apache/cxf/pull/620#discussion_r365002716
 
 

 ##########
 File path: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
 ##########
 @@ -1878,4 +1891,16 @@ public static String logMessageHandlerProblem(String name, Class<?> cls, MediaTy
         return errorMessage;
     }
 
+    // copy the input stream so that it is not inadvertently closed
+    private static InputStream copyAndGetEntityStream(Message m) {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            IOUtils.copy(m.getContent(InputStream.class), baos);
+        } catch (IOException e) {
+            throw ExceptionUtils.toInternalServerErrorException(e, null);
+        }
+        final byte[] copiedBytes = baos.toByteArray();
+        m.setContent(InputStream.class, new ByteArrayInputStream(copiedBytes));
 
 Review comment:
   Good question.  I'm running that suggestion through our automated tests and the TCK - on the surface, I think it should be fine, but just want to be sure.  The change I added looks like this:
   ```
   InputStream origInputStream = m.getContent(InputStream.class);
           try {
               IOUtils.copy(origInputStream, baos);
           } catch (IOException e) {
               throw ExceptionUtils.toInternalServerErrorException(e, null);
           } finally {
               try {
                   origInputStream.close();
               } catch (Throwable t) { /* AutoFFDC */ }
           }
   ```
   
   I'm out of the office tomorrow, so I may not have the results until Monday.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services