Skip to content

Commit

Permalink
Corretto problema nella lettura dei gruppi di properties da file este…
Browse files Browse the repository at this point in the history
…rno.
  • Loading branch information
pintorig committed Mar 1, 2021
1 parent 75f8010 commit df553b4
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions jars/core/src/main/java/it/govpay/core/utils/GovpayConfig.java
Expand Up @@ -575,24 +575,30 @@ public void readProperties() throws Exception {

private static Map<String,String> getProperties(String baseName, Properties[] props, boolean required, Logger log) throws Exception {
Map<String, String> valori = new HashMap<>();
String value = null;

List<String> nomiProperties = new ArrayList<String>();
// 1. collezionare tutti i nomi di properties da leggere (possono essere definiti in piu' file)
for(int i=0; i<props.length; i++) {
if(props[i] != null) {
for (Object nameObj : props[i].keySet()) {
String name = (String) nameObj;
if(name.startsWith(baseName)) {
String key = name.substring(baseName.length());
try { value = getProperty(name, props[i], required, i==1, log); } catch (Exception e) { }
if(value != null && !value.trim().isEmpty()) {
if(!valori.containsKey(key)) {
valori.put(key, value);
}
}
if(name.startsWith(baseName) && !nomiProperties.contains(name)) {
nomiProperties.add(name);
}
}
}
}

// 2. leggere la property singola
for (String nomeProprieta : nomiProperties) {
String valoreProprieta = getProperty(nomeProprieta, props, required, log);

if (valoreProprieta != null) {
String key = nomeProprieta.substring(baseName.length());
valori.put(key, valoreProprieta);
}
}

return valori;
}

Expand Down

0 comments on commit df553b4

Please sign in to comment.