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

Use CompletionService to replace ExecutorSerive in the method org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor.submit(Callable<T>) [SPR-17219] #21752

Closed
spring-projects-issues opened this issue Aug 27, 2018 · 1 comment
Labels
in: core status: duplicate

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Aug 27, 2018

qudh1 opened SPR-17219 and commented

The CompletionService is basically a Queue which returns the Futures in the order which they complete.It would be better to use CompletionService to replace ExecutorSerive in the method org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor.submit(Callable<T>).

Current code is 

@Override @Override public <T> Future<T> submit(Callable<T> task) { ExecutorService executor = getThreadPoolExecutor(); try { return executor.submit(task); } catch (RejectedExecutionException ex) { throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex); } }

Code implement by CompletionService is 

 @Override @Override public <T> Future<T> submit(Callable<T> task) { ExecutorService executor = getThreadPoolExecutor(); CompletionService<T> completionService = new ExecutorCompletionService<>(executor);
 try { return completionService.submit(task); } catch (RejectedExecutionException ex) { throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex); } }

Affects: 5.0.8

Referenced from: pull request #1945

@spring-projects-issues spring-projects-issues added status: waiting-for-triage type: enhancement in: core and removed type: enhancement labels Jan 11, 2019
@snicoll
Copy link
Member

@snicoll snicoll commented Nov 24, 2021

Duplicate of #1945

@snicoll snicoll marked this as a duplicate of #1945 Nov 24, 2021
@snicoll snicoll closed this as completed Nov 24, 2021
@snicoll snicoll added status: duplicate and removed status: waiting-for-triage labels Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: duplicate
Projects
None yet
Development

No branches or pull requests

2 participants