Skip to content
Snippets Groups Projects
Commit 06fafbe2 authored by felmer's avatar felmer
Browse files

Not loading properties file with Properties.load() method in order to avoid...

Not loading properties file with Properties.load() method in order to avoid property values like 'E:\users\Johan' to be interpreted as Unicode escape sequences.

SVN: 14252
parent 84baae7e
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,7 @@ import org.apache.commons.io.IOUtils; ...@@ -30,6 +30,7 @@ import org.apache.commons.io.IOUtils;
import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel; import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel;
import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException;
import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.common.filesystem.FileUtilities;
import ch.systemsx.cisd.common.utilities.ITimeProvider; import ch.systemsx.cisd.common.utilities.ITimeProvider;
import ch.systemsx.cisd.common.utilities.PropertyUtils; import ch.systemsx.cisd.common.utilities.PropertyUtils;
import ch.systemsx.cisd.common.utilities.SystemTimeProvider; import ch.systemsx.cisd.common.utilities.SystemTimeProvider;
...@@ -157,7 +158,6 @@ public class DataSetInfoExtractorForMSInjection implements IDataSetInfoExtractor ...@@ -157,7 +158,6 @@ public class DataSetInfoExtractorForMSInjection implements IDataSetInfoExtractor
private Properties loadMSInjectionProperties(File incomingDataSetDirectory) private Properties loadMSInjectionProperties(File incomingDataSetDirectory)
{ {
Properties msInjectionProperties = new Properties();
File msInjectionPropertiesFile = File msInjectionPropertiesFile =
new File(incomingDataSetDirectory, msInjectionPropertiesFileName); new File(incomingDataSetDirectory, msInjectionPropertiesFileName);
if (msInjectionPropertiesFile.exists() == false) if (msInjectionPropertiesFile.exists() == false)
...@@ -170,18 +170,31 @@ public class DataSetInfoExtractorForMSInjection implements IDataSetInfoExtractor ...@@ -170,18 +170,31 @@ public class DataSetInfoExtractorForMSInjection implements IDataSetInfoExtractor
throw new UserFailureException("Properties file '" + msInjectionPropertiesFileName throw new UserFailureException("Properties file '" + msInjectionPropertiesFileName
+ "' is a folder."); + "' is a folder.");
} }
FileInputStream stream = null; return loadPropertiesFile(msInjectionPropertiesFile);
try }
{
stream = new FileInputStream(msInjectionPropertiesFile); private Properties loadPropertiesFile(File msInjectionPropertiesFile)
msInjectionProperties.load(stream); {
} catch (IOException ex) Properties properties = new Properties();
{ List<String> lines = FileUtilities.loadToStringList(msInjectionPropertiesFile);
throw CheckedExceptionTunnel.wrapIfNecessary(ex); for (int i = 0; i < lines.size(); i++)
} finally
{ {
IOUtils.closeQuietly(stream); String line = lines.get(i);
if (line.length() == 0 || line.startsWith("#"))
{
continue;
}
int indexOfEqualSymbol = line.indexOf('=');
if (indexOfEqualSymbol < 0)
{
throw new UserFailureException("Missing '=' in line " + (i + 1)
+ " of MS injection properties file " + msInjectionPropertiesFileName
+ ": " + line);
}
String key = line.substring(0, indexOfEqualSymbol).trim();
String value = line.substring(indexOfEqualSymbol + 1).trim();
properties.setProperty(key, value);
} }
return msInjectionProperties; return properties;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment