Skip to content

BOM is not defining the OkHttp version #1508

@bcmedeiros

Description

@bcmedeiros

Describe the bug

I'm currently using a few AWS Kotlin SDK modules with the current setup:

<project>
   <dependencyManagement>
        <dependencies>
            <!-- AWS -->
            <dependency>
                <groupId>aws.sdk.kotlin</groupId>
                <artifactId>bom</artifactId>
                <version>1.3.112</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
   </dependencyManagement>
    ...
    <dependencies>
        <!-- AWS -->
        <dependency>
            <groupId>aws.sdk.kotlin</groupId>
            <artifactId>cognitoidentityprovider-jvm</artifactId>
        </dependency>
    </dependencies>
</project>

The issue is, even though I'm importing the aws.sdk.kotlin:bom BOM, I end up with OkHttp 4.12 in my classpath as defined by another BOM I'm inheriting from (Spring Boot), rather than the required 5.0.0-alpha-4, which is the required one.
Image

This causes all sorts of issues in my app, the simplest one to reproduce being the one below:

java.lang.NoClassDefFoundError: okhttp3/ConnectionListener
	at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngineKt.buildClientWithConnectionListener(OkHttpEngine.kt:165)
	at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngineKt.access$buildClientWithConnectionListener(OkHttpEngine.kt:1)
	at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngine.<init>(OkHttpEngine.kt:48)
	at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngine$Companion.invoke(OkHttpEngine.kt:41)
	at aws.smithy.kotlin.runtime.http.engine.DefaultHttpEngineJVMKt.newDefaultHttpEngine(DefaultHttpEngineJVM.kt:14)
	at aws.smithy.kotlin.runtime.http.engine.DefaultHttpEngineKt.DefaultHttpEngine(DefaultHttpEngine.kt:24)
	at aws.smithy.kotlin.runtime.http.engine.HttpEngineConfigImpl$BuilderImpl$engineConstructor$1.invoke(HttpEngineConfigImpl.kt:20)
	at aws.smithy.kotlin.runtime.http.engine.HttpEngineConfigImpl$BuilderImpl$engineConstructor$1.invoke(HttpEngineConfigImpl.kt:20)
	at aws.smithy.kotlin.runtime.http.engine.HttpEngineConfigImpl$BuilderImpl.engineSupplier$lambda$2(HttpEngineConfigImpl.kt:21)
	at aws.smithy.kotlin.runtime.http.engine.HttpEngineConfigImpl$BuilderImpl.buildHttpEngineConfig(HttpEngineConfigImpl.kt:77)
	at aws.sdk.kotlin.services.cognitoidentityprovider.CognitoIdentityProviderClient$Config$Builder.buildHttpEngineConfig(CognitoIdentityProviderClient.kt)

If I include the OkHttp BOM as follows directly in my file, then the problem is fixed:

            <dependency>
                <groupId>com.squareup.okhttp3</groupId>
                <artifactId>okhttp-bom</artifactId>
                <version>5.0.0-alpha.14</version> <!-- AWS Kotlin SDK needs 5.x, and there are no other users of OkHttp, so overriding Spring's default -->
                <type>pom</type>
                <scope>import</scope>
            </dependency>

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected behavior

Declaring the aws.sdk.kotlin:bom with the correct precedence over other BOMs being imported should be enough to have all the dependencies AWS Kotlin SDK needs to run.

Current behavior

SDK fails when making any HTTP calls because the OkHttp version needed is not declared in the BOM.

Steps to Reproduce

  1. Create a Spring Boot app with version 3.3.7
  2. Add the BOM in the description to de dependency management section and
  3. Any AWS SDK module that needs HTTP access to the dependency section
  4. Write some code to use the SDK module
  5. Run your app

Possible Solution

I think the aws.sdk.kotlin:bom artifact should declare a dependencyManagement entry with the following import, so people are more likely to get the correct version or at least see a conflict showing up when analyzing the issue.

            <dependency>
                <groupId>com.squareup.okhttp3</groupId>
                <artifactId>okhttp-bom</artifactId>
                <version>5.0.0-alpha.14</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

Context

No response

AWS SDK for Kotlin version

1.3.112

Platform (JVM/JS/Native)

JVM

Operating system and version

MacOS 15.2

Metadata

Metadata

Assignees

Labels

feature-requestA feature should be added or improved.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions