[jira] [Commented] (CXF-8096) Adding LoggingFeature causes blocking read

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[jira] [Commented] (CXF-8096) Adding LoggingFeature causes blocking read

Andriy Redko (Jira)

    [ https://issues.apache.org/jira/browse/CXF-8096?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16927108#comment-16927108 ]

Freeman Fang commented on CXF-8096:

Hi [~kkurucz],

I took a close look at the problem you described, IMO this is kind of by design.

About this method in your concern
IOUtils.copyAtLeast(bis, bos, limit == -1 ? Integer.MAX_VALUE : limit);
It's actually not "blocked until the stream will be closed."  This method will do
     * Copy at least the specified number of bytes from the input to the output
     * or until the inputstream is finished.
     * @param input
     * @param output
     * @param atLeast
     * @throws IOException
And by default When you enable logging feature, the "specified number of bytes" is 48k, it's what will be printed out as log for the incoming message. Since most message(at least in your testcase)'s size less than 48k, so it seems "blocked until the stream will be closed."  but this isn't true, it still use streaming way to read rest of the inputstream if it's size > 48K and copy stream to cachedOut which enable to re-read it to print the log do need extra time to process. Enable logging feature will give you more information, but it will add another layer of process on the Incoming message steam, so it has detrimental impact on performance, but this is by design and it's kind of trade-off.

Best Regards

> Adding LoggingFeature causes blocking read
> ------------------------------------------
>                 Key: CXF-8096
>                 URL: https://issues.apache.org/jira/browse/CXF-8096
>             Project: CXF
>          Issue Type: Bug
>          Components: logging
>    Affects Versions: 3.3.3
>            Reporter: Krisztian Kurucz
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
> Adding org.apache.cxf.feature.LoggingFeature to WebClient feature affects the reading of the response is blocked until the stream will be closed.
> Without LoggingFeature the response's input stream can be get immediately for further processing.
> error-prone line in WireTapIn::handleInputStream(Message, InputStream)::Line92: 
> {code:java}
> IOUtils.copyAtLeast(bis, bos, limit == -1 ? Integer.MAX_VALUE : limit);{code}

This message was sent by Atlassian Jira