spring-projects / spring-data-couchbase

Provides support to increase developer productivity in Java when using Couchbase. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-couchbase
Apache License 2.0
274 stars 190 forks source link

Compatibility Issue with Spring Data Couchbase and Couchbase Client 3.6.2 #1950

Open maksutspahi opened 1 month ago

maksutspahi commented 1 month ago

Description:

I previously reported an issue with spring-boot-starter-data-couchbase version 3.3.1 using Couchbase client version 3.6.0, which leads to a NoSuchMethodError exception when used with spring-boot-dependencies version 3.3.1 that specifies Couchbase client version 3.6.2. The Spring Boot team suggested that downgrading the Couchbase client dependency is not a viable solution as it may affect users relying on fixes made in versions 3.6.1 and 3.6.2.

Steps to Reproduce:

  1. Set up a Spring Boot project with spring-boot-starter-data-couchbase version 3.3.1.
  2. Use spring-boot-dependencies version 3.3.1.
  3. Attempt to perform a reactive Couchbase insert operation.
  4. Observe the NoSuchMethodError exception.

Expected Behavior:

Spring Data Couchbase should be compatible with Couchbase client version 3.6.2 to avoid runtime exceptions.

Actual Behavior:

A NoSuchMethodError exception is thrown due to a version mismatch between Spring Data Couchbase and the Couchbase client version specified in spring-boot-dependencies.

Environment:

Exception Log:

java.lang.NoSuchMethodError: 'reactor.core.publisher.Mono com.couchbase.client.core.transaction.CoreTransactionAttemptContext.insert(com.couchbase.client.core.io.CollectionIdentifier, java.lang.String, byte[], com.couchbase.client.core.transaction.support.SpanWrapper)'

at org.springframework.data.couchbase.core.ReactiveInsertByIdOperationSupport$ReactiveInsertByIdSupport.lambda$one$2(ReactiveInsertByIdOperationSupport.java:119) ~[spring-data-couchbase-5.3.1.jar!/:5.3.1]

Response from Spring Boot Team:

"Thanks for the report. All that we could do here would be to downgrade to Couchbase Client dependency to 3.6.0. We don't want to do that as users who aren't affected by the problem you have reported may be relying on fixes made in 3.6.1 and 3.6.2. I think the best way to address this would be to update Spring Data Couchbase so that it's compatible with 3.6.2. To that end, please open a Spring Data Couchbase issue." (https://github.com/spring-projects/spring-boot/issues/41445#issuecomment-2222134861)

Possible Solution:

Update Spring Data Couchbase to be compatible with Couchbase client version 3.6.2 to resolve this compatibility issue.


Please let me know if any additional information is needed. Thank you for your attention to this matter.

mikereiche commented 1 month ago

@maksutspahi

I'm not understanding why/how spring-boot-depdendencies version 3.3.1 specifies Couchbase Client version 3.6.2. Why doesn't it just rely on spring-data-couchbase for that? Which has the depdendency of Couchbase Client version 3.6.0. That is the only version that we build and test with.

wilkinsona commented 1 month ago

Spring Boot's dependency management includes 3.6.2 as it's the latest patch release of the client. Our goal is to keep third-party dependencies up-to-date so that users can benefit from the latest bug fixes.

Spring Boot includes auto-configuration for both Couchbase (CouchbaseAutoConfiguration) and Spring Data Couchbase (CouchbaseDataAutoConfiguration and CouchbaseReactiveDataAutoConfiguration). This leaves us in a tricky situation as we can either hold bug fixes back from those only using the former or have an incompatibility that affects some users of the latter. Neither's ideal.

I think there are a few options here. In order of preference, they are:

  1. Updates are made to the Couchbase Client and 3.6.3 is released that's backwards compatible with 3.6.1 and 3.6.0
  2. Updates are made to Spring Data Couchbase so that it's compatible with the breaking changes in 3.6.2
  3. Spring Boot downgrades back to 3.6.0

I'd really like to avoid 3 as it just hides the problem rather than solving it. Anyone who is using Spring Data Couchbase and needs to pick up a bug fix that was made in 3.6.2 will potentially be unable to do so due to the incompatibility. Furthermore, any Spring Boot users who's not using Spring Data Couchbase or is not affected by the current incompatibility will then be exposed to bugs that have already been fixed and will have to manually upgrade.

dnault commented 1 month ago

Tracking on the Couchbase SDK side as https://issues.couchbase.com/browse/JVMCBC-1540