You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Kamil (JIRA)" <ji...@apache.org> on 2019/05/17 10:08:00 UTC

[jira] [Commented] (CAMEL-13536) StackOverflow when using bean(this)

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

Kamil commented on CAMEL-13536:
-------------------------------

[~davsclaus], could you please paste a short example of what do you mean by "have the method added to the route builder instance itself"

> StackOverflow when using bean(this)
> -----------------------------------
>
>                 Key: CAMEL-13536
>                 URL: https://issues.apache.org/jira/browse/CAMEL-13536
>             Project: Camel
>          Issue Type: Bug
>          Components: came-core, camel-test, tests
>    Affects Versions: 2.24.0
>            Reporter: Kamil
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 3.0.0, 3.0.0-M3, 2.23.3, 2.22.5, 2.24.1, 2.25.0
>
>
> This testcase
> {code:java}
> import org.apache.camel.CamelContext;
> import org.apache.camel.Exchange;
> import org.apache.camel.RoutesBuilder;
> import org.apache.camel.builder.AdviceWithRouteBuilder;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.component.mock.MockEndpoint;
> import org.apache.camel.test.junit4.CamelTestSupport;
> import org.junit.Test;
> public class MyRouteTest extends CamelTestSupport {
> private static final String ROUTE_ID = "mytest";
> @Override
> protected RoutesBuilder createRouteBuilder() throws Exception {
>   return new RouteBuilder() {
>     @Override
>     public void configure() throws Exception {
>       from("direct:mytest")
>       .id(ROUTE_ID)
>       .bean(this, "hello", false) // <- here is the problem
>       .to("stream:out");
>     }
>     public void hello(final Exchange exchange) {
>     }
>   };
> }
> @Override
> public void setUp() throws Exception {
>   super.setUp();
>   final CamelContext camelContext = context();
>   camelContext.getRouteDefinition(ROUTE_ID)
>     .adviceWith(camelContext, new AdviceWithRouteBuilder() {
>     @Override
>     public void configure() throws Exception {
>       weaveAddLast().to("mock:extract");
>     }
>   });
> }
> @Override
> public boolean isUseAdviceWith() {
>   return true;
> }
> @Test
> public void shouldFire() throws InterruptedException {
>   // given
>   final MockEndpoint myMock = getMockEndpoint("mock:extract");
>   myMock.expectedMessageCount(1);
>   // when
>   template.sendBody("direct:mytest", "test");
>   // then
>   myMock.assertIsSatisfied();
> }
> }
> {code}
> Throws
> {code:java}
> java.lang.StackOverflowError
> at java.util.AbstractCollection.toString(Unknown Source)
> at java.lang.String.valueOf(Unknown Source)
> at java.lang.StringBuilder.append(Unknown Source)
> at org.apache.camel.model.RoutesDefinition.toString(RoutesDefinition.java:64)
> at org.apache.camel.builder.RouteBuilder.toString(RouteBuilder.java:74)
> at org.apache.camel.model.BeanDefinition.description(BeanDefinition.java:89)
> at org.apache.camel.model.BeanDefinition.toString(BeanDefinition.java:78)
> at java.lang.String.valueOf(Unknown Source)
> {code}
>  



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