spring-projects / spring-boot

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss.
https://spring.io/projects/spring-boot
Apache License 2.0
75.24k stars 40.7k forks source link

kotlinx-coroutines-bom seems to break upgrade to Spring Boot 2.7.1 #31521

Closed jesperancinha closed 2 years ago

jesperancinha commented 2 years ago

Hi there, I'm not sure if I should open the issue here too but I noticed that after trying to upgrade to Spring boot 2.7.1 I'm getting this error:

[ERROR] Failed to execute goal on project stamps-and-coins-service: 
Could not resolve dependencies for project 
org.jesperancinha.enterprise:stamps-and-coins-service:jar:0.0.1-SNAPSHOT: org.jetbrains.kotlinx:kotlinx-coroutines-bom:jar:1.6.3 was not found in 
https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

I dug into the BOM of spring boot and I found that it is using kotlinx-coroutines-bom 1.6.3 which is using kotlinx-coroutines-debug dependency which wants to download apparently a BOM as a jar file:

    <dependency>
      <groupId>org.jetbrains.kotlinx</groupId>
      <artifactId>kotlinx-coroutines-bom</artifactId>
      <version>1.6.3</version>
      <scope>runtime</scope>
    </dependency>

Have you seen this issue and are you going to release a fix soon?

Thanks!

wilkinsona commented 2 years ago

No, we haven't seen this as far as I know. Our Gradle-based build is not affected and a Maven-based project that we build as part of the release process was also unaffected. Perhaps the problem only occurs with certain dependencies. Can you please provide a minimal sample that reproduces the problem so that we can assess its impact?

jesperancinha commented 2 years ago

Yes you are right about that. It does not occur in the projects where I do not use coroutines. But if I use coroutines, it apparently goes through the build of materials and then it tries to download kotlinx-coroutines-bom.jar which of course does not exist. So indeed this is something related when using some dependencies. I've also opened an issue to them about this, because this isn't something particularly related to Spring Boot: https://github.com/Kotlin/kotlinx.coroutines/issues/3345

I'll make a sample project for you today about this.

jesperancinha commented 2 years ago

@wilkinsona , maybe this log output helps? It's one of my projects in GitLab. It's a much simpler project: https://gitlab.com/jesperancinha/video-series-app/-/jobs/2634783454

jesperancinha commented 2 years ago

@wilkinsona And this after I've removed the kotlinx-coroutines BOM from the pom file of that same project: https://gitlab.com/jesperancinha/video-series-app/-/jobs/2635016725

So it just happens whenever I include certain coroutine dependencies that make use of the couroutines debug library, I suppose. But of course apparently Spring Boot now also includes coroutines (I don't know when this started) so this is why I've opened this issue also to you.

jesperancinha commented 2 years ago

I think I found out what's needing that debug library.

        <dependency>
            <groupId>io.kotest</groupId>
            <artifactId>kotest-runner-junit5-jvm</artifactId>
            <scope>test</scope>
        </dependency>

Tough one this one :) because then it will only happen to whoever is using Kotest, but apparently this one actually starts in kotlinx coroutines, that's where the problem seems to begin. I'm waiting for a reaction from them at the moment, but this seems to be an issue with the kotlinx-couroutines libraries.

wilkinsona commented 2 years ago

Thanks, @jesperancinha. We import kotlinx-coroutines-bom into our spring-boot-dependencies bom. In 2.7.1 we've upgraded from 1.6.1 to 1.6.3 which means that any dependency on the debug library now uses a version with a faulty pom. This didn't affect Boot's build as we do not depend, directly or transitively, on kotlinx-coroutines-debug. You can work around the problem by setting kotlin-coroutines.version to 1.6.1.

Given that the problem is limited to users kotlinx-coroutines-debug and that there is a workaround, we'll leave things as they are in Spring Boot. We'll pick up 1.6.4 when it's released which should address the problem at source.