You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@juneau.apache.org by "John D. Ament (JIRA)" <ji...@apache.org> on 2018/02/03 15:38:00 UTC

[jira] [Updated] (JUNEAU-80) RestCallHandlerDefault service method calls handleResponse which seems to close output stream right before it runs res.flushbuffer which throws an IO exception because the stream is closed.

     [ https://issues.apache.org/jira/browse/JUNEAU-80?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John D. Ament updated JUNEAU-80:
--------------------------------
    Description: 
If I am doing something wrong, please let me know! Please bear with me. I'm not an expert.

I am trying to upgrade some REST infrastructure to use Juneau (7.0.1) and while all REST calls return successfully, I'm always seeing stack traces.

 
{code:java}
java.io.IOException: Stream is closed
at com.ibm.ws.http.channel.internal.outbound.HttpOutputStreamImpl.validate(HttpOutputStreamImpl.java:210)
at com.ibm.ws.http.channel.internal.outbound.HttpOutputStreamImpl.flush(HttpOutputStreamImpl.java:592)
at com.ibm.ws.webcontainer.osgi.response.WCOutputStream.flush(WCOutputStream.java:234)
at org.apache.juneau.rest.RestResponse.flushBuffer(RestResponse.java:461)
at org.apache.juneau.rest.RestCallHandler.service(RestCallHandler.java:182)
at org.apache.juneau.rest.RestCallHandler.service(RestCallHandler.java:129)
at org.apache.juneau.rest.RestServlet.service(RestServlet.java:142)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668){code}
 

 

It looks like the default rest call handler's service method is calling res.flushbuffer() which is throwing an IO exception. For the life of me, I couldn't figure out what was closing the output stream.

 

{{I was wondering if maybe the default 'handleResponse' was somehow closing the response output stream so I made my own RestCallHandler with an Override'd handleResponse which does this:}}
{code:java}
try {
res.flushBuffer();
} catch (IOException e1) {
logger.info("***IO ex flush before handle resp.");
}
try {
super.handleResponse(req, res, output);
} catch (RestException e) {
logger.info("***REST ex from handle resp.");
} catch (IOException e) {
logger.info("***IO ex from handle resp.");
}
try {
res.flushBuffer();
} catch (IOException e1) {
logger.info("***IO ex flush after handle resp.");
}
{code}
 

and sure enough, I got "***IO ex flush *after* handle resp." in my log.

 

It seems that handleResponse is closing the response output stream. I did a little bit more looking, and I see that DefaultHandler has a 'os.close()' in it.

 

Is this the culprit of my issue? (Or am I going about this wrong).

  was:
If I am doing something wrong, please let me know! Please bear with me. I'm not an expert.

I am trying to upgrade some REST infrastructure to use Juneau (7.0.1) and while all REST calls return successfully, I'm always seeing stack traces.

 

{{ java.io.IOException: Stream is closed}}
{{ at com.ibm.ws.http.channel.internal.outbound.HttpOutputStreamImpl.validate(HttpOutputStreamImpl.java:210)}}
{{ at com.ibm.ws.http.channel.internal.outbound.HttpOutputStreamImpl.flush(HttpOutputStreamImpl.java:592)}}
{{ at com.ibm.ws.webcontainer.osgi.response.WCOutputStream.flush(WCOutputStream.java:234)}}
{{ at org.apache.juneau.rest.RestResponse.flushBuffer(RestResponse.java:461)}}
{{ at org.apache.juneau.rest.RestCallHandler.service(RestCallHandler.java:182)}}
{{ at org.apache.juneau.rest.RestCallHandler.service(RestCallHandler.java:129)}}
{{ at org.apache.juneau.rest.RestServlet.service(RestServlet.java:142)}}
{{ at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)}}

 

It looks like the default rest call handler's service method is calling res.flushbuffer() which is throwing an IO exception. For the life of me, I couldn't figure out what was closing the output stream.

 

{{I was wondering if maybe the default 'handleResponse' was somehow closing the response output stream so I made my own RestCallHandler with an Override'd handleResponse which does this:}}

{{try {}}
{{    res.flushBuffer();}}
{{ } catch (IOException e1) {}}
{{    logger.info("***IO ex flush before handle resp.");}}
{{ }}}
{{ try {}}
{{    super.handleResponse(req, res, output);}}
{{} catch (RestException e) {}}
{{    logger.info("***REST ex from handle resp.");}}
{{ } catch (IOException e) {}}
{{    logger.info("***IO ex from handle resp.");}}
{{ }}}
{{ try {}}
{{    res.flushBuffer();}}
{{ } catch (IOException e1) {}}
{{    logger.info("***IO ex flush after handle resp.");}}
{{ }}}

 

and sure enough, I got "***IO ex flush *after* handle resp." in my log.

 

It seems that handleResponse is closing the response output stream. I did a little bit more looking, and I see that DefaultHandler has a 'os.close()' in it.

 

Is this the culprit of my issue? (Or am I going about this wrong).


> RestCallHandlerDefault service method calls handleResponse which seems to close output stream right before it runs res.flushbuffer which throws an IO exception because the stream is closed.
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: JUNEAU-80
>                 URL: https://issues.apache.org/jira/browse/JUNEAU-80
>             Project: Juneau
>          Issue Type: Bug
>          Components: Code
>    Affects Versions: 7.0.1
>         Environment: Red Hat Enterprise Linux Workstation release 6.9 (Santiago)
> WAS Liberty 17.0.0.1, with a CorsFilter web.xml
>            Reporter: Steve Haertel
>            Priority: Major
>              Labels: DefaultHandler, newbie, rest
>             Fix For: 7.0.1
>
>
> If I am doing something wrong, please let me know! Please bear with me. I'm not an expert.
> I am trying to upgrade some REST infrastructure to use Juneau (7.0.1) and while all REST calls return successfully, I'm always seeing stack traces.
>  
> {code:java}
> java.io.IOException: Stream is closed
> at com.ibm.ws.http.channel.internal.outbound.HttpOutputStreamImpl.validate(HttpOutputStreamImpl.java:210)
> at com.ibm.ws.http.channel.internal.outbound.HttpOutputStreamImpl.flush(HttpOutputStreamImpl.java:592)
> at com.ibm.ws.webcontainer.osgi.response.WCOutputStream.flush(WCOutputStream.java:234)
> at org.apache.juneau.rest.RestResponse.flushBuffer(RestResponse.java:461)
> at org.apache.juneau.rest.RestCallHandler.service(RestCallHandler.java:182)
> at org.apache.juneau.rest.RestCallHandler.service(RestCallHandler.java:129)
> at org.apache.juneau.rest.RestServlet.service(RestServlet.java:142)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:668){code}
>  
>  
> It looks like the default rest call handler's service method is calling res.flushbuffer() which is throwing an IO exception. For the life of me, I couldn't figure out what was closing the output stream.
>  
> {{I was wondering if maybe the default 'handleResponse' was somehow closing the response output stream so I made my own RestCallHandler with an Override'd handleResponse which does this:}}
> {code:java}
> try {
> res.flushBuffer();
> } catch (IOException e1) {
> logger.info("***IO ex flush before handle resp.");
> }
> try {
> super.handleResponse(req, res, output);
> } catch (RestException e) {
> logger.info("***REST ex from handle resp.");
> } catch (IOException e) {
> logger.info("***IO ex from handle resp.");
> }
> try {
> res.flushBuffer();
> } catch (IOException e1) {
> logger.info("***IO ex flush after handle resp.");
> }
> {code}
>  
> and sure enough, I got "***IO ex flush *after* handle resp." in my log.
>  
> It seems that handleResponse is closing the response output stream. I did a little bit more looking, and I see that DefaultHandler has a 'os.close()' in it.
>  
> Is this the culprit of my issue? (Or am I going about this wrong).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)