{"record":{"id":"2f7517ad91c8df1d","repo":"apache/hadoop","slug":"null-opt","errorCode":null,"errorMessage":"Null opt","messagePattern":"Null opt","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Options.java","lineNumber":171,"sourceCode":"    \n    public static class CreateParent extends CreateOpts {\n      private final boolean createParent;\n      protected CreateParent(boolean createPar) {\n        createParent = createPar;}\n      public boolean getValue() { return createParent; }\n    }\n\n    \n    /**\n     * Get an option of desired type\n     * @param clazz is the desired class of the opt\n     * @param opts - not null - at least one opt must be passed\n     * @return an opt from one of the opts of type theClass.\n     *   returns null if there isn't any\n     */\n    static <T extends CreateOpts> T getOpt(Class<T> clazz, CreateOpts... opts) {\n      if (opts == null) {\n        throw new IllegalArgumentException(\"Null opt\");\n      }\n      T result = null;\n      for (int i = 0; i < opts.length; ++i) {\n        if (opts[i].getClass() == clazz) {\n          if (result != null) {\n            throw new IllegalArgumentException(\"multiple opts varargs: \" + clazz);\n          }\n\n          @SuppressWarnings(\"unchecked\")\n          T t = (T)opts[i];\n          result = t;\n        }\n      }\n      return result;\n    }\n    /**\n     * set an option\n     * @param newValue  the option to be set","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Options.java#L153-L189","documentation":"Options.CreateOpts.getOpt(clazz, opts) requires a non-null varargs array of create options. Passing null (the array itself, not an element) throws IllegalArgumentException('Null opt') before scanning.","triggerScenarios":"Calling getOpt with an explicitly null CreateOpts... array — e.g. a caller built its option array conditionally and the builder returned null, or reflection/bridging code passed null through.","commonSituations":"Helper APIs assembling option arrays that default to null, defensive `opts != null ? opts : null` bugs, conditional builder methods.","solutions":["Pass an empty array (new CreateOpts[0]) instead of null","Fix option-array builders to never return null; return an empty array"],"exampleFix":"// before\nT opt = CreateOpts.getOpt(clazz, null);\n// after\nT opt = CreateOpts.getOpt(clazz, new CreateOpts[0]);   // never pass a null varargs array","handlingStrategy":"validation","validationCode":"CreateOpts[] safe = (opts == null) ? new CreateOpts[0] : opts;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass null for a varargs array; use an empty array","Make option-array builders return empty arrays, not null","Flag null literals passed to varargs parameters in review"],"tags":["create-options","varargs","null-argument"],"backgroundTag":"null-varargs-array","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}