{"record":{"id":"e95b58bcde481f43","repo":"apache/pulsar","slug":"failed-to-compute-configuration-overrides","errorCode":null,"errorMessage":"Failed to compute configuration overrides","messagePattern":"Failed to compute configuration overrides","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoader.java","lineNumber":316,"sourceCode":"                if (field.getDeclaredAnnotation(FieldContext.class) == null) {\n                    continue;\n                }\n                field.setAccessible(true);\n                Object current = field.get(conf);\n                Object def = field.get(defaults);\n                if (!Objects.equals(current, def)) {\n                    overrides.put(field.getName(), current);\n                }\n            }\n            Properties props = conf.getProperties();\n            if (props != null) {\n                for (String key : props.stringPropertyNames()) {\n                    overrides.putIfAbsent(key, props.getProperty(key));\n                }\n            }\n            return overrides;\n        } catch (ReflectiveOperationException e) {\n            throw new RuntimeException(\"Failed to compute configuration overrides\", e);\n        }\n    }\n}\n","sourceCodeStart":298,"sourceCodeEnd":320,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoader.java#L298-L320","documentation":"PulsarConfigurationLoader.runtimeConfigurationOverrides builds a map of configuration overrides by reflectively reading fields of a PulsarConfiguration object and merging properties. Any failure while reflecting over the config fields (e.g. an incompatible/illegal field access during introspection) is wrapped in this RuntimeException. It signals the broker configuration could not be transformed into CLI-style overrides, so startup/tooling cannot proceed with a coherent config view.","triggerScenarios":"Calling runtimeConfigurationOverrides(PulsarConfiguration) when reflection over the configuration object fails: field lookup throws NoSuchFieldException, or an inaccessible field triggers IllegalAccessException during the props/overrides merge loop.","commonSituations":"Running broker tooling (e.g. initialization or standalone startup) against a custom or repackaged configuration class whose fields changed name/type between versions; security managers or module encapsulation (JPMS strong encapsulation) blocking reflective access; shaded/mismatched jars mixing Pulsar versions.","solutions":["Check the 'Caused by' of the RuntimeException to see which reflective operation failed (field name / access error) and fix the configuration class or call site.","Align the Pulsar broker-common jar versions: ensure no mixed/shaded jars where the config class fields no longer match what the loader expects.","If running under JPMS or a security manager, open the configuration package for reflective access (--add-opens) or grant the needed ReflectPermission.","Validate the configuration file loads correctly (config-object fields are populated) before invoking override computation."],"exampleFix":"// before: calling with a custom config class in an unnamed module under JPMS\nPulsarConfiguration cfg = loadConfig();\nMap<String, Object> overrides = PulsarConfigurationLoader.runtimeConfigurationOverrides(cfg);\n// after: open reflective access or revert to stock config class\njava --add-opens org.apache.pulsar.broker/org.apache.pulsar.common.configuration=ALL-UNNAMED ...\n// or use the stock PulsarConfiguration implementation instead of a renamed subclass","handlingStrategy":"try-catch","validationCode":"// Pre-check: ensure reflective access is possible\ntry {\n    Class<?> cfgClass = config.getClass();\n    for (java.lang.reflect.Field f : cfgClass.getDeclaredFields()) {\n        f.setAccessible(true);\n    }\n} catch (Throwable t) {\n    // fail fast with a clear message before calling runtimeConfigurationOverrides\n}","typeGuard":null,"tryCatchPattern":"try {\n    overrides = PulsarConfigurationLoader.runtimeConfigurationOverrides(cfg);\n} catch (RuntimeException e) {\n    Throwable cause = e.getCause(); // ReflectiveOperationException detail\n    log.error(\"Config override computation failed: {}\", cause.getMessage(), e);\n    throw new IllegalStateException(\"Invalid configuration setup\", e);\n}","preventionTips":["Use the stock PulsarConfiguration classes rather than custom subclasses with renamed fields.","Avoid mixing Pulsar jar versions on the classpath (shading conflicts).","Run on a standard JDK without restrictive security managers; add --add-opens when using JPMS.","Always read the full cause chain — the real error is the wrapped ReflectiveOperationException."],"tags":["java","reflection","configuration","pulsar"],"backgroundTag":"reflective-access-failed","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}