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 @Async detection #164

Merged
merged 1 commit into from
Nov 15, 2024
Merged
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 @@ -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
Loading