{"record":{"id":"861696d35227a93c","repo":"apache/flink","slug":"the-configuration-is-unmodifiable-its-contents-ca","errorCode":null,"errorMessage":"The configuration is unmodifiable; its contents cannot be changed.","messagePattern":"The configuration is unmodifiable; its contents cannot be changed\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"flink-core/src/main/java/org/apache/flink/configuration/UnmodifiableConfiguration.java","lineNumber":73,"sourceCode":"\n    @Override\n    public final void addAll(Configuration other, String prefix) {\n        error();\n    }\n\n    @Override\n    final <T> void setValueInternal(String key, T value, boolean canBePrefixMap) {\n        error();\n    }\n\n    @Override\n    public <T> boolean removeConfig(ConfigOption<T> configOption) {\n        error();\n        return false;\n    }\n\n    private void error() {\n        throw new UnsupportedOperationException(\n                \"The configuration is unmodifiable; its contents cannot be changed.\");\n    }\n}\n","sourceCodeStart":55,"sourceCodeEnd":77,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/configuration/UnmodifiableConfiguration.java#L55-L77","documentation":"Thrown by UnmodifiableConfiguration.error() whenever any mutating operation (addAll, addAll with prefix, setValueInternal, removeConfig) is called. UnmodifiableConfiguration wraps a Configuration snapshot and intentionally blocks all writes to guarantee immutability.","triggerScenarios":"Obtaining an UnmodifiableConfiguration (e.g., from certain APIs that return read-only views) and then calling set, setString, addAll, or removeConfig on it. Passing an UnmodifiableConfiguration to code that attempts to modify it.","commonSituations":"Framework code that receives a Configuration and tries to add defaults, not knowing it's unmodifiable. Libraries that mutate a passed-in config. User code that reads config from a context that returns an UnmodifiableConfiguration.","solutions":["Create a mutable copy before modifying: Configuration mutable = new Configuration(unmodifiableConfig);","Check isInstanceOf / type before mutating, or design APIs to return mutable copies.","Avoid mutating configs received from external/framework sources."],"exampleFix":"// before\nunmodifiableConfig.setString(\"key\", \"value\"); // throws\n\n// after\nConfiguration mutable = new Configuration(unmodifiableConfig);\nmutable.setString(\"key\", \"value\");","handlingStrategy":"type-guard","validationCode":"Configuration target = (config instanceof UnmodifiableConfiguration)\n    ? new Configuration(config)\n    : config;\ntarget.setString(\"key\", \"value\");","typeGuard":"static boolean isMutable(Configuration c) { return !(c instanceof UnmodifiableConfiguration); }","tryCatchPattern":"try {\n    config.setString(key, value);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().contains(\"unmodifiable\")) {\n        config = new Configuration(config);\n        config.setString(key, value);\n    }\n}","preventionTips":["Create a mutable copy before modifying configs received from frameworks.","Check for UnmodifiableConfiguration before mutating.","Design APIs to return mutable copies when callers may need to extend."],"tags":["configuration","immutability","unsupported-operation"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}