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

camel-sql - Repeated parameters in URI are not treated correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.20.1
    • 3.0.0.RC1, 3.0.0
    • camel-sql
    • None
    • Unknown

    Description

      When constructing Camel SQL component with the following URI:

      sql:INSERT INTO TABLE ....?batch=true&...&batch=true

      Resulting camel endpoint ends up with batch == false. The reason for this is found in 

      private static void addParameter // this is in UriSupport.java

      This method adds values into a list and then setting the parameter does not work correctly. I believe that Camel should be more linient for such "errors" (which can occur if you construct URI programatically). 

      I suggest parameter value detection. If

      existing.equals(value) // to use actual names of variables from the code

      then just ignore. DO NOT do the following (list construction; current behavior):

      if (existing instanceof List) {
          list = CastUtils.cast((List<?>) existing);
      } else {
          // create a new list to hold the multiple values
          list = new ArrayList<String>();
          String s = existing != null ? existing.toString() : null;
          if (s != null) {
              list.add(s);
          }
      }
      list.add(value);
      

      In the end the URI shown in the beginning will result in Component with batch equal to false. Which is really hard to determine why and what happened. 

       

      I believe this is a generic problem tho

      Attachments

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              Kosta K Kosta Kostelnik
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m