{"record":{"id":"36e9fc9239309737","repo":"prestodb/presto","slug":"session-property-configuration-manager-s-is-alr","errorCode":null,"errorMessage":"Session property configuration manager '%s' is already registered","messagePattern":"Session property configuration manager '(.+?)' is already registered","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/server/SessionPropertyDefaults.java","lineNumber":67,"sourceCode":"    private static final Path SESSION_PROPERTY_CONFIGURATION = Paths.get(\"etc/session-property-config.properties\");\n    private static final String SESSION_PROPERTY_MANAGER_NAME = \"session-property-config.configuration-manager\";\n\n    private final SessionPropertyConfigurationManagerContext configurationManagerContext;\n    private final Map<String, SessionPropertyConfigurationManagerFactory> factories = new ConcurrentHashMap<>();\n    private final AtomicReference<SessionPropertyConfigurationManager> delegate = new AtomicReference<>();\n    private final String prestoServerVersion;\n\n    @Inject\n    public SessionPropertyDefaults(NodeInfo nodeInfo, NodeVersion nodeVersion)\n    {\n        this.configurationManagerContext = new SessionPropertyConfigurationManagerContextInstance(nodeInfo.getEnvironment());\n        this.prestoServerVersion = requireNonNull(nodeVersion.getVersion(), \"prestoServerVersion is null\");\n    }\n\n    public void addConfigurationManagerFactory(SessionPropertyConfigurationManagerFactory sessionConfigFactory)\n    {\n        if (factories.putIfAbsent(sessionConfigFactory.getName(), sessionConfigFactory) != null) {\n            throw new IllegalArgumentException(format(\"Session property configuration manager '%s' is already registered\", sessionConfigFactory.getName()));\n        }\n    }\n\n    public void loadConfigurationManager()\n            throws IOException\n    {\n        if (!Files.exists(SESSION_PROPERTY_CONFIGURATION)) {\n            return;\n        }\n\n        Map<String, String> properties = loadProperties(SESSION_PROPERTY_CONFIGURATION.toFile());\n        checkArgument(!isNullOrEmpty(properties.get(SESSION_PROPERTY_MANAGER_NAME)),\n                \"Session property configuration %s does not contain %s\",\n                SESSION_PROPERTY_CONFIGURATION,\n                SESSION_PROPERTY_MANAGER_NAME);\n\n        loadConfigurationManager(properties);\n    }","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/server/SessionPropertyDefaults.java#L49-L85","documentation":"SessionPropertyDefaults.addConfigurationManagerFactory registers SessionPropertyConfigurationManagerFactory instances by name in a map using putIfAbsent. If a factory with the same getName() is already present, it throws IllegalArgumentException — only one factory per name is allowed.","triggerScenarios":"Calling addConfigurationManagerFactory twice with factories whose names collide; typically the same session property configuration manager plugin registered twice (duplicate plugin install) or test setup (e.g. testApplyDefaultProperties) registering the factory more than once against a shared manager.","commonSituations":"Duplicate plugin jar deployments on the coordinator; initializing SessionPropertyDefaults multiple times in one process; test fixtures that share a manager across cases without resetting it.","solutions":["Remove the duplicate plugin so only one provider of that configuration-manager name is installed","Ensure the factory's getName() is unique among registered factories","In tests, construct a new SessionPropertyDefaults per case or register once in setup","Make startup idempotent by checking the name before registering"],"exampleFix":"// before\nsessionPropertyDefaults.addConfigurationManagerFactory(factory);\n// after\nif (!sessionPropertyDefaultsHasFactory(factory)) {\n    sessionPropertyDefaults.addConfigurationManagerFactory(factory);\n}","handlingStrategy":"validation","validationCode":"// ensure uniqueness before registration\nSet<String> seen = new HashSet<>();\nif (!seen.add(factory.getName())) { skip-or-log; }\nelse { defaults.addConfigurationManagerFactory(factory); }","typeGuard":"boolean isRegisterable(SessionPropertyConfigurationManagerFactory f, Set<String> registeredNames) {\n    return f.getName() != null && !registeredNames.contains(f.getName());\n}","tryCatchPattern":"try {\n    defaults.addConfigurationManagerFactory(factory);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Session property configuration manager already registered: {}\", factory.getName());\n}","preventionTips":["Install only one session property configuration manager plugin per name","Use unique getName() values for custom factories","In tests, create a new SessionPropertyDefaults per case or register once in setup"],"tags":["presto","session-properties","plugin-registration","illegal-argument"],"backgroundTag":"duplicate-registration","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}