{"record":{"id":"b0495fe5f9b48daf","repo":"ReactiveX/RxJava","slug":"array-of-size-9-expected-but-got-a-length","errorCode":null,"errorMessage":"Array of size 9 expected but got {a.length}","messagePattern":"Array of size 9 expected but got (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/reactivex/rxjava4/internal/functions/Functions.java","lineNumber":562,"sourceCode":"\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\n    static final class Identity implements Function<Object, Object> {\n        @Override\n        public Object apply(Object v) {\n            return v;\n        }\n\n        @Override\n        public String toString() {\n            return \"IdentityFunction\";\n        }\n    }\n\n    static final class EmptyRunnable implements Runnable {","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/ReactiveX/RxJava/blob/a8ab5356143f37a8f1dd6d76c79191bec5fa343b/src/main/java/io/reactivex/rxjava4/internal/functions/Functions.java#L544-L580","documentation":"Thrown by Array9Func.apply(Object[]) when the array length is not exactly 9. Array9Func is a record adapting Function9 (the highest fixed arity) to Function<Object[],R>, backing 9-way zip/combineLatest. Array arity must equal 9. Note: this is the last fixed-arity adapter (Function10+ use vararg/function-array paths).","triggerScenarios":"A 9-arity adapter receives an Object[] of length != 9. Custom-operator or test wiring error; not reachable from typical application code using public zip/combineLatest APIs.","commonSituations":"Dynamic source list fed to a fixed 9-arity adapter; refactoring a 9-way combine without updating array assembly; reflective construction with wrong count; bumping a 9-source combine to 10 sources but keeping the Function9 adapter.","solutions":["Pass exactly 9 elements to the 9-arity adapter; fix the array-building code.","Use the public 9-source zip/combineLatest overloads that manage arity internally.","Add a length-9 input test.","If you need 10+ sources, switch to the vararg/function-list zip overload instead of a fixed-arity adapter."],"exampleFix":"// before\nFunction<Object[], R> f = Functions.array9Func(fn9);\nR r = f.apply(arr8); // length 8 -> throws\n\n// after\nFunction<Object[], R> f = Functions.array9Func(fn9);\nR r = f.apply(new Object[]{ a,b,c,d,e,f2,g,h,i }); // length 9 matches arity","handlingStrategy":"validation","validationCode":"assert args.length == 9 : \"9-arity adapter requires length-9 array\";","typeGuard":null,"tryCatchPattern":"try {\n    R r = array9Fn.apply(args);\n} catch (IllegalArgumentException e) {\n    // array length != 9; or switch to vararg zip if you need >= 10 sources\n}","preventionTips":["For 10+ sources, use the vararg/function-list zip overload, not a fixed-arity adapter.","Bind array length to the source count.","Regression-test the 9-arity boundary."],"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"}