[CONTROLLER-1758] Class FileModuleShardConfigProvider does not load configurations from classpath properly Created: 25/Aug/17 Updated: 25/Jul/23 Resolved: 04/Sep/17 |
|
| Status: | Resolved |
| Project: | controller |
| Component/s: | mdsal |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Samuel Kontris | Assignee: | Jakub Toth |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| External issue ID: | 9056 |
| Description |
|
Loading configurations from classpath in class FileModuleShardConfigProvider [1] does not work properly, because it tries to read from file name instead of file path. This is code that read configs: Config moduleShardsConfig = null; Config modulesConfig = null; if (modulesFile.exists()) { LOG.info("modules config file exists - reading config from it"); modulesConfig = ConfigFactory.parseFile(modulesFile); } else { LOG.warn("modules configuration read from resource"); modulesConfig = ConfigFactory.load(modulesFile.getName()); // <------------------- } And it should look something like this: Config moduleShardsConfig = null; if (moduleShardsFile.exists()) { LOG.info("module shards config file exists - reading config from it"); moduleShardsConfig = ConfigFactory.parseFile(moduleShardsFile); } else { LOG.warn("module shards configuration read from resource"); final String path = moduleShardsFile.getPath().replace("\\", "/"); // in case of windows OS moduleShardsConfig = ConfigFactory.load(path); } Config modulesConfig = null; else { LOG.warn("modules configuration read from resource"); final String path = modulesFile.getPath().replace("\\", "/"); // in case of windows OS modulesConfig = ConfigFactory.load(path); }[1] - org.opendaylight.controller.cluster.datastore.config.FileModuleShardConfigProvider |
| Comments |
| Comment by Jakub Toth [ 30/Aug/17 ] |
|
In this way, we don't need to use replace method on getPath() because the resulting string uses the system-dependent default name-separator character to separate the names. This field is initialized to contain the first character of the value of the system property file.separator. On UNIX systems the value of this field is '/'; on Microsoft Windows systems it is ' |
| Comment by Juraj Veverka [ 04/Sep/17 ] |
|
(In reply to Jakub Toth from comment #1) this is true, but in this case is file path used as classpath and on systems with File.separator != '/' this code will never work. moduleShardsConfig = ConfigFactory.load(moduleShardsConfigPath); original strings are private members of FileModuleShardConfigProvider class. |
| Comment by Jakub Toth [ 04/Sep/17 ] |