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

FileConfiguration getFile(), getFileName(), getBasePath() are not always consistent

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.3
    • 1.5
    • None
    • None

    Description

      Taken from the maillinglist:

      > I have a properties configuration which is loaded without a problem.
      > Later in my application I will access the file which is aligned to
      > this configuration.
      >
      >
      >
      > final IFileConfiguration _productConf =
      > _conf.getProductConfigurations().get(_productId);
      >
      > log.debug("product conf file " + _productConf.getFile());
      >
      > log.debug("product conf filename " + _productConf.getFileName());
      >
      > log.debug("product conf base path " + _productConf.getBasePath());
      >
      >
      >
      > The methods _productConf.getFile() and _productConf.getFileName()
      > returning null but the getBasePath() returns a path which is correct
      > (like file:/C:/Projects/workspace/myProject/project.properties). Seems
      > for me like a bug because the PropertiesConfiguration is loaded
      > correct and works.
      >
      >
      >
      > By side: I have also set a file reloading strategy for this
      > configuration.
      >
      >
      >
      > Any ideas what's happen in this case or where I can find the problem?
      > It would be nicer to get the File() instead the BasePath which has to
      > be converted into a URL before I can access the whole properties file.
      >
      >
      >
      > Thanks in advance,
      >
      >
      >
      > - Thomas Wabner
      >
      >
      Thomas,

      you are right, the conversions between a base path, a file name, and a File are not always consistent. How did you load the configuration (this determines, which internal fields are set)?

      I would recommend to work with URLs, i.e. the method getURL(). A file-based configuration's URL is always defined.

      If you like, you can open a Jira ticket for this problem.

      Thanks.
      Oliver

      The file is loaded in this way:

      _productConf = new ProductConfiguration();
      _productConf.load(FileTools.getPathForList(_propductPathList).getPath());

      means the load method gets an String and not an File.

      Attachments

        Activity

          People

            oheger Oliver Heger
            waffel Thomas Wabner
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: