Skip to content
This repository was archived by the owner on Aug 26, 2026. It is now read-only.

Add support for BINARY (BYTEA) column type in JdbcOAuth2AuthorizationService - #2337

Closed
s-chan-o wants to merge 1 commit into
spring-attic:mainfrom
s-chan-o:fix/jdbc-postgresql-bytea-support
Closed

Add support for BINARY (BYTEA) column type in JdbcOAuth2AuthorizationService#2337
s-chan-o wants to merge 1 commit into
spring-attic:mainfrom
s-chan-o:fix/jdbc-postgresql-bytea-support

Conversation

@s-chan-o

Copy link
Copy Markdown

Problem

JdbcOAuth2AuthorizationService fails when PostgreSQL (or PostgreSQL-compatible databases such as AWS Aurora DSQL) is used as the backend store.

PostgreSQL represents binary data using the BYTEA type, which is reported by the JDBC driver as Types.BINARY (-2). The current implementation only handles Types.BLOB and Types.CLOB, so BYTEA columns cause data read/write failures.

Fixes gh-2321

Changes

Added Types.BINARY handling in three locations within JdbcOAuth2AuthorizationService:

Method Change
getLobValue Reads bytes and converts to String; trims trailing null bytes present in fixed-length BINARY columns
doSetValue Writes byte[] or String values via LobCreator for Types.BINARY parameters
mapToSqlParameter Converts String values to byte[] when the column type is Types.BINARY

Testing

  • Added custom-oauth2-authorization-schema-binary-data-type.sql with binary(10000) column definitions (HSQL equivalent of PostgreSQL BYTEA, mapping to Types.BINARY)
  • Added tableDefinitionWhenBinarySqlTypeThenAuthorizationUpdated() test following the same pattern as the existing CLOB test

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 27, 2026
…Service

PostgreSQL uses BYTEA for binary data, which is reported by the JDBC
driver as Types.BINARY (-2). The JdbcOAuth2AuthorizationService only
handled Types.BLOB and Types.CLOB, causing failures when used with
PostgreSQL (and compatible databases such as AWS Aurora DSQL).

This commit adds handling for Types.BINARY in three places:
- getLobValue: reads bytes and converts to String, trimming trailing
  null bytes that may be present with fixed-length BINARY columns
- doSetValue: writes byte[] or String values via the LobCreator
- mapToSqlParameter: converts String values to byte[] for BINARY columns

Fixes spring-atticgh-2321

Signed-off-by: seungchan <s24041@gsm.hs.kr>
@s-chan-o
s-chan-o force-pushed the fix/jdbc-postgresql-bytea-support branch from 2171724 to e117302 Compare June 4, 2026 07:03
@jgrandja

Copy link
Copy Markdown
Contributor

@s-chan-o

Spring Authorization Server has moved to Spring Security (gh-2195). Please see the Notice. New features and enhancements need to be added in Spring Security.

@jgrandja jgrandja closed this Aug 26, 2026
@jgrandja jgrandja self-assigned this Aug 26, 2026
@jgrandja jgrandja added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Development

Successfully merging this pull request may close these issues.

org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationService should support postgres DB as an implementation

3 participants