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

properties binding: issues binding to map when the key contains a dot

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 3.7.0
    • came-core
    • None
    • Unknown

    Description

      I'm trying to bind some properties to an object that has a filed of type Map<String, Object> and it looks like that when the keys for the map contain a dot, the the mapping fails.

      As example:

       Map<String, Object> properties = mapOf(
          "resources[0].name", "knative3",
          "resources[0].type", "endpoint",
          "resources[0].metadata[knative.apiVersion]", "serving.knative.dev/v1",
          "resources[0].metadata[knative.kind]", "Service",
      );
      
      CamelContext context = new DefaultCamelContext();
      KnativeEnvironment env = KnativeEnvironment.mandatoryLoadFromProperties(context, properties);
      List<KnativeResource> res = env.lookup(Knative.Type.endpoint, "knative3").collect(Collectors.toList());
      
      assertThat(res).hasSize(1);
      assertThat(res).first().satisfies(resource  -> {
          assertThat(resource.getName()).isEqualTo("knative3");
          assertThat(resource.getMetadata()).isNotEmpty();
      });
      

      This code fails as resource.getMetadata() return an empty map, if the properties are then changed to:

       Map<String, Object> properties = mapOf(
          "resources[0].name", "knative3",
          "resources[0].type", "endpoint",
          "resources[0].metadata[knative_apiVersion]", "serving.knative.dev/v1",
          "resources[0].metadata[knative_kind]", "Service",
      );
      

      Then the test succeeds.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            lb Luca Burgazzoli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: