diff --git a/main/pom.xml b/main/pom.xml
index 4e88805..dc11fa9 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -9,10 +9,8 @@
butterfly-container
1.2.7-SNAPSHOT
-
- org.openrefine.dependencies
+
butterfly
- 1.2.7-SNAPSHOT
SIMILE Butterfly Engine
https://github.com/OpenRefine/simile-butterfly/
@@ -81,9 +79,14 @@
- commons-collections
- commons-collections
- 3.2.2
+ org.apache.commons
+ commons-collections4
+ 4.4
+
+
+ org.apache.commons
+ commons-configuration2
+ 2.10.1
commons-io
diff --git a/main/src/edu/mit/simile/butterfly/Butterfly.java b/main/src/edu/mit/simile/butterfly/Butterfly.java
index e6ff843..390b1c2 100644
--- a/main/src/edu/mit/simile/butterfly/Butterfly.java
+++ b/main/src/edu/mit/simile/butterfly/Butterfly.java
@@ -36,7 +36,11 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.collections.ExtendedProperties;
+import org.apache.commons.configuration2.AbstractConfiguration;
+import org.apache.commons.configuration2.CombinedConfiguration;
+import org.apache.commons.configuration2.PropertiesConfiguration;
+import org.apache.commons.configuration2.ex.ConfigurationException;
+import org.apache.commons.configuration2.tree.OverrideCombiner;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.RuntimeConstants;
import org.mozilla.javascript.Context;
@@ -156,7 +160,7 @@ public static boolean isGAE(ServletConfig config) {
transient protected ServletContext _context;
transient protected ButterflyMounter _mounter;
- protected ExtendedProperties _properties;
+ protected PropertiesConfiguration _properties;
protected File _contextDir;
protected File _homeDir;
protected File _webInfDir;
@@ -188,27 +192,17 @@ public void init(ServletConfig config) throws ServletException {
_contextDir = new File(_context.getRealPath("/"));
_webInfDir = new File(_contextDir, "WEB-INF");
- _properties = new ExtendedProperties();
+ _properties = new PropertiesConfiguration();
_mounter = new ButterflyMounter();
// Load the butterfly properties
String props = System.getProperty("butterfly.properties");
File butterflyProperties = (props == null) ? new File(_webInfDir, "butterfly.properties") : new File(props);
- BufferedInputStream is = null;
- try {
- is = new BufferedInputStream(new FileInputStream(butterflyProperties));
- _properties.load(is);
- } catch (FileNotFoundException e) {
+ try (BufferedInputStream is = new BufferedInputStream(Files.newInputStream(butterflyProperties.toPath()))){
+ _properties.read(new InputStreamReader(is, StandardCharsets.UTF_8));
+ } catch (IOException|ConfigurationException e) {
throw new ServletException("Could not find butterfly properties file",e);
- } catch (IOException e) {
- throw new ServletException("Could not read butterfly properties file",e);
- } finally {
- try {
- is.close();
- } catch (Exception e) {
- // ignore
- }
}
// Process eventual properties includes
@@ -216,27 +210,20 @@ public void init(ServletConfig config) throws ServletException {
if (includes != null) {
for (String prop : includes.split(",")) {
File prop_file = (prop.startsWith("/")) ? new File(prop) : new File(_webInfDir, prop);
- try {
- is = new BufferedInputStream(new FileInputStream(prop_file));
- ExtendedProperties p = new ExtendedProperties();
- p.load(is);
- _properties.combine(p);
- } catch (Exception e) {
- // ignore
- } finally {
- try {
- is.close();
- } catch (Exception e) {
- // ignore
- }
+ try (BufferedInputStream is = new BufferedInputStream(Files.newInputStream(prop_file.toPath()))){
+ PropertiesConfiguration p = new PropertiesConfiguration();
+ p.read(new InputStreamReader(is, StandardCharsets.UTF_8));
+ _properties.append(p);
+ } catch (ConfigurationException | IOException e) {
+ _logger.warn("Error loading included properties file: " + prop_file, e);
}
}
}
// Overload with properties set from the command line
// using the -Dkey=value parameters to the JVM
Properties systemProperties = System.getProperties();
- for (Iterator