{"record":{"id":"2d96ecd6c109f19d","repo":"alibaba/ARouter","slug":"more-than-one-interceptors-use-same-priority-d","errorCode":null,"errorMessage":"More than one interceptors use same priority [%d], They are [%s] and [%s].","messagePattern":"More than one interceptors use same priority \\[(.+?)\\], They are \\[(.+?)\\] and \\[(.+?)\\]\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/processor/InterceptorProcessor.java","lineNumber":95,"sourceCode":"\n    /**\n     * Parse interceptor.\n     *\n     * @param elements elements of interceptor.\n     */\n    private void parseInterceptors(Set<? extends Element> elements) throws IOException {\n        if (CollectionUtils.isNotEmpty(elements)) {\n            logger.info(\">>> Found interceptors, size is \" + elements.size() + \" <<<\");\n\n            // Verify and cache, sort incidentally.\n            for (Element element : elements) {\n                if (verify(element)) {  // Check the interceptor meta\n                    logger.info(\"A interceptor verify over, its \" + element.asType());\n                    Interceptor interceptor = element.getAnnotation(Interceptor.class);\n\n                    Element lastInterceptor = interceptors.get(interceptor.priority());\n                    if (null != lastInterceptor) { // Added, throw exceptions\n                        throw new IllegalArgumentException(\n                                String.format(Locale.getDefault(), \"More than one interceptors use same priority [%d], They are [%s] and [%s].\",\n                                        interceptor.priority(),\n                                        lastInterceptor.getSimpleName(),\n                                        element.getSimpleName())\n                        );\n                    }\n\n                    interceptors.put(interceptor.priority(), element);\n                } else {\n                    logger.error(\"A interceptor verify failed, its \" + element.asType());\n                }\n            }\n\n            // Interface of ARouter.\n            TypeElement type_IInterceptor = elementUtils.getTypeElement(IINTERCEPTOR);\n            TypeElement type_IInterceptorGroup = elementUtils.getTypeElement(IINTERCEPTOR_GROUP);\n\n            /**","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/alibaba/ARouter/blob/84f451d244e3fb1d0e37801de1b9ee2af2f81d68/arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/processor/InterceptorProcessor.java#L77-L113","documentation":"Thrown by InterceptorProcessor.parseInterceptors when two classes annotated with @Interceptor declare the same priority. ARouter interceptors are indexed by their priority in a map, so duplicate priorities are ambiguous and compilation fails, naming both conflicting classes.","triggerScenarios":"Two @Interceptor(priority = N) classes in the same module (or across modules compiled together) share the same integer N, and the second insert into interceptors.get(priority) finds an existing entry.","commonSituations":"Copy-pasting an interceptor class and forgetting to change the priority; two teams adding interceptors with the same priority in different modules; refactoring that merges modules.","solutions":["Change the priority of one of the conflicting @Interceptor classes to a unique value.","Search the codebase for `@Interceptor(priority = <N>)` and assign distinct priorities.","If the conflict is across modules, coordinate priority allocation across teams or document priority ranges per module."],"exampleFix":"// before\n@Interceptor(priority = 1)\npublic class LoginInterceptor implements IInterceptor { ... }\n@Interceptor(priority = 1)\npublic class LogInterceptor implements IInterceptor { ... }\n\n// after\n@Interceptor(priority = 1)\npublic class LoginInterceptor implements IInterceptor { ... }\n@Interceptor(priority = 2)\npublic class LogInterceptor implements IInterceptor { ... }","handlingStrategy":"validation","validationCode":"// CI check: ensure unique interceptor priorities\nSet<Integer> seen = new HashSet<>();\nfor (Class<?> c : interceptorClasses) {\n    int p = c.getAnnotation(Interceptor.class).priority();\n    if (!seen.add(p)) throw new IllegalStateException(\"Duplicate interceptor priority: \" + p);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a central registry/doc of allocated interceptor priorities.","When copying an interceptor, immediately change its priority.","Add a unit test scanning @Interceptor annotations for duplicate priorities."],"tags":["annotation-processor","arouter","duplicate-key","interceptor"],"backgroundTag":"conflicting-config-options","analyzedSha":"84f451d244e3fb1d0e37801de1b9ee2af2f81d68","analyzedAt":"2026-09-06T13:30:41.084Z","contentChangedAt":"2026-09-06T13:30:41.084Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}