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

remove use of ForkJoinPool in SubmissionController (#399) #518

Merged
merged 1 commit into from
Jun 10, 2020
Merged
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 @@ -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