[jira] [Commented] (CAMEL-12510) Camel servlet component throw "IOException: Stream closed" during route processing for HTTP get request with custom processor

2018-08-06 Thread Claus Ibsen (JIRA)


[ 
https://issues.apache.org/jira/browse/CAMEL-12510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16570252#comment-16570252
 ] 

Claus Ibsen commented on CAMEL-12510:
-

No the OUT header is not a valid, as then you need to copy over other stuff, 
like its body and whatnot. Use getMessage is better.

> Camel servlet component throw "IOException: Stream closed" during route 
> processing for HTTP get request with custom processor
> -
>
> Key: CAMEL-12510
> URL: https://issues.apache.org/jira/browse/CAMEL-12510
> Project: Camel
>  Issue Type: Bug
>  Components: camel-servlet
>Affects Versions: 2.21.0
>Reporter: Thomas Papke
>Priority: Major
>
> If i just build a simple Route like this to proxy a incoming Get request to 
> external host:
> {code:java}
>     @Override
>     public void configure() throws Exception {
>     from(format("servlet://%s?httpMethodRestrict=GET=%s", 
> RETRIEVE_PATH, servletName))
>     .process((exchange) -> {
>     exchange.getOut().setHeader(Exchange.HTTP_URI, 
> "https://some.external.system/;);
>     }).to("https4:something");
>     }
> {code}
> The following exception is thrown:
> {code:java}
> org.apache.camel.RuntimeCamelException: java.io.IOException: Stream closed
>   at 
> org.apache.camel.http.common.HttpMessage.createBody(HttpMessage.java:80)
>   at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:54)
>   at 
> org.apache.camel.processor.DefaultExchangeFormatter.getBodyTypeAsString(DefaultExchangeFormatter.java:468)
>   at 
> org.apache.camel.processor.DefaultExchangeFormatter.format(DefaultExchangeFormatter.java:126)
>   at 
> org.apache.camel.processor.CamelLogProcessor.process(CamelLogProcessor.java:88)
>   at 
> org.apache.camel.component.log.LogProducer.process(LogProducer.java:40)
>   at 
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
>   at 
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
>   at 
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
>   at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
>   at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>   at 
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
>   at 
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
>   at 
> org.apache.camel.http.common.CamelServlet.doService(CamelServlet.java:208)
>   at 
> org.apache.camel.http.common.CamelServlet.service(CamelServlet.java:78)
>   at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>   at 
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>   at 
> org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:110)
>   at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>   at 
> org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
>   at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>   at 
> org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)
>   at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>   at 
> org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
>   at 
> 

[jira] [Commented] (CAMEL-12510) Camel servlet component throw "IOException: Stream closed" during route processing for HTTP get request with custom processor

2018-05-16 Thread Thomas Papke (JIRA)

[ 
https://issues.apache.org/jira/browse/CAMEL-12510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16476936#comment-16476936
 ] 

Thomas Papke commented on CAMEL-12510:
--

If I rewrite the code (where the "Stream closed" issue occure) from:
{code}
@Override
    public void configure() throws Exception {
    from(format("servlet://%s?httpMethodRestrict=GET=%s", 
RETRIEVE_PATH, servletName))
    .process((exchange) -> {
    exchange.getOut().setHeader(Exchange.HTTP_URI, 
"https://some.external.system/;);
    }).to("http4://oldhost");
    }
{code}

to your suggestion:
{code}
@Override
public void configure() throws Exception {
from(format("servlet://%s?httpMethodRestrict=GET=%s", 
RETRIEVE_PATH, servletName))
.process((exchange) -> {
Message msg = exchange.getMessage();
msg.setHeader(Exchange.HTTP_URI, 
"https://some.external.system/;);
}).to("http4://oldhost");
}
{code}

the behavior also change.
But isn't the first example setting the out header also a valid approach?

> Camel servlet component throw "IOException: Stream closed" during route 
> processing for HTTP get request with custom processor
> -
>
> Key: CAMEL-12510
> URL: https://issues.apache.org/jira/browse/CAMEL-12510
> Project: Camel
>  Issue Type: Bug
>  Components: camel-servlet
>Affects Versions: 2.21.0
>Reporter: Thomas Papke
>Priority: Major
>
> If i just build a simple Route like this to proxy a incoming Get request to 
> external host:
> {code:java}
>     @Override
>     public void configure() throws Exception {
>     from(format("servlet://%s?httpMethodRestrict=GET=%s", 
> RETRIEVE_PATH, servletName))
>     .process((exchange) -> {
>     exchange.getOut().setHeader(Exchange.HTTP_URI, 
> "https://some.external.system/;);
>     }).to("https4:something");
>     }
> {code}
> The following exception is thrown:
> {code:java}
> org.apache.camel.RuntimeCamelException: java.io.IOException: Stream closed
>   at 
> org.apache.camel.http.common.HttpMessage.createBody(HttpMessage.java:80)
>   at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:54)
>   at 
> org.apache.camel.processor.DefaultExchangeFormatter.getBodyTypeAsString(DefaultExchangeFormatter.java:468)
>   at 
> org.apache.camel.processor.DefaultExchangeFormatter.format(DefaultExchangeFormatter.java:126)
>   at 
> org.apache.camel.processor.CamelLogProcessor.process(CamelLogProcessor.java:88)
>   at 
> org.apache.camel.component.log.LogProducer.process(LogProducer.java:40)
>   at 
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
>   at 
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
>   at 
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
>   at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
>   at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>   at 
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
>   at 
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
>   at 
> org.apache.camel.http.common.CamelServlet.doService(CamelServlet.java:208)
>   at 
> org.apache.camel.http.common.CamelServlet.service(CamelServlet.java:78)
>   at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>   at 
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>   at 
> org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:110)
>   at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>   at 
> org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
>   at 
> 

[jira] [Commented] (CAMEL-12510) Camel servlet component throw "IOException: Stream closed" during route processing for HTTP get request with custom processor

2018-05-16 Thread Claus Ibsen (JIRA)

[ 
https://issues.apache.org/jira/browse/CAMEL-12510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16476916#comment-16476916
 ] 

Claus Ibsen commented on CAMEL-12510:
-

 

Try with this in the processor
{code:java}
exchange.getMessage()...{code}

> Camel servlet component throw "IOException: Stream closed" during route 
> processing for HTTP get request with custom processor
> -
>
> Key: CAMEL-12510
> URL: https://issues.apache.org/jira/browse/CAMEL-12510
> Project: Camel
>  Issue Type: Bug
>  Components: camel-servlet
>Affects Versions: 2.21.0
>Reporter: Thomas Papke
>Priority: Major
>
> If i just build a simple Route like this to proxy a incoming Get request to 
> external host:
> {code:java}
>     @Override
>     public void configure() throws Exception {
>     from(format("servlet://%s?httpMethodRestrict=GET=%s", 
> RETRIEVE_PATH, servletName))
>     .process((exchange) -> {
>     exchange.getOut().setHeader(Exchange.HTTP_URI, 
> "https://some.external.system/;);
>     }).to("https4:something");
>     }
> {code}
> The following exception is thrown:
> {code:java}
> org.apache.camel.RuntimeCamelException: java.io.IOException: Stream closed
>   at 
> org.apache.camel.http.common.HttpMessage.createBody(HttpMessage.java:80)
>   at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:54)
>   at 
> org.apache.camel.processor.DefaultExchangeFormatter.getBodyTypeAsString(DefaultExchangeFormatter.java:468)
>   at 
> org.apache.camel.processor.DefaultExchangeFormatter.format(DefaultExchangeFormatter.java:126)
>   at 
> org.apache.camel.processor.CamelLogProcessor.process(CamelLogProcessor.java:88)
>   at 
> org.apache.camel.component.log.LogProducer.process(LogProducer.java:40)
>   at 
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
>   at 
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
>   at 
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
>   at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
>   at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
>   at 
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
>   at 
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
>   at 
> org.apache.camel.http.common.CamelServlet.doService(CamelServlet.java:208)
>   at 
> org.apache.camel.http.common.CamelServlet.service(CamelServlet.java:78)
>   at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>   at 
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>   at 
> org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:110)
>   at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>   at 
> org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
>   at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>   at 
> org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)
>   at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
>   at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
>   at 
> org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
>   at 
>