Skip to content

Commit

Permalink
Add rule for RestTemplate + Apache HttpClient
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Manuel Leflet Estrada <[email protected]>
  • Loading branch information
jmle committed Nov 20, 2024
1 parent 82ec756 commit ce74de7
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,36 @@
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.web.client.RestTemplate
location: CONSTRUCTOR_CALL
- 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:
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,14 @@
package org.konveyor;

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

public class Main {
import java.net.URI;

public static void main(String[] args) throws IntrospectionException {
public class Main {

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

}
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: 1

0 comments on commit ce74de7

Please sign in to comment.