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

wrong property key: PropertiesBuilderParametersImpl.PROP_IO_FACTORY

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.1.1
    • Component/s: None
    • Labels:
      None

      Description

      Example in user guide about using custom IOFactory doesn't work.

      Link:
      https://commons.apache.org/proper/commons-configuration/userguide/howto_properties.html#Custom_properties_readers_and_writers

      When you set an IOFactory like this:

      params.properties()
      .setFileName("myfile.properties")
      .setIOFactory(new WhitespaceIOFactory())

      this custom IOFactory won't be set in your PropertiesConfiguration because
      the constant PropertiesBuilderParametersImpl.PROP_IO_FACTORY has the value:
      "iOFactory".

      FileBasedConfigurationBuilder tries to set the property "iOFactory" of PropertiesConfiguration .
      The method setiOFactory() exists not.

      I have found a workaround, maybe this can explain better the problem:

      //New subclass:
      public class PropertiesConfigurationOk extends PropertiesConfiguration {
      public void setiOFactory(IOFactory ioFactory)

      { super.setIOFactory(ioFactory); }

      }

      //Usage of new subclass:
      FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfigurationOk.class) .configure(propertiesBuilderParameters);

      PropertiesConfiguration config = builder.getConfiguration();

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              vargattila Attila Varga
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: