{"record":{"id":"edc77621c3652c7b","repo":"ReactiveX/RxJava","slug":"array-of-size-6-expected-but-got","errorCode":null,"errorMessage":"Array of size 6 expected but got {}","messagePattern":"Array of size 6 expected but got (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/reactivex/rxjava4/internal/functions/Functions.java","lineNumber":523,"sourceCode":"\n        @SuppressWarnings(\"unchecked\")\n        @Override\n        public R apply(Object[] a) throws Throwable {\n            if (a.length != 5) {\n                throw new IllegalArgumentException(\"Array of size 5 expected but got \" + a.length);\n            }\n            return f.apply((T1)a[0], (T2)a[1], (T3)a[2], (T4)a[3], (T5)a[4]);\n        }\n    }\n\n    record Array6Func<T1, T2, T3, T4, T5, T6, R>(\n            Function6<T1, T2, T3, T4, T5, T6, R> f) implements Function<Object[], R> {\n\n        @SuppressWarnings(\"unchecked\")\n            @Override\n            public R apply(Object[] a) throws Throwable {\n                if (a.length != 6) {\n                    throw new IllegalArgumentException(\"Array of size 6 expected but got \" + a.length);\n                }\n                return f.apply((T1) a[0], (T2) a[1], (T3) a[2], (T4) a[3], (T5) a[4], (T6) a[5]);\n            }\n        }\n\n    record Array7Func<T1, T2, T3, T4, T5, T6, T7, R>(\n            Function7<T1, T2, T3, T4, T5, T6, T7, R> f) implements Function<Object[], R> {\n\n        @SuppressWarnings(\"unchecked\")\n            @Override\n            public R apply(Object[] a) throws Throwable {\n                if (a.length != 7) {\n                    throw new IllegalArgumentException(\"Array of size 7 expected but got \" + a.length);\n                }\n                return f.apply((T1) a[0], (T2) a[1], (T3) a[2], (T4) a[3], (T5) a[4], (T6) a[5], (T7) a[6]);\n            }\n        }\n","sourceCodeStart":505,"sourceCodeEnd":541,"githubUrl":"https://github.com/ReactiveX/RxJava/blob/a8ab5356143f37a8f1dd6d76c79191bec5fa343b/src/main/java/io/reactivex/rxjava4/internal/functions/Functions.java#L505-L541","documentation":"Thrown by Array6Func.apply(Object[]) when the array length is not exactly 6. Array6Func is a record adapting Function6 to Function<Object[],R>, backing 6-way zip/combineLatest fan-in. Array arity must equal 6.","triggerScenarios":"A 6-arity adapter receives an Object[] of length != 6. An internal/custom-operator wiring error rather than typical application usage.","commonSituations":"Variable-length source list fed to a fixed 6-arity adapter; refactoring a multi-source combine without updating the array assembly; reflective construction of the payload array.","solutions":["Pass exactly 6 elements to the 6-arity adapter; correct the array-building code.","Prefer public 6-source zip/combineLatest overloads that manage arity.","Add a test verifying length-6 input.","Couple array length to the live source count."],"exampleFix":"// before\nFunction<Object[], R> f = Functions.array6Func(fn6);\nR r = f.apply(arr5); // length 5 -> throws\n\n// after\nFunction<Object[], R> f = Functions.array6Func(fn6);\nR r = f.apply(new Object[]{ a, b, c, d, e, f2 }); // length 6 matches arity","handlingStrategy":"validation","validationCode":"assert args.length == 6 : \"6-arity adapter requires length-6 array\";","typeGuard":null,"tryCatchPattern":"try {\n    R r = array6Fn.apply(args);\n} catch (IllegalArgumentException e) {\n    // array length != 6\n}","preventionTips":["Prefer public 6-source zip/combineLatest APIs.","Derive array length from the source count.","Add a length-6 input test."],"tags":["validation","argument","functions","arity","zip","rxjava"],"backgroundTag":null,"analyzedSha":"a8ab5356143f37a8f1dd6d76c79191bec5fa343b","analyzedAt":"2026-08-13T23:25:30.069Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}