9 Replies Latest reply on Feb 22, 2014 1:04 AM by yvrprasad

    StackOverflowError in camel-sql-binding quickstart

    igarashitm

      It just disappeared from my workspace, so post a reminder for next time. I and David saw this infinite loop in camel-sql-binding quickstart today, but is not 100% reproducible.

      java.lang.StackOverflowError

              at org.switchyard.test.MockHandler.waitFor(MockHandler.java:169)

              at org.switchyard.test.MockHandler.waitForOKMessage(MockHandler.java:149)

              at org.switchyard.quickstarts.camel.sql.CamelSqlRetrieveTest.getContents(CamelSqlRetrieveTest.java:68)

              at org.switchyard.quickstarts.camel.sql.CamelSqlRetrieveTest.getContents(CamelSqlRetrieveTest.java:76)

              at org.switchyard.quickstarts.camel.sql.CamelSqlRetrieveTest.getContents(CamelSqlRetrieveTest.java:76)

              at org.switchyard.quickstarts.camel.sql.CamelSqlRetrieveTest.getContents(CamelSqlRetrieveTest.java:76)

              at org.switchyard.quickstarts.camel.sql.CamelSqlRetrieveTest.getContents(CamelSqlRetrieveTest.java:76)

              at org.switchyard.quickstarts.camel.sql.CamelSqlRetrieveTest.getContents(CamelSqlRetrieveTest.java:76)

              ........

        • 1. Re: StackOverflowError in camel-sql-binding quickstart
          dward

          Yup.  Here's the top of the test.  It's not 100%, but it seems like:

           

          1. cd quickstarts/ ; mvn clean install = ERROR

          2. cd quickstarts/camel-sql-binding/ ; mvn clean install = NO ERROR

          3. cd quickstarts; mvn clean install -DskipTests=true ; mvn test = NO ERROR

           

          1. -------------------------------------------------------------------------------
          2. Test set: org.switchyard.quickstarts.camel.sql.CamelSqlRetrieveTest
          3. -------------------------------------------------------------------------------
          4. Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.913 sec <<< FAILURE!
          5. shouldRetrieveGreetings(org.switchyard.quickstarts.camel.sql.CamelSqlRetrieveTest)  Time elapsed: 0.148 sec  <<< ERROR!
          6. java.lang.StackOverflowError
          7.     at java.util.concurrent.LinkedBlockingQueue.size(LinkedBlockingQueue.java:260)
          8.     at org.switchyard.test.MockHandler.waitFor(MockHandler.java:172)
          9.     at org.switchyard.test.MockHandler.waitForOKMessage(MockHandler.java:149)
          10.     at org.switchyard.quickstarts.camel.sql.CamelSqlRetrieveTest.getContents(CamelSqlRetrieveTest.java:68)
          11.     at org.switchyard.quickstarts.camel.sql.CamelSqlRetrieveTest.getContents(CamelSqlRetrieveTest.java:76)
          12.     at org.switchyard.quickstarts.camel.sql.CamelSqlRetrieveTest.getContents(CamelSqlRetrieveTest.java:76)
          • 2. Re: StackOverflowError in camel-sql-binding quickstart
            mageshbk

            Well I had the same issue too. Thought that it could be a *Windows only* issue so kept quite. Here is what I do to solve it:

             

            If I change the test like this it goes through

                private List<Greeting> getContents(MockHandler handler) {
                    handler.waitForOKMessage();
                    List<Greeting> greetings = new ArrayList<Greeting>();
                    for (Exchange exchange : handler.getMessages()) {
                        Greeting[] content = exchange.getMessage().getContent(Greeting[].class);
                        if (content != null) {
                            greetings.addAll(Arrays.asList(content));
                        }
                        try {
                            Thread.sleep(100);
                        }
                        catch (InterruptedException ie) {
                            // Ignore
                        }
                    }
                    return greetings.size() == 0 ? getContents(handler) : greetings;
                }
            
            

             

            Magesh

            • 3. Re: StackOverflowError in camel-sql-binding quickstart
              dward

              Magesh, would you mind submitting a pull request to fix it?

              • 4. Re: StackOverflowError in camel-sql-binding quickstart
                dward

                Actually, I see you're offline. Nevermind then, I'll submit one.

                • 5. Re: StackOverflowError in camel-sql-binding quickstart
                  dward
                  • 6. Re: StackOverflowError in camel-sql-binding quickstart
                    splatch

                    Hey,

                    It's my fault. Hows about setting waitTimeout in MockHandler to 1000 ms?

                     

                    Cheers,

                    Lukasz

                    • 7. Re: StackOverflowError in camel-sql-binding quickstart
                      dward
                      1. I'm having a hard time seeing how a race condition causes a stack overflow error...
                      2. Would changing the waitTimeout in MockHandler be effectively the same thing as introducting a wait in the test per Magesh's fix?
                      3. Can we envision any other fix that doesn't depend on an arbitrary wait, so it is dependable?
                      • 8. Re: StackOverflowError in camel-sql-binding quickstart
                        splatch

                        David,

                        The retrieve binding has 1 second initial delay and poll database every second. I think 2-4 second for wait timeout should be ok, however first poll may return empty result. That's why test code waits untill something is returned by SQL query.

                        • 9. Re: StackOverflowError in camel-sql-binding quickstart
                          yvrprasad

                          Not able to test/run this quickstart: camel-sql-binding

                          Tried Magesh's fix - Did not work

                          Tried mvn -Dmaven.test.skip=true jboss-as:deploy - Did not work


                          [ERROR] Failed to execute goal org.jboss.as.plugins:jboss-as-maven-plugin:7.5.Final:deploy (default-cli) on project switchyard-camel-sql-binding: Deployment failed and was rolled back. -> [Help 1]