{"id":"266d322db9945335","repo":"junit-team/junit5","slug":"annotationbasedargumentsprovider-does-not-override","errorCode":null,"errorMessage":"AnnotationBasedArgumentsProvider does not override the provideArguments(ParameterDeclarations, ExtensionContext, Annotation) method. Please report this issue to the maintainers of %s.","messagePattern":"AnnotationBasedArgumentsProvider does not override the provideArguments\\(ParameterDeclarations, ExtensionContext, Annotation\\) method\\. Please report this issue to the maintainers of (.+?)\\.","errorType":"exception","errorClass":"JUnitException","httpStatus":null,"severity":"error","filePath":"junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/AnnotationBasedArgumentsProvider.java","lineNumber":79,"sourceCode":"\tpublic Stream<? extends Arguments> provideArguments(ParameterDeclarations parameters, ExtensionContext context) {\n\t\treturn annotations.stream().flatMap(annotation -> provideArguments(parameters, context, annotation));\n\t}\n\n\t/**\n\t * Provide a {@link Stream} of {@link Arguments} &mdash; based on metadata in the\n\t * provided annotation &mdash; to be passed to a {@code @ParameterizedTest} method.\n\t *\n\t * @param context the current extension context; never {@code null}\n\t * @param annotation the annotation to process; never {@code null}\n\t * @return a stream of arguments; never {@code null}\n\t * @deprecated Please implement\n\t * {@link #provideArguments(ParameterDeclarations, ExtensionContext, Annotation)}\n\t * instead.\n\t */\n\t@Deprecated(since = \"5.13\")\n\t@API(status = DEPRECATED, since = \"5.13\")\n\tprotected Stream<? extends Arguments> provideArguments(ExtensionContext context, A annotation) {\n\t\tthrow new JUnitException(\"\"\"\n\t\t\t\tAnnotationBasedArgumentsProvider does not override the \\\n\t\t\t\tprovideArguments(ParameterDeclarations, ExtensionContext, Annotation) method. \\\n\t\t\t\tPlease report this issue to the maintainers of %s.\"\"\".formatted(getClass().getName()));\n\t}\n\n\t/**\n\t * The returned {@code Stream} will be {@link Stream#close() properly closed}\n\t * by the default implementation of\n\t * {@link #provideArguments(ParameterDeclarations, ExtensionContext)},\n\t * making it safe to use a resource such as\n\t * {@link java.nio.file.Files#lines(java.nio.file.Path) Files.lines()}.\n\t */\n\tprotected Stream<? extends Arguments> provideArguments(ParameterDeclarations parameters, ExtensionContext context,\n\t\t\tA annotation) {\n\t\treturn provideArguments(context, annotation);\n\t}\n\n}","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/junit-team/junit5/blob/956246301e03d757539f7b76dd5a91f298637563/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/AnnotationBasedArgumentsProvider.java#L61-L97","documentation":"Thrown by the deprecated default provideArguments(ExtensionContext, A) in AnnotationBasedArgumentsProvider. It fires when a subclass neither overrides the current 3-arg provideArguments(ParameterDeclarations, ExtensionContext, A) nor the deprecated 2-arg variant. It signals a programming defect in a custom annotation-based arguments provider.","triggerScenarios":"A custom provider `class MyProvider extends AnnotationBasedArgumentsProvider<MyAnno>` registered via @ArgumentsSource, where the author forgot to override the 3-arg provideArguments. The framework's 3-arg default delegates to the 2-arg default, which throws.","commonSituations":"Upgrading JUnit from pre-5.13 (where the 2-arg was the contract) without adding the new override; following an outdated tutorial; abstract intermediate subclass left without implementation.","solutions":["Override `protected Stream<? extends Arguments> provideArguments(ParameterDeclarations parameters, ExtensionContext context, MyAnno annotation)` in the subclass.","If you cannot change the class, report the issue to the maintainers of that third-party provider as the message instructs.","As a temporary stopgap, pin JUnit to a version whose ArgumentsProvider contract the provider implements."],"exampleFix":"// before\nclass MyProvider extends AnnotationBasedArgumentsProvider<MyAnno> {\n    // no overrides\n}\n\n// after\nclass MyProvider extends AnnotationBasedArgumentsProvider<MyAnno> {\n    @Override\n    protected Stream<? extends Arguments> provideArguments(\n            ParameterDeclarations parameters, ExtensionContext context, MyAnno annotation) {\n        return Stream.of(Arguments.of(annotation.value()));\n    }\n}","handlingStrategy":"validation","validationCode":"// Fail fast at extension registration: assert the subclass overrides the 3-arg method.\nClass<? extends AnnotationBasedArgumentsProvider<?>> provider = MyProvider.class;\nboolean overrides3Arg = Arrays.stream(provider.getDeclaredMethods())\n    .anyMatch(m -> m.getName().equals(\"provideArguments\")\n        && m.getParameterCount() == 3\n        && !Modifier.isVolatile(m.getModifiers()));\nif (!overrides3Arg) {\n    throw new IllegalStateException(provider.getName()\n        + \" must override provideArguments(ParameterDeclarations, ExtensionContext, Annotation)\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    // run the parameterized test that uses the custom provider\n} catch (JUnitException e) {\n    if (e.getMessage().contains(\"does not override the provideArguments\")) {\n        // implement the 3-arg override in the provider class named in the message\n    } else throw e;\n}","preventionTips":["When extending AnnotationBasedArgumentsProvider, always @Override the 3-arg provideArguments.","Add a reflection-based smoke test that asserts your provider overrides the expected method.","Treat the deprecated 2-arg method as a migration aid only, not a long-term contract."],"tags":["junit","jupiter-params","arguments-provider","api-migration"],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}