{"record":{"id":"31e6add7a3162a88","repo":"ReactiveX/RxJava","slug":"array-of-size-7-expected-but-got","errorCode":null,"errorMessage":"Array of size 7 expected but got {}","messagePattern":"Array of size 7 expected but got (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/reactivex/rxjava4/internal/functions/Functions.java","lineNumber":536,"sourceCode":"\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\n    record Array8Func<T1, T2, T3, T4, T5, T6, T7, T8, R>(\n            Function8<T1, T2, T3, T4, T5, T6, T7, T8, R> f) implements Function<Object[], R> {\n\n        @SuppressWarnings(\"unchecked\")\n            @Override\n            public R apply(Object[] a) throws Throwable {\n                if (a.length != 8) {\n                    throw new IllegalArgumentException(\"Array of size 8 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], (T8) a[7]);\n            }\n        }\n","sourceCodeStart":518,"sourceCodeEnd":554,"githubUrl":"https://github.com/ReactiveX/RxJava/blob/a8ab5356143f37a8f1dd6d76c79191bec5fa343b/src/main/java/io/reactivex/rxjava4/internal/functions/Functions.java#L518-L554","documentation":"Thrown by Array7Func.apply(Object[]) when the array length is not exactly 7. Array7Func is a record adapting Function7 to Function<Object[],R>, backing 7-way zip/combineLatest. Array arity must equal 7.","triggerScenarios":"A 7-arity adapter receives an Object[] of length != 7. Reachable from custom operator/test code that mismatches source count and adapter arity.","commonSituations":"Dynamic source list fed to a fixed 7-arity adapter; refactoring a fan-in without realigning the array; reflective array assembly with the wrong count.","solutions":["Provide exactly 7 elements to the 7-arity adapter; fix the array construction.","Use the public 7-source zip/combineLatest APIs.","Add a length-7 input test.","Bind array length to the source count, not a constant."],"exampleFix":"// before\nFunction<Object[], R> f = Functions.array7Func(fn7);\nR r = f.apply(arr6); // length 6 -> throws\n\n// after\nFunction<Object[], R> f = Functions.array7Func(fn7);\nR r = f.apply(new Object[]{ a, b, c, d, e, f2, g }); // length 7 matches arity","handlingStrategy":"validation","validationCode":"assert args.length == 7 : \"7-arity adapter requires length-7 array\";","typeGuard":null,"tryCatchPattern":"try {\n    R r = array7Fn.apply(args);\n} catch (IllegalArgumentException e) {\n    // array length != 7\n}","preventionTips":["Use public 7-source zip/combineLatest overloads.","Bind array length to the source count.","Regression-test arity boundaries."],"tags":["validation","argument","functions","arity","zip","rxjava"],"backgroundTag":null,"analyzedSha":"a8ab5356143f37a8f1dd6d76c79191bec5fa343b","analyzedAt":"2026-08-13T23:25:30.069Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}