apache/seatunnel · error · IndexOutOfBoundsException
Index: , Fields size
Error message
Index: <index>, Fields size:<size>
What it means
Schema.get() is a custom accessor over an internal list of Field objects in the Doris REST table schema model. It throws IndexOutOfBoundsException when the requested index is >= the number of fields, deliberately including the size in the message since java.util.List.get's default message is less descriptive. It guards only the upper bound; a negative index will still be thrown by the underlying list.
Solutions
- Check the index against schema.size() before calling get(index)
- Re-fetch the Doris table schema if it may have changed (ALTER TABLE) instead of caching it
- Fix loop bounds (use `<` not `<=`) when iterating fields
Example fix
// before
Field f = schema.get(index);
// after
if (index < 0 || index >= schema.size()) {
throw new IllegalArgumentException("field index out of range: " + index);
}
Field f = schema.get(index); Defensive patterns
Strategy: validation
Validate before calling
if (schema == null || index < 0 || index >= schema.size()) return null; Field f = schema.get(index);
Type guard
boolean inRange(int i, Schema s) { return s != null && i >= 0 && i < s.size(); } Prevention
- Always derive loop bounds from schema.size()
- Refetch schema after any ALTER TABLE
- Never cache field counts across schema changes
When it happens
Trigger: Calling Schema.get(i) with i >= schema.size() while walking the Doris FE /schema REST response, e.g. iterating with a stale or wrong field count, or parsing a schema whose fields were truncated by an FE misconfiguration.
Common situations: Parsing Doris table metadata during schema-based save-mode table creation; loop bounds mismatch after a concurrent ALTER TABLE changed the schema; off-by-one loops like `for (i = 0; i <= schema.size(); i++)`.
Related errors
- Can't find column in table.
- Close scanner from failed.
- CloseScanner result from
- Closing httpClient failed.
- Closing streamLoadHttpClient failed.
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/392999799a24abc5.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/rest/models/Schema.java:77
}
public void put(
String name,
String type,
String comment,
int scale,
int precision,
String aggregationType) {
properties.add(new Field(name, type, comment, scale, precision, aggregationType));
}
public void put(Field f) {
properties.add(f);
}
public Field get(int index) {
if (index >= properties.size()) {
throw new IndexOutOfBoundsException(
"Index: " + index + ", Fields size:" + properties.size());
}
return properties.get(index);
}
public int size() {
return properties.size();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Schema schema = (Schema) o;View on GitHub (pinned to cf67b549a7)