{"record":{"id":"89ae6272852301ad","repo":"ReactiveX/RxJava","slug":"array-of-size-8-expected-but-got","errorCode":null,"errorMessage":"Array of size 8 expected but got {}","messagePattern":"Array of size 8 expected but got (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/reactivex/rxjava4/internal/functions/Functions.java","lineNumber":549,"sourceCode":"\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\n    record Array9Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, R>(\n            Function9<T1, T2, T3, T4, T5, T6, T7, T8, T9, R> f) implements Function<Object[], R> {\n\n        @SuppressWarnings(\"unchecked\")\n            @Override\n            public R apply(Object[] a) throws Throwable {\n                if (a.length != 9) {\n                    throw new IllegalArgumentException(\"Array of size 9 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], (T9) a[8]);\n            }\n        }\n","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/ReactiveX/RxJava/blob/a8ab5356143f37a8f1dd6d76c79191bec5fa343b/src/main/java/io/reactivex/rxjava4/internal/functions/Functions.java#L531-L567","documentation":"Thrown by Array8Func.apply(Object[]) when the array length is not exactly 8. Array8Func is a record adapting Function8 to Function<Object[],R>, backing 8-way zip/combineLatest. Array arity must equal 8.","triggerScenarios":"An 8-arity adapter receives an Object[] of length != 8. An internal/custom-operator wiring error; rarely hit from normal public API use.","commonSituations":"Variable-length source list fed to a fixed 8-arity adapter; fan-in refactoring that changed source count but not the array; reflective payload construction.","solutions":["Pass exactly 8 elements to the 8-arity adapter; correct the array builder.","Prefer public 8-source zip/combineLatest overloads.","Add a length-8 input test.","Drive array length from the actual source count."],"exampleFix":"// before\nFunction<Object[], R> f = Functions.array8Func(fn8);\nR r = f.apply(arr7); // length 7 -> throws\n\n// after\nFunction<Object[], R> f = Functions.array8Func(fn8);\nR r = f.apply(new Object[]{ a, b, c, d, e, f2, g, h }); // length 8 matches arity","handlingStrategy":"validation","validationCode":"assert args.length == 8 : \"8-arity adapter requires length-8 array\";","typeGuard":null,"tryCatchPattern":"try {\n    R r = array8Fn.apply(args);\n} catch (IllegalArgumentException e) {\n    // array length != 8\n}","preventionTips":["Prefer public 8-source zip/combineLatest APIs.","Couple array length to source count.","Add a length-8 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"}