Skip to content

NumberFormatException in BuiltinDynamicCodecs when reading oid value #470

Closed
@marekpribyl

Description

@marekpribyl

Bug Report

Versions

  • Driver: v0.8.8.RELEASE
  • Database: PostgreSQL 11.12
  • Java: 16
  • OS: Linux

Current Behavior

The problem is in BuiltinDynamicCodecs#register() when oid value is read. In Postgres the value is stored as unsigned integer, but in the code the value is converted to singed integer:

Integer oid = row.get("oid", Integer.class);

So if the value is bigger than Integer.MAX_VALUE, exception is thrown.

For me this happens when this SQL is executed (in BuiltinDynamicCodecs#register()):

 SELECT oid, typname FROM pg_catalog.pg_type WHERE typname IN ('hstore');
Stack trace
Caused by: java.lang.NumberFormatException: For input string: \"3496546339\"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
at java.base/java.lang.Integer.parseInt(Integer.java:660)
at java.base/java.lang.Integer.parseInt(Integer.java:778)
at io.r2dbc.postgresql.codec.NumericDecodeUtils.decodeNumber(NumericDecodeUtils.java:68)
at io.r2dbc.postgresql.codec.AbstractNumericCodec.decodeNumber(AbstractNumericCodec.java:86)
at io.r2dbc.postgresql.codec.IntegerCodec.doDecode(IntegerCodec.java:49)
at io.r2dbc.postgresql.codec.IntegerCodec.doDecode(IntegerCodec.java:30)
at io.r2dbc.postgresql.codec.AbstractCodec.decode(AbstractCodec.java:82)
at io.r2dbc.postgresql.codec.DefaultCodecs.decode(DefaultCodecs.java:154)
at io.r2dbc.postgresql.PostgresqlRow.decode(PostgresqlRow.java:90)
at io.r2dbc.postgresql.PostgresqlRow.get(PostgresqlRow.java:77)
at io.r2dbc.postgresql.codec.BuiltinDynamicCodecs.lambda$null$0(BuiltinDynamicCodecs.java:80)
at io.r2dbc.postgresql.PostgresqlResult.lambda$map$1(PostgresqlResult.java:111)
at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onNext(FluxHandleFuseable.java:169)
... 40 common frames omitted  

Possible Solution

Use Long instead of Integer?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions