JavaMoney / jsr354-ri

JSR 354 - Moneta: Reference Implementation
Other
334 stars 100 forks source link

Bump Okhttp 4.12 to Okhttp 5.0.0-alpha.12 ("alpha") #412

Closed DylanLukes closed 3 months ago

DylanLukes commented 5 months ago

I am running into an issue wherein I want to use both the AWS Kotlin SDK and Moneta from this repository in the same project. Unfortunately, some other packages such as the AWS Kotlin SDK transitively depends on okhttp:5.0.0-alpha.11 on JVM, and so we end up with a dependency version conflict at runtime.

While the 5.x API is stable, and has been around over 3 years now, it is still "alpha", though only the APIs introduced in 5.x are unstable:

The alpha releases in the 5.0.0 series have production-quality code and an unstable API. We expect to make changes to the APIs introduced in 5.0.0-alpha.X. These releases are safe for production use and ‘alpha’ strictly signals that we’re still experimenting with some new APIs.

If it's possible to bump the dependency to 5.0.0-alpha.X, that would be nice. The okhttp3 interface has been stable for a while now.

I did a little feasibility exploration doing nothing but bumping the version in pom.xml to 5.0.0-alpha.12:

Build

I was able to successfully build with one warning. That warning is unrelated: Required filename-based automodules detected: [osgi.annotation-8.1.0.jar]. Please don't publish this project to a public artifact repository!

Test

[INFO] Results:
[INFO] 
[INFO] Tests run: 39, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] ------------------------< org.javamoney:moneta >------------------------
[INFO] Building Moneta (JSR 354 RI) 1.4.4                                 [7/7]
[INFO]   from moneta/pom.xml
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Moneta Parent 1.4.4:
[INFO] 
[INFO] Moneta Parent ...................................... SUCCESS [  0.043 s]
[INFO] Moneta Core ........................................ SUCCESS [  6.805 s]
[INFO] Moneta Currency Conversion (Parent) ................ SUCCESS [  0.003 s]
[INFO] Moneta Currency Conversion ......................... SUCCESS [  1.140 s]
[INFO] Moneta Currency Conversion - ECB Provider .......... SUCCESS [ 52.178 s]
[INFO] Moneta Currency Conversion - IMF Provider .......... SUCCESS [ 43.473 s]
[INFO] Moneta (JSR 354 RI) ................................ SUCCESS [  0.001 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:44 min
[INFO] Finished at: 2024-04-11T19:58:54-07:00
[INFO] ------------------------------------------------------------------------

The aforementioned error, to give an example of where the incompatibility comes in. Seems to be only when a library uses one of the 5.x.x specific APIs.

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpUtilsKt.toOkHttpRequest(OkHttpUtils.kt:51)

The following method did not exist:

    'okhttp3.Request$Builder okhttp3.Request$Builder.tag(kotlin.reflect.KClass, java.lang.Object)'

The calling method's class, aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpUtilsKt, was loaded from the following location:

    jar:file:/Users/dylan/.gradle/caches/modules-2/files-2.1/aws.smithy.kotlin/http-client-engine-okhttp-jvm/1.1.3/b0dd25c01125eea76b1ed62eda65c3181382bef5/http-client-engine-okhttp-jvm-1.1.3.jar!/aws/smithy/kotlin/runtime/http/engine/okhttp/OkHttpUtilsKt.class

The called method's class, okhttp3.Request$Builder, is available from the following locations:

    jar:file:/Users/dylan/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/4.12.0/2f4525d4a200e97e1b87449c2cd9bd2e25b7e8cd/okhttp-4.12.0.jar!/okhttp3/Request$Builder.class

The called method's class hierarchy was loaded from the following locations:

    okhttp3.Request.Builder: file:/Users/dylan/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/4.12.0/2f4525d4a200e97e1b87449c2cd9bd2e25b7e8cd/okhttp-4.12.0.jar
keilw commented 3 months ago

Thanks, but we won't use Okhttp 5.0.0 unless it has a Final release. Feel free to build a snapshot or alpha release locally, but we cannot do something "dodgy" just because Amazon or someone else does.