{"record":{"id":"36ac63e9cb71b004","repo":"pinpoint-apm/pinpoint","slug":"duplicated-servicetype-servicetype-duplicat","errorCode":null,"errorMessage":"duplicated ServiceType ${serviceType} / ${duplicated}","messagePattern":"duplicated ServiceType (.+?) / (.+?)","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/trace/ServiceTypeRegistry.java","lineNumber":58,"sourceCode":"    private final Map<String, ServiceType> nameLookupTable;\n\n    private final Map<String, List<ServiceType>> descLookupTable;\n\n    private ServiceTypeRegistry(Map<Integer, ServiceType> buildMap) {\n        Objects.requireNonNull(buildMap, \"buildMap\");\n\n        this.codeLookupTable = IntHashMapUtils.copy(buildMap);\n        this.nameLookupTable = buildNameLookupTable(buildMap.values());\n        this.descLookupTable = buildDescLookupTable(buildMap.values());\n    }\n\n    private Map<String, ServiceType> buildNameLookupTable(Collection<ServiceType> serviceTypes) {\n        final Map<String, ServiceType> copy = new HashMap<>();\n\n        for (ServiceType serviceType : serviceTypes) {\n            final ServiceType duplicated = copy.put(serviceType.getName(), serviceType);\n            if (duplicated  != null) {\n                throw new IllegalStateException(\"duplicated ServiceType \" + serviceType + \" / \" + duplicated);\n            }\n        }\n        return copy;\n    }\n\n    @Override\n    public ServiceType findServiceType(int code) {\n        final ServiceType serviceType = this.codeLookupTable.get(code);\n        if (serviceType == null) {\n            return ServiceType.UNDEFINED;\n        }\n        return serviceType;\n    }\n\n    @Override\n    public ServiceType findServiceTypeByName(String name) {\n        final ServiceType serviceType = this.nameLookupTable.get(name);\n        if (serviceType == null) {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/trace/ServiceTypeRegistry.java#L40-L76","documentation":"ServiceTypeRegistry.buildNameLookupTable builds a name-to-ServiceType map during registry construction. Since HashMap.put returns the previous value, any two ServiceTypes sharing the same name cause an immediate IllegalStateException — service type names must be unique identifiers in Pinpoint. This runs in the constructor, so the registry can never be created while a name collision exists.","triggerScenarios":"Constructing a ServiceTypeRegistry (or its builder path via createServiceTypeRegistry) with a collection containing two ServiceTypes with identical getName() values — typically a custom service type reusing a built-in name like 'TOMCAT' or two custom types with the same name.","commonSituations":"Custom plugin type descriptor files (type-provider.yml / ServiceType descriptors) that copy a built-in name; loading the same plugin twice so its types are registered twice; merging plugin lists where names overlap across plugins.","solutions":["Rename one of the conflicting ServiceTypes so names are unique","Check the message's 'duplicated' part to see which existing type owns the name","Remove duplicate plugin registrations / duplicate type descriptor entries from the classpath","Use a distinct, descriptive name in the custom plugin's ServiceTypeDescriptor"],"exampleFix":"// before\nServiceType MY_APP = new ServiceType(1200, \"TOMCAT\"); // name collides\n// after\nServiceType MY_APP = new ServiceType(1200, \"MY_TOMCAT_APP\");","handlingStrategy":"validation","validationCode":"Set<String> seen = new HashSet<>();\nfor (ServiceType st : serviceTypes) {\n    if (!seen.add(st.getName())) {\n        throw new IllegalStateException(\"duplicate ServiceType name: \" + st.getName());\n    }\n}\nServiceTypeRegistry registry = new ServiceTypeRegistry(serviceTypes);","typeGuard":null,"tryCatchPattern":"try {\n    ServiceTypeRegistry registry = new ServiceTypeRegistry(serviceTypes);\n} catch (IllegalStateException e) {\n    LOGGER.error(\"service type name collision: {}\", e.getMessage());\n}","preventionTips":["Give custom service types unique, prefixed names (e.g. MYCOMPANY_APP)","Avoid loading the same plugin jar twice","Compare against built-in ServiceType names before naming a custom type"],"tags":["duplicate-key","registry","service-type"],"backgroundTag":"internal-invariant-violation","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}