Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule for RestTemplate Apache HttpClient 5 requirement #174

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,35 @@
url: https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-6.0-Release-Notes#web-applications
- title: 'Specific Spring Framwork change'
url: https://github.com/spring-projects/spring-framework/issues/28552

- ruleID: spring-framework-5.x-to-6.0-web-applications-00020
category: mandatory
effort: 5
labels:
- konveyor.io/source=spring5
- konveyor.io/target=spring6+
when:
and:
- java.referenced:
pattern: org.springframework.http.client.HttpComponentsClientHttpRequestFactory
- java.dependency:
name: org.apache.httpcomponents.httpclient
upperbound: 4.5.999999
ignore: true
description: RestTemplate now requires Apache HttpClient 5
message: |
`RestTemplate`, or rather the `HttpComponentsClientHttpRequestFactory`, now requires Apache HttpClient 5.
Please upgrade your HttpClient dependency, ideally to the latest version:

```xml
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.4.1</version>
</dependency>
```
links:
- title: 'Spring 6.0 migration guide'
url: https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-6.0-Release-Notes#web-applications
- title: 'Apache HttpClient 4 to 5 migration guide'
url: https://hc.apache.org/httpcomponents-client-5.4.x/migration-guide/preparation.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
<version>1.7.36</version>
<scope>runtime</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.4</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package org.konveyor;

import java.beans.IntrospectionException;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

import java.net.URI;

public class Main {

public static void main(String[] args) throws IntrospectionException {
public static void main(String[] args) {
RestTemplate rest = new RestTemplate();
rest.getForEntity(URI.create("http://www.example.com/"), Object.class);

HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ tests:
mode: "source-only"
hasIncidents:
exactly: 1
- ruleID: spring-framework-5.x-to-6.0-web-applications-00020
testCases:
- name: tc-1
analysisParams:
mode: "source-only"
hasIncidents:
exactly: 2
Loading