check
check

Reputation: 1

Spring Boot r2dbc enum error - org.springframework.r2dbc.BadSqlGrammarException

I have been working on creating a chat_module application with Reactive programming - spring boot 3.4.1, postgres-r2dbc, and mongo reactive.

While previously I was using Strings for some columns in the postgres, the application was working fine but after i switched to enums it is giving me error.

Controller -

@RestController
@RequestMapping("/test")
@RequiredArgsConstructor
public class TestController {

    private final ChatRoomService chatRoomService;

    @PatchMapping("/update-chatroom/{roomId}")
    public Mono<ChatRoomDto> updateChatRoomLastMessage(@PathVariable Long roomId) {
        ChatRoomDto updateDto = ChatRoomDto.builder()
            .id(roomId)
            .lastMessageAt(LocalDateTime.now())
            .build();
            
        return chatRoomService.updateRoom(roomId, updateDto, 1L);
    }
}

Service -

@Transactional
  public Mono<ChatRoomDto> updateRoom(Long roomId, ChatRoomDto roomDto, Long userId) {
    return chatRoomRepository
        .findById(roomId)
        .switchIfEmpty(Mono.error(new IllegalStateException("Room not found")))
        .flatMap(
            room ->
                chatRoomMemberRepository
                    .findByRoomIdAndUserId(roomId, userId)
                    .switchIfEmpty(
                        Mono.error(new IllegalStateException("Not authorized to update room")))
                    .filter(
                        member ->
                            member.getRole().equals(ChatRoomMemberRole.admin)
                                || member.getRole().equals(ChatRoomMemberRole.moderator))
                    .switchIfEmpty(
                        Mono.error(new IllegalStateException("Not authorized to update room")))
                    .map(
                        member -> {
                          room.setUpdatedAt(LocalDateTime.now());
                          return room;
                        })
                    .flatMap(chatRoomRepository::save)
                    .map(
                        updatedRoom -> toChatRoomDto(updatedRoom, true, ChatRoomMemberRole.admin)));
  }
public enum ChatRoomMemberRole {
  admin,
  moderator,
  member
}
public enum ChatRoomType {
  global,
  open,
  restricted
}

data.sql

CREATE TYPE chat_room_type AS ENUM ('global', 'open', 'restricted');
CREATE TYPE chat_room_visibility AS ENUM ('open', 'restricted');
CREATE TYPE chat_room_member_role AS ENUM ('admin', 'moderator', 'member');

CREATE TABLE chat_room
(
    id              SERIAL PRIMARY KEY,
    name            VARCHAR(255)         NOT NULL,
    type            chat_room_type       NOT NULL,
    visibility      chat_room_visibility NOT NULL,
    creator_id      INT                  REFERENCES app_user (id) ON DELETE SET NULL,
    created_at      TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
    updated_at      TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
    max_members     INT                  NOT NULL,
    current_members INT                      DEFAULT 0,
    tags            TEXT[],
);

INSERT INTO chat_room (name, description, type, visibility, creator_id, max_members, current_members, is_active,
                       room_icon, category, rules, tags, last_message_at, metadata, pinned_message)
VALUES ('General Chat', 'A place for general discussions', 'open', 'open', 1, 100, 2, TRUE, 'general.jpg',
        'General', 'Be respectful', '{"chat", "general"}', '2023-10-27 10:00:00', '{
    "theme": "light"
  }';

When I call the api -

curl --location --request PATCH 'http://localhost:8080/test/update-chatroom/1'

{
    "timestamp": "2025-01-28T21:13:37.479+00:00",
    "status": 500,
    "error": "Internal Server Error",
    "trace": "org.springframework.r2dbc.BadSqlGrammarException: execute; bad SQL grammar [UPDATE chat_room SET name = $1, description = $2, type = $3, visibility = $4, creator_id = $5, created_at = $6, updated_at = $7, max_members = $8, current_members = $9, is_active = $10, room_icon = $11, category = $12, rules = $13, tags = $14, last_message_at = $15, metadata = $16, pinned_message = $17 WHERE chat_room.id = $18]\r\n\tat org.springframework.r2dbc.connection.ConnectionFactoryUtils.convertR2dbcException(ConnectionFactoryUtils.java:253)\r\n\tat org.springframework.r2dbc.core.DefaultDatabaseClient.lambda$inConnection$4(DefaultDatabaseClient.java:135)\r\n\tat reactor.core.publisher.Mono.lambda$onErrorMap$28(Mono.java:3848)\r\n\tat reactor.core.publisher.Mono.lambda$onErrorResume$30(Mono.java:3938)\r\n\tat reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94)\r\n\tat reactor.core.publisher.MonoUsingWhen$MonoUsingWhenSubscriber.deferredError(MonoUsingWhen.java:277)\r\n\tat \reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onNext(FluxHandleFuseable.java:179)\r\n\t... 57 more\r\n",
    "message": "execute; bad SQL grammar [UPDATE chat_room SET name = $1, description = $2, type = $3, visibility = $4, creator_id = $5, created_at = $6, updated_at = $7, max_members = $8, current_members = $9, is_active = $10, room_icon = $11, category = $12, rules = $13, tags = $14, last_message_at = $15, metadata = $16, pinned_message = $17 WHERE chat_room.id = $18]",
    "path": "/test/update-chatroom/1"
}

build.gradle.kts -

plugins {
    java
    id("org.springframework.boot") version "3.4.1"
    id("io.spring.dependency-management") version "1.1.7"
    id("com.diffplug.spotless") version "6.25.0"
}

group = "com.aceplay"
version = "0.0.1-SNAPSHOT"

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

configurations {
    compileOnly {
        extendsFrom(configurations.annotationProcessor.get())
    }
}

repositories {
    mavenCentral()
}

dependencies {
    // Core dependencies
    compileOnly("org.projectlombok:lombok")
    developmentOnly("org.springframework.boot:spring-boot-devtools")
    annotationProcessor("org.projectlombok:lombok")
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    implementation("org.springframework.boot:spring-boot-starter-validation")
    implementation("org.springframework.boot:spring-boot-starter-data-jpa")

    // Reactive PostgreSQL (R2DBC)
    implementation("org.springframework.boot:spring-boot-starter-data-r2dbc")
    implementation("org.postgresql:r2dbc-postgresql:1.0.7.RELEASE")
    // https://mvnrepository.com/artifact/io.r2dbc/r2dbc-pool
    implementation("io.r2dbc:r2dbc-pool:1.0.2.RELEASE")
    // For SSL support
    implementation("org.postgresql:postgresql")

    // MongoDB Reactive
    implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive")

    // Spring Reactive Web (WebFlux)
    implementation("org.springframework.boot:spring-boot-starter-webflux")
    // websockets
    implementation("org.springframework.boot:spring-boot-starter-websocket")

    // Test dependencies
    testImplementation("org.springframework.boot:spring-boot-starter-test")
    testImplementation("io.projectreactor:reactor-test")
    testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
spotless {
    java {
        // Remove unused imports
        removeUnusedImports()

        // Use Google Java formatting
        googleJavaFormat()

        // Import ordering
        importOrder("java", "javax", "org", "com", "")

//        // Add header to all files
//        licenseHeader("/* (C) $YEAR */") // Optional

        // Format all Java files
        target("src/*/java/**/*.java")

        // Enforce indent with spaces
        indentWithSpaces(4)

        // Remove trailing whitespace
        trimTrailingWhitespace()

        // Ensure files end with newline
        endWithNewline()
    }
}
tasks.withType<Test> {
    useJUnitPlatform()
}

I just want to get the proper response after updating the chatroom but getting BadSQLGrammar Exception - that too I am not even updating the type in the update method in chatroom service. Server Logs -

2025-01-29T02:43:35.548+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.QUERY                : Executing query: SELECT oid, * FROM pg_catalog.pg_type WHERE typname IN ('hstore','geometry','vector')
2025-01-29T02:43:36.132+05:30 DEBUG 54128 --- [chat_module] [nio-8080-exec-1] o.s.r.c.R2dbcTransactionManager          : Creating new transaction with name [com.aceplay.chat_module.service.ChatRoomService.updateRoom]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2025-01-29T02:43:36.148+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.QUERY                : Executing query: SELECT 1
2025-01-29T02:43:36.298+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] o.s.r.c.R2dbcTransactionManager          : Acquired Connection [PooledConnection[PostgresqlConnection{client=io.r2dbc.postgresql.client.ReactorNettyClient@789840b4, codecs=io.r2dbc.postgresql.codec.DefaultCodecs@f1a87cb}]] for R2DBC transaction
2025-01-29T02:43:36.299+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] o.s.r.c.R2dbcTransactionManager          : Starting R2DBC transaction on Connection [PooledConnection[PostgresqlConnection{client=io.r2dbc.postgresql.client.ReactorNettyClient@789840b4, codecs=io.r2dbc.postgresql.codec.DefaultCodecs@f1a87cb}]] using [ExtendedTransactionDefinition [transactionName='com.aceplay.chat_module.service.ChatRoomService.updateRoom', readOnly=false, isolationLevel=null, lockWaitTimeout=PT0S]]
2025-01-29T02:43:36.301+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.QUERY                : Executing query: BEGIN READ WRITE
2025-01-29T02:43:36.458+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] o.s.r2dbc.core.DefaultDatabaseClient     : Executing SQL statement [SELECT chat_room.* FROM chat_room WHERE chat_room.id = $1 LIMIT 2]
2025-01-29T02:43:36.462+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [0] to: 1
2025-01-29T02:43:36.500+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.QUERY                : Executing query: SELECT chat_room.* FROM chat_room WHERE chat_room.id = $1 LIMIT 2
2025-01-29T02:43:36.849+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] o.s.r2dbc.core.DefaultDatabaseClient     : Executing SQL statement [SELECT * FROM chat_room_member WHERE room_id = $1 AND user_id = $2]
2025-01-29T02:43:36.851+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [0] to: 1
2025-01-29T02:43:36.851+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [1] to: 1
2025-01-29T02:43:36.854+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.QUERY                : Executing query: SELECT * FROM chat_room_member WHERE room_id = $1 AND user_id = $2
2025-01-29T02:43:37.097+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-5] io.r2dbc.postgresql.QUERY                : Executing query: SHOW TRANSACTION ISOLATION LEVEL
2025-01-29T02:43:37.114+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] o.s.r2dbc.core.DefaultDatabaseClient     : Executing SQL statement [UPDATE chat_room SET name = $1, description = $2, type = $3, visibility = $4, creator_id = $5, created_at = $6, updated_at = $7, max_members = $8, current_members = $9, is_active = $10, room_icon = $11, category = $12, rules = $13, tags = $14, last_message_at = $15, metadata = $16, pinned_message = $17 WHERE chat_room.id = $18]
2025-01-29T02:43:37.114+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [0] to: General Chat
2025-01-29T02:43:37.115+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [1] to: A place for general discussions
2025-01-29T02:43:37.115+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [2] to: open
2025-01-29T02:43:37.115+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [3] to: open
2025-01-29T02:43:37.115+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [4] to: 1
2025-01-29T02:43:37.115+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [5] to: 2025-01-29T02:09:46.810697
2025-01-29T02:43:37.115+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [6] to: 2025-01-29T02:43:37.102447400
2025-01-29T02:43:37.115+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [7] to: 100
2025-01-29T02:43:37.115+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [8] to: 2
2025-01-29T02:43:37.115+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [9] to: true
2025-01-29T02:43:37.115+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [10] to: general.jpg
2025-01-29T02:43:37.115+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [11] to: General
2025-01-29T02:43:37.115+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [12] to: Be respectful
2025-01-29T02:43:37.115+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [13] to: [Ljava.lang.String;@1889c1d5
2025-01-29T02:43:37.116+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [14] to: 2023-10-27T15:30
2025-01-29T02:43:37.116+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [15] to: {"theme": "light"}
2025-01-29T02:43:37.116+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [16] to: {"userId": 1, "message": "Welcome!"}
2025-01-29T02:43:37.116+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.PARAM                : Bind parameter [17] to: 1
2025-01-29T02:43:37.118+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.QUERY                : Executing query: UPDATE chat_room SET name = $1, description = $2, type = $3, visibility = $4, creator_id = $5, created_at = $6, updated_at = $7, max_members = $8, current_members = $9, is_active = $10, room_icon = $11, category = $12, rules = $13, tags = $14, last_message_at = $15, metadata = $16, pinned_message = $17 WHERE chat_room.id = $18
2025-01-29T02:43:37.256+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-5] io.r2dbc.postgresql.QUERY                : Executing query: SELECT oid, * FROM pg_catalog.pg_type WHERE typname IN ('hstore','geometry','vector')
2025-01-29T02:43:37.261+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] o.s.r.c.R2dbcTransactionManager          : Initiating transaction rollback
2025-01-29T02:43:37.261+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] o.s.r.c.R2dbcTransactionManager          : Rolling back R2DBC transaction on Connection [PooledConnection[PostgresqlConnection{client=io.r2dbc.postgresql.client.ReactorNettyClient@789840b4, codecs=io.r2dbc.postgresql.codec.DefaultCodecs@f1a87cb}]]
2025-01-29T02:43:37.263+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] io.r2dbc.postgresql.QUERY                : Executing query: ROLLBACK
2025-01-29T02:43:37.417+05:30 DEBUG 54128 --- [chat_module] [actor-tcp-nio-4] o.s.r.c.R2dbcTransactionManager          : Releasing R2DBC Connection [PooledConnection[PostgresqlConnection{client=io.r2dbc.postgresql.client.ReactorNettyClient@789840b4, codecs=io.r2dbc.postgresql.codec.DefaultCodecs@f1a87cb}]] after transaction
2025-01-29T02:43:37.449+05:30 ERROR 54128 --- [chat_module] [nio-8080-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] threw exception

io.r2dbc.postgresql.ExceptionFactory$PostgresqlBadGrammarException: column "type" is of type chat_room_type but expression is of type character varying
    at io.r2dbc.postgresql.ExceptionFactory.createException(ExceptionFactory.java:96) ~[r2dbc-postgresql-1.0.7.RELEASE.jar:1.0.7.RELEASE]
    at io.r2dbc.postgresql.ExceptionFactory.createException(ExceptionFactory.java:65) ~[r2dbc-postgresql-1.0.7.RELEASE.jar:1.0.7.RELEASE]
    at io.r2dbc.postgresql.ExceptionFactory.handleErrorResponse(ExceptionFactory.java:132) ~[r2dbc-postgresql-1.0.7.RELEASE.jar:1.0.7.RELEASE]
    
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.116.Final.jar:4.1.116.Final]
    at java.base/java.lang.Thread.run(Thread.java:842) ~[na:na]

2025-01-29T02:43:37.458+05:30 ERROR 54128 --- [chat_module] [nio-8080-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.r2dbc.BadSqlGrammarException: execute; bad SQL grammar [UPDATE chat_room SET name = $1, description = $2, type = $3, visibility = $4, creator_id = $5, created_at = $6, updated_at = $7, max_members = $8, current_members = $9, is_active = $10, room_icon = $11, category = $12, rules = $13, tags = $14, last_message_at = $15, metadata = $16, pinned_message = $17 WHERE chat_room.id = $18]] with root cause

io.r2dbc.postgresql.ExceptionFactory$PostgresqlBadGrammarException: column "type" is of type chat_room_type but expression is of type character varying
    at io.r2dbc.postgresql.ExceptionFactory.createException(ExceptionFactory.java:96) ~[r2dbc-postgresql-1.0.7.RELEASE.jar:1.0.7.RELEASE]
    at io.r2dbc.postgresql.ExceptionFactory.createException(ExceptionFactory.java:65) ~[r2dbc-postgresql-1.0.7.RELEASE.jar:1.0.7.RELEASE]
    at io.r2dbc.postgresql.ExceptionFactory.handleErrorResponse(ExceptionFactory.java:132) ~[r2dbc-postgresql-1.0.7.RELEASE.jar:1.0.7.RELEASE]
    at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onNext(FluxHandleFuseable.java:179) ~[reactor-core-3.7.1.jar:3.7.1]
    at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:337) ~[reactor-core-3.7.1.jar:3.7.1]
    at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107) ~[reactor-core-3.7.1.jar:3.7.1]
    at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:854) ~[reactor-core-3.7.1.jar:3.7.1]
    at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:854) ~[reactor-core-3.7.1.jar:3.7.1]
    at io.r2dbc.postgresql.util.FluxDiscardOnCancel$FluxDiscardOnCancelSubscriber.onNext(FluxDiscardOnCancel.java:91) ~[r2dbc-postgresql-1.0.7.RELEASE.jar:1.0.7.RELEASE]
    at reactor.core.publisher.FluxDoFinally$DoFinallySubscriber.onNext(FluxDoFinally.java:113) ~[reactor-core-3.7.1.jar:3.7.1]
    at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:129) ~[reactor-core-3.7.1.jar:3.7.1]
    at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:880) ~[reactor-core-3.7.1.jar:3.7.1]
    at reactor.core.publisher.FluxCreate$BufferAsyncSink.next(FluxCreate.java:805) ~[reactor-core-3.7.1.jar:3.7.1]
    at reactor.core.publisher.FluxCreate$SerializedFluxSink.next(FluxCreate.java:163) ~[reactor-core-3.7.1.jar:3.7.1]
    at io.r2dbc.postgresql.client.ReactorNettyClient$Conversation.emit(ReactorNettyClient.java:696) ~[r2dbc-postgresql-1.0.7.RELEASE.jar:1.0.7.RELEASE]
    at io.r2dbc.postgresql.client.ReactorNettyClient$BackendMessageSubscriber.emit(ReactorNettyClient.java:948) ~[r2dbc-postgresql-1.0.7.RELEASE.jar:1.0.7.RELEASE]
    at io.r2dbc.postgresql.client.ReactorNettyClient$BackendMessageSubscriber.onNext(ReactorNettyClient.java:822) ~[r2dbc-postgresql-1.0.7.RELEASE.jar:1.0.7.RELEASE]
    at io.r2dbc.postgresql.client.ReactorNettyClient$BackendMessageSubscriber.onNext(ReactorNettyClient.java:728) ~[r2dbc-postgresql-1.0.7.RELEASE.jar:1.0.7.RELEASE]
    at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:129) ~[reactor-core-3.7.1.jar:3.7.1]
    at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:854) ~[reactor-core-3.7.1.jar:3.7.1]
    at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:224) ~[reactor-core-3.7.1.jar:3.7.1]
    at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:224) ~[reactor-core-3.7.1.jar:3.7.1]
    at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:292) ~[reactor-netty-core-1.2.1.jar:1.2.1]
    at reactor.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:401) ~[reactor-netty-core-1.2.1.jar:1.2.1]
    at reactor.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:435) ~[reactor-netty-core-1.2.1.jar:1.2.1]
    at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:115) ~[reactor-netty-core-1.2.1.jar:1.2.1]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346) ~[netty-codec-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318) ~[netty-codec-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.r2dbc.postgresql.client.SSLSessionHandlerAdapter.channelRead(SSLSessionHandlerAdapter.java:85) ~[r2dbc-postgresql-1.0.7.RELEASE.jar:1.0.7.RELEASE]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1503) ~[netty-handler-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1366) ~[netty-handler-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1415) ~[netty-handler-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:530) ~[netty-codec-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:469) ~[netty-codec-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290) ~[netty-codec-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1357) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:868) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) ~[netty-transport-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.116.Final.jar:4.1.116.Final]
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.116.Final.jar:4.1.116.Final]
    at java.base/java.lang.Thread.run(Thread.java:842) ~[na:na]

  1. I tried adding custom config to map enums but still nothing

@Configuration
public class R2dbcConfig {

  @Bean
  public List<Object> r2dbcCustomConverters() {
    List<Object> converters = new ArrayList<>();
    converters.add(new ChatRoomTypeReadingConverter());
    converters.add(new ChatRoomTypeWritingConverter());
    return converters;
  }

  @Bean
  public CodecRegistrar enumCodecRegistrar() {
    return EnumCodec.builder()
        .withEnum("chat_room_type", ChatRoomType.class)
        .withEnum("chat_room_visibility", ChatRoomVisibility.class)
        .withEnum("chat_room_member_role", ChatRoomMemberRole.class)
        .withEnum("notification_preference", NotificationPreference.class)
        .withEnum("gender", Gender.class)
        .build();
  }
}
@ReadingConverter
public class ChatRoomTypeReadingConverter implements Converter<String, ChatRoomType> {
  @Override
  public ChatRoomType convert(String source) {
    return source != null ? ChatRoomType.valueOf(source.toUpperCase()) : null;
  }
}
@WritingConverter
public class ChatRoomTypeWritingConverter implements Converter<ChatRoomType, String> {
  @Override
  public String convert(ChatRoomType source) {
    return source.name().toLowerCase();
  }
}

Upvotes: 0

Views: 60

Answers (0)

Related Questions