优化updateEnvironmentProperty方法

This commit is contained in:
Redkale
2022-11-29 21:13:08 +08:00
parent 6ab8aa8e72
commit af92ac4048

View File

@@ -1720,20 +1720,28 @@ public final class Application {
} else if (key.startsWith("mimetype.property.")) { } else if (key.startsWith("mimetype.property.")) {
MimeType.add(key.substring("mimetype.property.".length()), val); MimeType.add(key.substring("mimetype.property.".length()), val);
} else if (key.startsWith("property.")) { } else if (key.startsWith("property.")) {
Object old = resourceFactory.find(key, String.class);
if (!Objects.equals(val, old)) {
envProperties.put(key, val);
if (changeCache == null) { if (changeCache == null) {
resourceFactory.register(key, val); resourceFactory.register(key, val);
} else { } else {
changeCache.put(key, val); changeCache.put(key, val);
} }
}
} else { } else {
if (key.startsWith("redkale.")) { if (key.startsWith("redkale.")) {
throw new RuntimeException("property " + key + " cannot redkale. startsWith"); throw new RuntimeException("property " + key + " cannot redkale. startsWith");
} }
String newkey = "property." + key;
Object old = resourceFactory.find(newkey, String.class);
if (!Objects.equals(val, old)) {
envProperties.put(key, val); envProperties.put(key, val);
if (changeCache == null) { if (changeCache == null) {
resourceFactory.register("property." + key, val); resourceFactory.register(newkey, val);
} else { } else {
changeCache.put("property." + key, val); changeCache.put(newkey, val);
}
} }
} }
} }