ctubbsii commented on a change in pull request #1077: Updated commons config
from ver 1 to 2
URL: https://github.com/apache/fluo/pull/1077#discussion_r313147029
##########
File path:
modules/api/src/main/java/org/apache/fluo/api/config/SimpleConfiguration.java
##########
@@ -192,34 +195,30 @@ public void load(InputStream in) {
* @since 1.2.0
*/
public void load(File file) {
- try {
- PropertiesConfiguration config = new PropertiesConfiguration();
- // disabled to prevent accumulo classpath value from being shortened
- config.setDelimiterParsingDisabled(true);
- config.load(file);
+ try(InputStream in = Files.newInputStream(file.toPath())) {
+ PropertiesConfiguration config = newPropertiesConfiguration();
+ new FileHandler(config).load(cleanUp(in));
((CompositeConfiguration) internalConfig).addConfiguration(config);
- } catch (ConfigurationException e) {
+ } catch (ConfigurationException | IOException e) {
throw new IllegalArgumentException(e);
}
}
public void save(File file) {
- PropertiesConfiguration pconf = new PropertiesConfiguration();
- pconf.setDelimiterParsingDisabled(true);
- pconf.append(internalConfig);
try {
- pconf.save(file);
+ PropertiesConfiguration pconf = newPropertiesConfiguration();
+ pconf.append(internalConfig);
+ new FileHandler(pconf).save(file);
} catch (ConfigurationException e) {
throw new FluoException(e);
}
}
public void save(OutputStream out) {
- PropertiesConfiguration pconf = new PropertiesConfiguration();
- pconf.setDelimiterParsingDisabled(true);
- pconf.append(internalConfig);
try {
- pconf.save(out);
+ PropertiesConfiguration pconf = newPropertiesConfiguration();
+ pconf.append(internalConfig);
+ new FileHandler(pconf).save(out);
Review comment:
You shouldn't use FileHandler here. You should instead use
PropertiesConfigurationLayout:
```java
StringWriter writer = new StringWriter();
pconf.getLayout().save(pconf, writer);
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services