Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-7582

Python scripts with multiple statements return null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.13.0
    • 2.14.0
    • camel-language
    • None
    • Unknown

    Description

      As reported here:
      http://camel.465427.n5.nabble.com/Return-Value-from-Python-Script-Not-In-Message-Body-tt5724056.html#none

      It seems that when calling python script that has more than a single statement the return value from the script is null. Here is a simple example in groovy that shows this:

      package com.im.examples
      
      import org.apache.camel.*
      import org.apache.camel.impl.*
      import org.apache.camel.builder.*
      
      String script = URLEncoder.encode('"Hello world!"', "UTF-8") // this works - script returns "Hello world!"
      //String script = URLEncoder.encode('bar = "baz"; "Hello world!"', "UTF-8") // this fails - script returns null
      
      CamelContext camelContext = new DefaultCamelContext()
      camelContext.addRoutes(new RouteBuilder() {
              def void configure() {
                  from("direct:python")
                  .to("language:python:" + script)
              }
          }
      )
      
      camelContext.start()
      
      ProducerTemplate t = camelContext.createProducerTemplate()
      def result = t.requestBody('direct:python', 'foo')
      println result
      
      camelContext.stop()
      

      Attachments

        Activity

          People

            njiang Willem Jiang
            tdudgeon Tim Dudgeon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: