{"record":{"id":"293f90dc14edccfc","repo":"deeplearning4j/deeplearning4j","slug":"unknown-inequalityhanding-option-was-passed-in","errorCode":null,"errorMessage":"Unknown InequalityHanding option was passed in: ","messagePattern":"Unknown InequalityHanding option was passed in: ","errorType":"exception","errorClass":"ND4JIllegalStateException","httpStatus":null,"severity":"error","filePath":"deeplearning4j/deeplearning4j-data/deeplearning4j-utility-iterators/src/main/java/org/deeplearning4j/datasets/iterator/parallel/BaseParallelDataSetIterator.java","lineNumber":114,"sourceCode":"\n                    if (states.allFalse())\n                        return false;\n                }\n\n                return true;\n            }\n            case PASS_NULL: {\n                // we just return true here, no matter what's up\n                return true;\n            }\n            case STOP_EVERYONE: {\n                if (!states.allTrue())\n                    return false;\n\n                return true;\n            }\n            default:\n                throw new ND4JIllegalStateException(\n                        \"Unknown InequalityHanding option was passed in: \" + inequalityHandling);\n        }\n    }\n\n    public DataSet next() {\n        DataSet ds = nextFor(getCurrentProducerIndex());\n        stepForward();\n        return ds;\n    }\n\n    protected int getCurrentProducerIndex() {\n        return (int) (counter.get() % numProducers);\n    }\n\n    protected void stepForward() {\n        counter.getAndIncrement();\n    }\n","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/deeplearning4j/deeplearning4j/blob/4c22ac5fe4a8350d05d224e7f4499429f7f69c93/deeplearning4j/deeplearning4j-data/deeplearning4j-utility-iterators/src/main/java/org/deeplearning4j/datasets/iterator/parallel/BaseParallelDataSetIterator.java#L96-L132","documentation":"BaseParallelDataSetIterator.hasNext() dispatches on the configured InequalityHandling strategy once some producers are depleted. If the inequalityHandling field does not match any known enum constant (typically null or an unrecognized value on this code path), the switch's default branch throws ND4JIllegalStateException('Unknown InequalityHanding option was passed in: ' + inequalityHandling).","triggerScenarios":"hasNext() reached the switch because states are not allFalse and the current producer is depleted, while inequalityHandling is null (field never set because a subclass/constructor did not assign it) or holds an unexpected value; deserialization/serialization of the iterator dropping the enum value.","commonSituations":"Custom subclass of BaseParallelDataSetIterator forgetting to set inequalityHandling before first hasNext(); constructing the iterator via reflection/framework DI that skips the enum field; mixing DL4J versions where an enum constant was renamed so old serialized configs no longer match.","solutions":["Ensure the concrete subclass constructor always assigns this.inequalityHandling from a valid InequalityHandling constant (RESET, RELOCATE, PASS_NULL, STOP_EVERYONE)","Print/inspect the iterator's inequalityHandling value when the exception message shows null","Fix any serialization/config pipeline so the enum survives round-trips, and validate it in the constructor with Objects.requireNonNull"],"exampleFix":"// before\nprotected BaseParallelDataSetIterator(int numProducers) {\n    super(numProducers);\n    // inequalityHandling never set -> ND4JIllegalStateException in hasNext()\n}\n// after\npublic MyParallelIterator(int numProducers, InequalityHandling handling) {\n    super(numProducers);\n    this.inequalityHandling = Objects.requireNonNull(handling, \"inequalityHandling\");\n}","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(inequalityHandling, \"inequalityHandling must be set\");\nEnumSet.of(InequalityHandling.RESET, InequalityHandling.RELOCATE,\n           InequalityHandling.PASS_NULL, InequalityHandling.STOP_EVERYONE)\n           .contains(inequalityHandling); // else reject before use","typeGuard":null,"tryCatchPattern":"try {\n    boolean more = parallelIterator.hasNext();\n} catch (ND4JIllegalStateException e) {\n    // log inequalityHandling value; reconfigure iterator with a valid InequalityHandling enum constant\n}","preventionTips":["Always pass a valid InequalityHandling constant (RESET/RELOCATE/PASS_NULL/STOP_EVERYONE) into the subclass constructor","Add a constructor-time null check on inequalityHandling in custom subclasses","Validate enum values survive any serialization/config round-trip","Check the exception message — it prints the offending value, often null"],"tags":["java","deeplearning4j","nd4j","parallel-iterator","invalid-enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"4c22ac5fe4a8350d05d224e7f4499429f7f69c93","analyzedAt":"2026-09-07T05:27:04.714Z","contentChangedAt":"2026-09-07T05:27:04.714Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}