I use spring boot 3.3.3. There is a dependency problem in spring boot 3.3.3.

SpringBoot Dependency management brings an invalid combination of HttpCore5 and HttpClient5

And I think https://github.com/spring-projects/spring-boot/issues/41374 update may casue this problem.

import org.apache.hc.client5.http.classic.HttpClient
import org.apache.hc.client5.http.config.ConnectionConfig
import org.apache.hc.client5.http.config.RequestConfig
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager
import org.apache.hc.core5.util.Timeout

class HttpClient5ClientFactory {

  companion object {
    fun createHttpClient5Client(): HttpClient {
      val connectionManager = PoolingHttpClientConnectionManager()
      connectionManager.defaultMaxPerRoute = 100
      connectionManager.maxTotal = 100
      connectionManager.setDefaultConnectionConfig(
        ConnectionConfig.custom()
          .setConnectTimeout(Timeout.ofSeconds(1))
          .build()
      )
      val requestConfig = RequestConfig.custom()
        .setResponseTimeout(Timeout.ofSeconds(5))
        .build()

      val httpClientBuilder = HttpClientBuilder.create()
        .useSystemProperties()
        .setConnectionManager(connectionManager)
        .setDefaultRequestConfig(requestConfig)

      val httpClient = httpClientBuilder.build()
      return httpClient
    }
  }
}

Comment From: bclozel

It looks like a duplicate of https://github.com/spring-projects/spring-framework/issues/33806

Can you try with Framework SNAPSHOTs and report back?

Comment From: donguseo

This doesn't seem to be the same issue. Apache HttpClient 5.3.1 is built with HttpCore5 version 5.2.4. However, in the Gradle file with dependency information on the Spring Boot 3.3.x branch, it specifies version 5.2.5. Although the build succeeds without issues, it's stressful to keep seeing those red underlines in IntelliJ while working. Please compare and verify the versions in the two links below.

https://mvnrepository.com/artifact/org.apache.httpcomponents.client5/httpclient5/5.3.1 https://github.com/spring-projects/spring-boot/blob/3.3.x/spring-boot-project/spring-boot-dependencies/build.gradle

Comment From: bclozel

Thanks for your feedback. I'm still not sure I understand this case. I don't think Spring Boot is bringing multiple or conflicting org.apache.httpcomponents.core5:httpcore5 versions in the classpath. Can you check your application dependency management and report back? Where are the multiple/conflicting versions coming from?

Thanks

Comment From: donguseo

I just created a sample project and uploaded it to my GitHub repository. Please download it from the link below and check it out. https://github.com/donguseo/httpcore-dependency

When you open the project in IntelliJ and open the HttpClient5ClientFactory.kt file, you should definitely see the red underlines. You'll also see the httpcore5 version listed as 5.2.5 in the dependencies.

Then, open the build.gradle.kts file and comment out all Spring-related plugins. Rebuild with Gradle, and you’ll notice that the red underlines are gone, and the httpcore5 version has reverted to 5.2.4.

It seems that version 5.2.5 had some changes related to the minimum and maximum JDK versions, which might be causing this issue. I don't have the time to analyze it further. :(

Sorry I couldn't be of more help. This is probably all I can do for now. I hope that in the next or subsequent version, this issue will be resolved.

Comment From: bclozel

@donguseo why is this closed?

Comment From: donguseo

@donguseo why is this closed?

I considered it a Spring Boot issue, but it was transferred to the Spring Framework, and after that, I received no further feedback on the problem I raised.

I closed the issue because it seemed you weren't taking it seriously. I don't intend to raise this issue again. The quickest solution would be for me to simply use Spring Boot 3.3.1, so it's not a major problem for me. Alternatively, I could resolve it by setting up a separate module for the part that uses Apache HTTP Core and adjusting dependencies accordingly. Even if there’s a red line, it still builds fine, so it’s not critical—just inconvenient.

If you consider my inconvenience a significant issue, I’d appreciate it if you could address it; otherwise, please feel free to disregard it.

Comment From: bclozel

We'll have a look. 19 hours is a very short amount of time to consider an issue as disregarded. I will move back this issue to Spring Boot if it turns out to be a bug there.

Comment From: donguseo

I was too hasty. Thank you.

Comment From: snicoll

Thanks for the sample. Looking at what makes it work based on your description, force downgrading HttpCore5 to 5.2.4, makes the error go away. I've added this to your build:

extra["httpcore5.version"] = "5.2.4"

However, I am not sure what the error comes from. Yes the IDE shows an error for me as well but compilation works. Looking at the changelog between 5.2.4 and 5.2.5 I don't see a change that would lead to this problem. At this point, it looks like an error in the IDE.

@donguseo can you make the sample actually fail outside of the IDE? Something like compilation that does not work or an error at runtime?

Comment From: snicoll

The IDE does not show an error for the same code written in Java.

@sdeleuze does that ring any bell?

Comment From: donguseo

@snicoll Thank you. Applying it as you described removed the error I mentioned. It seems this resolves the issue I was facing.

Outside of the IDE, there were no problems. The code compiled well, and the functionality worked as expected. Since it’s still in development, I haven't seen any issues in the production environment.

I also checked the changes in httpcore5’s code, and nothing stood out as a significant problem. If you find out why this issue occurred, I’d appreciate any additional comments.

Comment From: snicoll

@donguseo alright, thanks for confirming. Please report this issue to https://youtrack.jetbrains.com/issues. I am going to close this one but feel free to add a link to the issue you've created so that we can follow along.