{"record":{"id":"72b41f4f546b2fc7","repo":"apache/beam","slug":"method-s-has-multiple-definitions-s-with-different-return","errorCode":null,"errorMessage":"Method [%s] has multiple definitions %s with different return types for [%s].","messagePattern":"Method \\[(.+?)\\] has multiple definitions (.+?) with different return types for \\[(.+?)\\]\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java","lineNumber":1374,"sourceCode":"  private static void validateInheritedInterfacesExtendPipelineOptions(Class<?> klass) {\n    Set<Class<?>> nonPipelineOptionsClasses = new LinkedHashSet<>();\n    checkInheritedFrom(klass, PipelineOptions.class, nonPipelineOptionsClasses);\n\n    if (!nonPipelineOptionsClasses.isEmpty()) {\n      throwNonPipelineOptions(klass, nonPipelineOptionsClasses);\n    }\n  }\n\n  private static class MultipleDefinitions {\n    private Method method;\n    private SortedSet<Method> collidingMethods;\n  }\n\n  private static void throwForMultipleDefinitions(\n      Class<? extends PipelineOptions> iface, List<MultipleDefinitions> definitions) {\n    if (definitions.size() == 1) {\n      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    }","sourceCodeStart":1356,"sourceCodeEnd":1392,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java#L1356-L1392","documentation":"Thrown when a single PipelineOptions interface hierarchy defines the same bean method (same getter name) multiple times with different return types. Beam cannot resolve which type the property has, so registration fails.","triggerScenarios":"PipelineOptionsFactory.fromArgs(...).as(iface.class) where throwForMultipleDefinitions receives a MultipleDefinitions entry: getFoo() returns String in one interface and int (or List<String>) in another inherited interface.","commonSituations":"Two teams define the same property name with different types in separate option interfaces that are later combined; renaming a property's type in one interface but not another; Java generics erasure hiding a conflicting return type.","solutions":["Align the return types of the colliding methods listed in the message so they are identical.","Or rename one of the properties (e.g. getFooMillis vs getFooDuration) to make them distinct.","Remove the duplicate definition if one interface should simply inherit the other's getter."],"exampleFix":"// before\ninterface A extends PipelineOptions { String getFoo(); }\ninterface B extends PipelineOptions { int getFoo(); }\n// after\ninterface A extends PipelineOptions { String getFoo(); }\ninterface B extends PipelineOptions { int getFooCount(); }","handlingStrategy":"validation","validationCode":"java.util.Map<String, Class<?>> types = new java.util.HashMap<>();\nfor (java.lang.reflect.Method m : MyOptions.class.getMethods()) {\n  Class<?> prev = types.putIfAbsent(m.getName(), m.getReturnType());\n  if (prev != null && !prev.equals(m.getReturnType())) {\n    throw new IllegalStateException(m.getName() + \" has conflicting return types \" + prev + \" vs \" + m.getReturnType());\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  PipelineOptionsFactory.fromArgs(args).as(MyOptions.class);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"multiple definitions\")) { /* unify return types or rename properties */ }\n  throw e;\n}","preventionTips":["Give each property a unique name across the entire options hierarchy","Avoid combining option interfaces that were developed independently without a name-collision review","Run a unit test calling .as() on every options interface in CI"],"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"}