Skip to content

Commit

Permalink
[#9288] Restore IllegalArgumentException
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaseder committed May 17, 2021
1 parent ed5ed02 commit 5024f76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion jOOQ/src/main/java/org/jooq/impl/FieldsImpl.java
Expand Up @@ -97,7 +97,7 @@ final class FieldsImpl<R extends Record> extends AbstractQueryPart implements Re

@Override
public final <U> RecordMapper<R, U> mapper(int fieldIndex, Configuration configuration, Class<? extends U> type) {
return mapper(fieldIndex, converterOrFail(configuration, field(fieldIndex).getType(), type));
return mapper(fieldIndex, converterOrFail(configuration, fields[safeIndex(fieldIndex)].getType(), type));
}

@Override
Expand Down Expand Up @@ -332,6 +332,13 @@ public final Field<?> field(int index) {
return null;
}

final int safeIndex(int index) {
if (index >= 0 && index < fields.length)
return index;

throw new IllegalArgumentException("No field at index " + index + " in Record type " + fields);
}

@Override
public final <T> Field<T> field(int fieldIndex, Class<T> type) {
Field<?> result = field(fieldIndex);
Expand Down
2 changes: 1 addition & 1 deletion jOOQ/src/main/java/org/jooq/impl/ResultImpl.java
Expand Up @@ -1203,7 +1203,7 @@ else if (o2 == null)
}
}

final int safeIndex(int index) {
private final int safeIndex(int index) {
if (index >= 0 && index < fields.size())
return index;

Expand Down

0 comments on commit 5024f76

Please sign in to comment.