private void cacheInput(Message outMessage) {
        if (outMessage.getExchange() == null) {
            return;
        }
        Message inMessage = outMessage.getExchange().getInMessage();
        if (inMessage == null) {
            return;
        }
        Object o = inMessage.get("cxf.io.cacheinput");
        DelegatingInputStream in = inMessage.getContent(DelegatingInputStream.class);
        if (PropertyUtils.isTrue(o)) {
            Collection<Attachment> atts = inMessage.getAttachments();
            if (atts != null) {
                for (Attachment a : atts) {
                    if (a.getDataHandler().getDataSource() instanceof AttachmentDataSource) {
                        try {
                            ((AttachmentDataSource) a.getDataHandler().getDataSource()).cache(inMessage);
                        } catch (IOException e) {
                            throw new Fault(e);
                        }
                    }
                }
            }
            if (in != null) {
                in.cacheInput();
            }
        } else if (in != null) {
            //We don't need to cache it, but we may need to consume it in order for the client
            // to be able to receive a response. (could be blocked sending)
            //However, also don't want to consume indefinitely.   We'll limit to 16M.
            try {
                IOUtils.consume(in, 16 * 1024 * 1024);
            } catch (Exception ioe) {
                //ignore
            }
        }
    }
private void cacheInput ( Message outMessage ) { if ( outMessage . getExchange ( ) == null ) { return ; } Message inMessage = outMessage . getExchange ( ) . getInMessage ( ) ; if ( inMessage == null ) { return ; } Object o = inMessage . get ( "cxf.io.cacheinput" ) ; DelegatingInputStream in = inMessage . getContent ( DelegatingInputStream . class ) ; if ( PropertyUtils . isTrue ( o ) ) { Collection < Attachment > atts = inMessage . getAttachments ( ) ; if ( atts != null ) { for ( Attachment a : atts ) { if ( a . getDataHandler ( ) . getDataSource ( ) instanceof AttachmentDataSource ) { try { ( ( AttachmentDataSource ) a . getDataHandler ( ) . getDataSource ( ) ) . cache ( inMessage ) ; } catch ( IOException e ) { throw new Fault ( e ) ; } } } } if ( in != null ) { in . cacheInput ( ) ; } } else if ( in != null ) { try { IOUtils . consume ( in , 16 * 1024 * 1024 ) ; } catch ( Exception ioe ) { } } }
On first write, we need to make sure any attachments and such that are still on the incoming stream
are read in.  Otherwise we can get into a deadlock where the client is still trying to send the
request, but the server is trying to send the response.   Neither side is reading and both blocked
on full buffers.  Not a good situation.
@param outMessage