Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-130

[configuration] FileConfiguration - Save problem when embedded spaces are in the path

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: PC

      Description

      Actual path to file:
      C:/Documents and Settings/chrisw/IdeaProjects/sptech-as400-
      cmretention/classes/com/sptech/CMRetention/configuration.xml

      The configuration file is read correctly without a problem.

      The save operation creates the following directory structure and file:
      C:/Documents%20and%20Settings/chrisw/IdeaProjects/sptech-as400-
      cmretention/classes/com/sptech/CMRetention/configuration.xml

      Here is the code that I was using:

      try

      { URL f = getClass().getResource("cmretention.xml"); XMLConfiguration xml = new XMLConfiguration(f); System.out.println(xml.getString("login.user")); xml.setAutoSave(true); xml.setProperty("login.server",server); xml.setProperty("login.user", user); xml.setProperty("login.password", password); xml.setProperty("paths.library", library); xml.save(); }

      catch (ConfigurationException e)

      { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. }

        Activity

        Hide
        Oliver Heger added a comment -

        Fixed in SVN by adding a URLDecoder.decode() call to
        ConfigurationUtils.fileFromURL().

        Show
        Oliver Heger added a comment - Fixed in SVN by adding a URLDecoder.decode() call to ConfigurationUtils.fileFromURL().
        Hide
        Oliver Heger added a comment -

        The problem not only occurs with XMLConfiguration, but with all file based
        configurations. Cause is the method fileFromURL() in ConfigurationUtils, which
        uses url.getPath() to transform a URL into a File object. Obviously this method
        performs no decoding if the URL is application/x-www-form-urlencoded.

        Show
        Oliver Heger added a comment - The problem not only occurs with XMLConfiguration, but with all file based configurations. Cause is the method fileFromURL() in ConfigurationUtils, which uses url.getPath() to transform a URL into a File object. Obviously this method performs no decoding if the URL is application/x-www-form-urlencoded.

          People

          • Assignee:
            Unassigned
            Reporter:
            Chris Winterscheid
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development