Hi, I guess the only way to trace the problem is closely compare your logic with LoggingInInterceptor one and try to find out which part of your code causes the side-effects...

Cheers, Sergey
On 27/02/14 00:34, charlie wrote:
I did some further research on this issue.  Note:  I am using CXF
3.0.0-milestone1.

In milestone1 release, LoggingInInterceptor checks for a
DelegatingInputStream; see below.
But using similar logic in my interceptor also leads to the "Stream closed"
error.

It appears in my configuration, the DelegatingInputStream
is not markable (ie, markSupported() returns false), so the
InputStream.reset() option is not available.

I also tried calling DelegatingInputStream.cacheInput(), to see if caching
the input would
circumvent the "Stream closed" error.  That did not help.

Lastly, I do have an input-validation-interceptor that runs during the
INVOKE phase, I believe;
commenting out that validation-interceptor in the application-context
configuration had no effect.

Why is the input stream on the Message not being kept open after I reset it
(ie, call Message.setContent) ?

Thanks!
Charlie

  148         InputStream is = message.getContent(InputStream.class);
  149         if (is != null) {
  150             CachedOutputStream bos = new CachedOutputStream();
  151             if (threshold > 0) {
  152                 bos.setThreshold(threshold);
  153             }
  154             try {
  155                 // use the appropriate input stream and restore it
later
  156                 InputStream bis = is instanceof DelegatingInputStream
  157                     ? ((DelegatingInputStream)is).getInputStream() :
is;
  158
  159                 IOUtils.copyAndCloseInput(bis, bos);
  160                 bos.flush();
  161                 bis = bos.getInputStream();
  162
  163                 // restore the delegating input stream or the input
stream
  164                 if (is instanceof DelegatingInputStream) {
  165                     ((DelegatingInputStream)is).setInputStream(bis);
  166                 } else {
  167                     message.setContent(InputStream.class, bis);
  168                 }
  169
  170                 if (bos.getTempFile() != null) {
  171                     //large thing on disk...
  172                     buffer.getMessage().append("\nMessage (saved to tmp
file):\n");
  173                     buffer.getMessage().append("Filename: " +
bos.getTempFile().getAbsolutePath() + "\n");
  174                 }
  175                 if (bos.size() > limit) {
  176                     buffer.getMessage().append("(message truncated to "
+ limit + " bytes)\n");
  177                 }
  178                 writePayload(buffer.getPayload(), bos, encoding, ct);
  179
  180                 bos.close();
  181             } catch (Exception e) {
  182                 throw new Fault(e);
  183             }



--
View this message in context: 
http://cxf.547215.n5.nabble.com/error-Stream-closed-interceptor-logs-request-body-content-CachedOutputStream-tp5740545p5740554.html
Sent from the cxf-user mailing list archive at Nabble.com.



--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Reply via email to