Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit 6d575903 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

do not include a file multiple times

parent 2cf0fcc3
...@@ -5,6 +5,7 @@ import org.jetbrains.annotations.NotNull; ...@@ -5,6 +5,7 @@ import org.jetbrains.annotations.NotNull;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Properties; import java.util.Properties;
...@@ -18,13 +19,16 @@ public class ModuleResourceBundle extends ResourceBundle { ...@@ -18,13 +19,16 @@ public class ModuleResourceBundle extends ResourceBundle {
protected static final Control CONTROL = new MultiResourceBundleControl(); protected static final Control CONTROL = new MultiResourceBundleControl();
private Properties properties; private Properties properties;
private HashSet<String> usedProperties;
public ModuleResourceBundle(String baseName, Locale locale){ public ModuleResourceBundle(String baseName, Locale locale){
setParent(ResourceBundle.getBundle(baseName, locale, CONTROL)); setParent(ResourceBundle.getBundle(baseName, locale, CONTROL));
} }
protected ModuleResourceBundle(Properties properties){ protected ModuleResourceBundle(Properties properties, HashSet<String> usedProperties){
this.properties = properties; this.properties = properties;
this.usedProperties = usedProperties;
} }
@Override @Override
...@@ -70,12 +74,15 @@ public class ModuleResourceBundle extends ResourceBundle { ...@@ -70,12 +74,15 @@ public class ModuleResourceBundle extends ResourceBundle {
Properties properties = load(baseName, locale, loader); Properties properties = load(baseName, locale, loader);
String include = properties.getProperty("include"); String include = properties.getProperty("include");
HashSet<String> usedProperties = new HashSet<>();
if (include != null){ if (include != null){
for (String includeBasename : include.split("\\s*,\\s*")){ for (String includeBasename : include.split("\\s*,\\s*")){
properties.putAll(load(includeBasename, locale, loader)); if (usedProperties.add(includeBasename)){
properties.putAll(load(includeBasename, locale, loader));
}
} }
} }
return new ModuleResourceBundle(properties); return new ModuleResourceBundle(properties, usedProperties);
} }
private Properties load(String baseName, Locale locale, ClassLoader loader) throws IOException { private Properties load(String baseName, Locale locale, ClassLoader loader) throws IOException {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment