{"record":{"id":"4be0bb421e37c6bf","repo":"apache/beam","slug":"interface-s-has-methods-with-multiple-definitions-with","errorCode":null,"errorMessage":"Interface [%s] has Methods with multiple definitions with different return types:","messagePattern":"Interface \\[(.+?)\\] has Methods with multiple definitions with different return types:","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java","lineNumber":1391,"sourceCode":"      MultipleDefinitions errDef = definitions.get(0);\n      throw new IllegalArgumentException(\n          String.format(\n              \"Method [%s] has multiple definitions %s with different return types for [%s].\",\n              errDef.method.getName(), errDef.collidingMethods, iface.getName()));\n    } else if (definitions.size() > 1) {\n      StringBuilder errorBuilder =\n          new StringBuilder(\n              String.format(\n                  \"Interface [%s] has Methods with multiple definitions with different return\"\n                      + \" types:\",\n                  iface.getName()));\n      for (MultipleDefinitions errDef : definitions) {\n        errorBuilder.append(\n            String.format(\n                \"%n  - Method [%s] has multiple definitions %s\",\n                errDef.method.getName(), errDef.collidingMethods));\n      }\n      throw new IllegalArgumentException(errorBuilder.toString());\n    }\n  }\n\n  private static class InconsistentlyAnnotatedGetters {\n    PropertyDescriptor descriptor;\n    Iterable<String> getterClassNames;\n    Iterable<String> gettersWithTheAnnotationClassNames;\n  }\n\n  private static void throwForGettersWithInconsistentAnnotation(\n      List<InconsistentlyAnnotatedGetters> getters, Class<? extends Annotation> annotationClass) {\n    if (getters.size() == 1) {\n      InconsistentlyAnnotatedGetters getter = getters.get(0);\n      throw new IllegalArgumentException(\n          String.format(\n              \"Expected getter for property [%s] to be marked with @%s on all %s, \"\n                  + \"found only on %s\",\n              getter.descriptor.getName(),","sourceCodeStart":1373,"sourceCodeEnd":1409,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java#L1373-L1409","documentation":"The multi-definition variant of the multiple-definitions error: when several properties on one interface have colliding definitions with different return types, Beam aggregates them into one message headed 'Interface [%s] has Methods with multiple definitions with different return types:'. It fails PipelineOptions registration the same way as the single case.","triggerScenarios":"PipelineOptionsFactory.fromArgs(...).as(iface.class) where throwForMultipleDefinitions receives definitions.size() > 1; the body appends one line per colliding method before throwing.","commonSituations":"Merging several option interfaces (e.g. combined pipeline options inheriting from many feature-specific interfaces) where multiple properties clash at once; large refactors that rename types incompletely.","solutions":["Read each listed '- Method [...] has multiple definitions' line to identify all colliding properties.","Fix every listed method: unify return types across the hierarchy or rename the properties.","Re-run the pipeline; repeat until no collisions remain since all are reported together."],"exampleFix":"// before\ninterface A extends PipelineOptions { String getFoo(); int getBar(); }\ninterface B extends PipelineOptions { int getFoo(); long getBar(); }\n// after\ninterface A extends PipelineOptions { String getFoo(); int getBar(); }\ninterface B extends PipelineOptions { String getFoo(); int getBar(); }","handlingStrategy":"validation","validationCode":"// Same check as error 242; run it before registration to enumerate all collisions:\njava.util.Map<String, java.util.Set<Class<?>>> byName = new java.util.HashMap<>();\nfor (java.lang.reflect.Method m : MyOptions.class.getMethods()) {\n  byName.computeIfAbsent(m.getName(), k -> new java.util.HashSet<>()).add(m.getReturnType());\n}\nbyName.forEach((name, rets) -> { if (rets.size() > 1) System.err.println(\"collision: \" + name + \" -> \" + rets); });","typeGuard":null,"tryCatchPattern":"try {\n  PipelineOptionsFactory.fromArgs(args).as(MyOptions.class);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"multiple definitions with different return types:\")) { /* fix each listed method */ }\n  throw e;\n}","preventionTips":["Parse every '- Method [...] has multiple definitions' line and fix all at once","Keep property naming conventions unique per feature interface","Add an integration test that instantiates the full combined options class"],"tags":["java","apache-beam","pipeline-options","method-signature"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}