Skip to content

Commit

Permalink
Rule for @async detection
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Manuel Leflet Estrada <jleflete@redhat.com>
  • Loading branch information
jmle committed Nov 5, 2024
1 parent 7f8f5b0 commit b26f625
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,24 @@
links:
- title: 'Spring 6.0 migration guide'
url: https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-6.0-Release-Notes#core-container

- ruleID: spring-framework-5.x-to-6.0-core-container-00010
category: potential
effort: 2
labels:
- konveyor.io/source=spring5
- konveyor.io/target=spring6+
when:
java.referenced:
pattern: org.springframework.scheduling.annotation.Async
location: ANNOTATION
description: Methods annotated with @Async must return either Future or void
message: |
Methods annotated with @Async must return either Future or void. This has long been documented but is now also
actively checked and enforced, with an exception thrown for any other return type.
If your @Async annotated method does not return `Future` or `void`, please change its signature.
links:
- title: 'Spring 6.0 migration guide'
url: https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-6.0-Release-Notes#core-container

Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
package org.konveyor;

import org.konveyor.beans.Bean;
import org.springframework.beans.BeanInfoFactory;
import org.springframework.beans.SimpleBeanInfoFactory;
import org.springframework.scheduling.annotation.Async;

import java.beans.BeanInfo;
import java.beans.IntrospectionException;

import org.springframework.beans.BeanInfoFactory;
import org.springframework.beans.SimpleBeanInfoFactory;
import java.util.concurrent.RunnableFuture;

public class Main {

public static void main(String[] args) throws IntrospectionException {
BeanInfoFactory factory = new SimpleBeanInfoFactory();
BeanInfo beanInfo = factory.getBeanInfo(Bean.class);
System.out.println(beanInfo.getBeanDescriptor());


}

@Async
public RunnableFuture<String> correctAsyncMethod(String param) {
return null;
}

@Async
public void correctAsyncMethod2(String param) {
}

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

0 comments on commit b26f625

Please sign in to comment.