Search code examples
okhttpminio

Issue with okhttp and minio 3.x packages


I have a Java 8 project using Maven to import io.minio minio package. We have been using minio package 8.2.1 but due to this vulnerability we are trying to update this package to a newer version. After trying to update to any of the 8.3 versions, I get the following stacktrace while trying to construct a new MinioClient object:

Caused by: java.lang.RuntimeException: Unsupported OkHttp library found. Must use okhttp >= 4.8.1
    at io.minio.S3Base.<clinit>(S3Base.java:100)
    ... 26 more
Caused by: java.lang.NoSuchMethodError: kotlin.collections.ArraysKt.copyInto([B[BIII)[B
    at okio.Segment.writeTo(Segment.kt:169)
    at okio.Segment.compact(Segment.kt:152)
    at okio.Buffer.write(Buffer.kt:1842)
    at okio.Buffer.read(Buffer.kt:1854)
    at okio.Buffer.writeAll(Buffer.kt:1642)
    at okio.Options$Companion.buildTrieRecursive(Options.kt:187)
    at okio.Options$Companion.buildTrieRecursive(Options.kt:174)
    at okio.Options$Companion.buildTrieRecursive$default(Options.kt:113)
    at okio.Options$Companion.of(Options.kt:72)
    at okhttp3.internal.Util.<clinit>(Util.kt:71)
    at okhttp3.RequestBody$Companion.create(RequestBody.kt:145)
    at okhttp3.RequestBody$Companion.create$default(RequestBody.kt:143)
    at okhttp3.RequestBody.create(RequestBody.kt)
    at io.minio.S3Base.<clinit>(S3Base.java:98)
    ... 26 more

I am not overriding the okhttp package (4.8.1) included in minio 8.3.X. I have verified maven is using okhttp3 4.8.1 (only) both in the External Libraries section of IntelliJ project viewer and by running mvn dependency:tree and seeing that there's only a single okhttp3 package in use by the project (v4.8.1). Anyone know how to resolve this error?


Solution

  • Your build tool should be pulling in OkHttp’s transitive dependencies, Okio and Kotlin-stdlib. It appears from this stacktrace that the Kotlin stdlib is either outdated or absent? Update that and this crash should be fixed.