- Java 17
- Spring Boot v2.7.4
- MySQL 5.7
- MariaDB R2DBC driver (see why)
MySQL:
CREATE TABLE `some_table`
(
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`json` JSON DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;
INSERT INTO some_table (id, json) VALUE (1, '{}');
Mapping:
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table("some_table")
public class SomeTable {
@Id
@Column("id")
private Long id;
@Column("json")
private String json;
}
Repository:
@Repository
public interface SomeTableRepository extends ReactiveCrudRepository<SomeTable, Long> {
}
When calling someTableRepository.findById(1L), the returned SomeTable#json is expected to be "{}" but it actually is "123,125". Not sure where that cryptic 123,125 comes from. According to https://stackoverflow.com/a/21343591/1225328, "123 and 125 is ascii for { and }", but that doesn't explain why it started failing with v2.7.4.
Works fine with Spring Boot v2.7.3.
Probably due to some dependency upgrade but I can't find my way out of the dependency tree of Spring Boot 🙈
Replicated in https://github.com/sp00m/spring-boot-2.7.4-r2dbc-json-issue, see https://github.com/sp00m/spring-boot-2.7.4-r2dbc-json-issue/blob/master/src/test/java/base/SomeTableRepositoryTest.java#L42 which passes with v2.7.3, but fails with v2.7.4:
expected value: SomeTable(id=1, json={}); actual value: SomeTable(id=1, json=123,125)
Comment From: wilkinsona
Thanks for the easy-to-use sample.
This appears to be a regression in R2DBC Borca-SR2. Things work fine with SR1. More specifically, the problem appears to be in 1.1.2 of the MariaDB driver. The problem does not occur with 1.1.1-rc, the version included in Borca-SR1. I think this should be reported here. /cc @mp911de