Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-55

[configuration] Interpolation with multivalued keys returns nested strings instead of flattend string and interpolate doesn't work with all getters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 1.1
    • None
    • None
    • None
    • Operating System: other
      Platform: Other

    • 36819

    Description

      I tried these properties with Configuration 1.1 stable (a
      PropertiesConfiguration in a CompositeConfiguration, but that shouldn't matter)

      z=1,2,3,${x},7,8
      x=4,${y}
      y=5,6

      If queried using getStringArray("z") etc. this results in:
      e.g. something like

      String[] z = config.getStringArray("z");
      for (int i = 0; i < z.length; i++) {
      System.out.println(z[i].toString());
      }

      1
      2
      3
      [4, [5, 6]]
      7
      8

      Note brackets and nesting!
      I guess it would be better to flatten such multivalued keys without
      brackets,commas and spaces e.g. the result should look like (note: this is
      already formated a bit)
      x = 4,5,6
      y = 5,6
      z = 1,2,3,4,5,6,7,8

      Also note that commons-configuration-src-20050926.zip nightly build behaves
      different, here the result was (also preformated):

      x = [4, 5]
      y = [5, 6]
      z = [1, 2, 3, 4, 7, 8]

      Looks as if only the first value is taken when interpolating...

      Besides interpolate should get called for each getter.
      a = ${b}
      b = 5

      One would expect config.getInt("a") == 5 instead of throwing an exception
      because ${b} is no valid int. Of course, you can workaround by using
      .getString("a") and converting manually, but this defeats the added value of all
      different getters.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mech@tngtech.com Michael Echerer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: