diff --git a/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java b/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java index d84c4f29b..9ba18fa8c 100644 --- a/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java +++ b/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java @@ -10,13 +10,12 @@ import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.util.Properties; +import java.util.Set; /** - * Class to change JVM system properties according to an external properties file + * Class to overwrite system properties with an external properties file *
- * The app starts with a set of predefined properties (defined in [APPDIR]/../Cryptomator.cfg). - * That file is difficult to edit and edits do not persist over updates. - * To allow overwriting these properties, the method {@link #adjustSystemProperties()} loads the properties file {@value PROP_FILENAME} from an OS-dependent location and add the contained properties to the {@link System} properties. + * To overwrite system properties, the method {@link #adjustSystemProperties()} loads the properties file {@value PROP_FILENAME} from an OS-dependent location and add all supported properties to the {@link System} properties. * The predefined location are: *
+ * Supported properties for override are: + *
- * If the file exists and is a valid properties file, its properties will overwrite the existing system properties. - *
- * WARNING: This method modifies the global system properties and should be used with caution. Overwriting some properties has no effect, because they are read only once from the original config during JVM startup. + * If the file exists and is a valid properties file, its content will overwrite existing system properties. + * Only some properties are supported, see {@link AdminPropertiesSetter} * * @return The adjusted system properties. */ @@ -64,9 +78,13 @@ class AdminPropertiesSetter { var adminProps = loadAdminProperties(ADMIN_PROPERTIES_FILE); for (var key : adminProps.stringPropertyNames()) { - var value = adminProps.getProperty(key); - LOG.info("Overwriting {} with value {} from admin properties.", key, value); - systemProps.setProperty(key, value); + if (ALLOWED_OVERRIDES.contains(key)) { + var value = adminProps.getProperty(key); + LOG.info("Overwriting {} with value {} from admin properties.", key, value); + systemProps.setProperty(key, value); + } else { + LOG.debug("Property {} in admin properties is not supported for override.", key); + } } return systemProps; }