{"record":{"id":"78d64e27dacf5763","repo":"apache/hadoop","slug":"oidname-oidname-is-not-supported","errorCode":null,"errorMessage":"oidName: ${oidName} is not supported.","messagePattern":"oidName: (.+?) is not supported\\.","errorType":"exception","errorClass":"NoSuchFieldException","httpStatus":null,"severity":"warning","filePath":"hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/KerberosUtil.java","lineNumber":99,"sourceCode":"   * @throws ClassNotFoundException for backward compatibility.\n   * @throws GSSException for backward compatibility.\n   * @throws NoSuchFieldException if the input is not supported.\n   * @throws IllegalAccessException for backward compatibility.\n   *\n   */\n  @Deprecated\n  public static Oid getOidInstance(String oidName)\n      throws ClassNotFoundException, GSSException, NoSuchFieldException,\n      IllegalAccessException {\n    switch (oidName) {\n    case \"GSS_SPNEGO_MECH_OID\":\n      return GSS_SPNEGO_MECH_OID;\n    case \"GSS_KRB5_MECH_OID\":\n      return GSS_KRB5_MECH_OID;\n    case \"NT_GSS_KRB5_PRINCIPAL\":\n      return NT_GSS_KRB5_PRINCIPAL_OID;\n    default:\n      throw new NoSuchFieldException(\n          \"oidName: \" + oidName + \" is not supported.\");\n    }\n  }\n\n  /**\n   * Return the default realm for this JVM.\n   *\n   * @return The default realm\n   * @throws IllegalArgumentException If the default realm does not exist.\n   * @throws ClassNotFoundException Not thrown. Exists for compatibility.\n   * @throws NoSuchMethodException Not thrown. Exists for compatibility.\n   * @throws IllegalAccessException Not thrown. Exists for compatibility.\n   * @throws InvocationTargetException Not thrown. Exists for compatibility.\n   */\n  public static String getDefaultRealm()\n      throws ClassNotFoundException, NoSuchMethodException,\n      IllegalArgumentException, IllegalAccessException,\n      InvocationTargetException {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/KerberosUtil.java#L81-L117","documentation":"This deprecated helper maps a small fixed set of constant names to JGSS Oid objects for SPNEGO/Kerberos. Only 'GSS_SPNEGO_MECH_OID', 'GSS_KRB5_MECH_OID' and 'NT_GSS_KRB5_PRINCIPAL' are recognized; anything else throws NoSuchFieldException('oidName: ... is not supported.') for compatibility with the old reflection-based lookup.","triggerScenarios":"Calling KerberosUtil.getOidInstance() with a name like 'GSS_NT_S...' or a made-up constant; migrating code that used Class.getField(name).get(null) on GSSUtil and passing an arbitrary field name.","commonSituations":"Code written against an old hadoop-auth that reflected on org.ietf.jgss.GSSUtil fields; callers assuming any JGSS constant name is accepted.","solutions":["Pass one of the three supported names verbatim","Better: stop using the deprecated method and construct Oids directly, e.g. new Oid(\"1.3.6.1.5.5.2\") for SPNEGO","For the common cases, use the constants already exposed by KerberosUtil or GSSUtil"],"exampleFix":"// before\nOid oid = KerberosUtil.getOidInstance(\"GSS_NT_EXPORT_CONTEXT\"); // NoSuchFieldException\n\n// after\nOid spnego = new Oid(\"1.3.6.1.5.5.2\");\nOid krb5 = new Oid(\"1.2.840.113554.1.2.2\");","handlingStrategy":"type-guard","validationCode":"java.util.Set<String> SUPPORTED = java.util.Set.of(\n    \"GSS_SPNEGO_MECH_OID\", \"GSS_KRB5_MECH_OID\", \"NT_GSS_KRB5_PRINCIPAL\");\nif (!SUPPORTED.contains(oidName)) throw new IllegalArgumentException(oidName);","typeGuard":"// prefer direct Oid construction over the deprecated lookup\nstatic Optional<Oid> toOid(String name) {\n  switch (name) {\n    case \"GSS_SPNEGO_MECH_OID\": return Optional.of(newOid(\"1.3.6.1.5.5.2\"));\n    case \"GSS_KRB5_MECH_OID\":   return Optional.of(newOid(\"1.2.840.113554.1.2.2\"));\n    case \"NT_GSS_KRB5_PRINCIPAL\": return Optional.of(newOid(\"1.2.840.113554.1.2.2.1\"));\n    default: return Optional.empty();\n  }\n}","tryCatchPattern":"try { Oid o = KerberosUtil.getOidInstance(name); } catch (NoSuchFieldException e) { /* unknown constant: switch to direct new Oid(...) */ }","preventionTips":["Migrate off the deprecated getOidInstance to direct Oid construction","Centralize OID constants in one enum instead of passing strings around"],"tags":["kerberos","gss-api","deprecated","hadoop-auth"],"backgroundTag":"unsupported-api-constant","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}