Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
remove use of ForkJoinPool in SubmissionController (#399) (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-burwig authored and ole-lilienthal committed Jun 10, 2020
1 parent ca2268d commit 68834f8
Showing 1 changed file with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.apache.commons.math3.distribution.PoissonDistribution;
Expand Down Expand Up @@ -62,7 +61,6 @@ public class SubmissionController {

private final SubmissionControllerMonitor submissionControllerMonitor;
private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
private final ForkJoinPool forkJoinPool = ForkJoinPool.commonPool();
private final DiagnosisKeyService diagnosisKeyService;
private final TanVerifier tanVerifier;
private final Double fakeDelayMovingAverageSamples;
Expand Down Expand Up @@ -115,23 +113,21 @@ private DeferredResult<ResponseEntity<Void>> buildFakeDeferredResult() {
private DeferredResult<ResponseEntity<Void>> buildRealDeferredResult(SubmissionPayload exposureKeys, String tan) {
DeferredResult<ResponseEntity<Void>> deferredResult = new DeferredResult<>();

forkJoinPool.submit(() -> {
try {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
if (!this.tanVerifier.verifyTan(tan)) {
submissionControllerMonitor.incrementInvalidTanRequestCounter();
deferredResult.setResult(buildTanInvalidResponseEntity());
} else {
persistDiagnosisKeysPayload(exposureKeys);
deferredResult.setResult(buildSuccessResponseEntity());
stopWatch.stop();
updateFakeDelay(stopWatch.getTotalTimeMillis());
}
} catch (Exception e) {
deferredResult.setErrorResult(e);
try {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
if (!this.tanVerifier.verifyTan(tan)) {
submissionControllerMonitor.incrementInvalidTanRequestCounter();
deferredResult.setResult(buildTanInvalidResponseEntity());
} else {
persistDiagnosisKeysPayload(exposureKeys);
deferredResult.setResult(buildSuccessResponseEntity());
stopWatch.stop();
updateFakeDelay(stopWatch.getTotalTimeMillis());
}
});
} catch (Exception e) {
deferredResult.setErrorResult(e);
}

return deferredResult;
}
Expand Down

0 comments on commit 68834f8

Please sign in to comment.