- Fix the "IndexOutOfBoundsException", when checking the futures' results.

- Update dependencies.
This commit is contained in:
Lampros Smyrnaios 2023-10-20 14:25:05 +03:00
parent df0ea62a5a
commit 44c2fe7418
2 changed files with 12 additions and 5 deletions

View File

@ -1,5 +1,5 @@
plugins {
id 'org.springframework.boot' version '2.7.16'
id 'org.springframework.boot' version '2.7.17'
id 'io.spring.dependency-management' version '1.1.3'
id 'java'
}
@ -43,7 +43,7 @@ dependencies {
//implementation group: 'jakarta.validation', name: 'jakarta.validation-api', version: '3.0.2'
// https://mvnrepository.com/artifact/com.google.guava/guava
implementation group: 'com.google.guava', name: 'guava', version: '32.1.2-jre'
implementation group: 'com.google.guava', name: 'guava', version: '32.1.3-jre'
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.13.0'
@ -113,14 +113,14 @@ dependencies {
implementation 'com.fasterxml.woodstox:woodstox-core:6.5.1'
// https://mvnrepository.com/artifact/org.json/json
implementation 'org.json:json:20230618'
implementation 'org.json:json:20231013'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation 'com.google.code.gson:gson:2.10.1'
// https://mvnrepository.com/artifact/io.micrometer/micrometer-registry-prometheus
runtimeOnly 'io.micrometer:micrometer-registry-prometheus:1.11.4'
runtimeOnly 'io.micrometer:micrometer-registry-prometheus:1.11.5'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation "org.springframework.boot:spring-boot-starter-test"

View File

@ -24,7 +24,9 @@ import org.springframework.stereotype.Component;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
@ -100,6 +102,8 @@ public class ScheduledTasks {
int numFailedTasks = 0;
List<Future<Boolean>> futuresToDelete = new ArrayList<>(sizeOfFutures);
for ( int i=0; i < sizeOfFutures; ++i ) {
Future<Boolean> future = null;
try {
@ -121,10 +125,13 @@ public class ScheduledTasks {
// Only here, the "future" will be null.
} finally {
if ( future != null )
UrlsController.futuresOfBackgroundTasks.remove(future); // We do not need it anymore. This is the safest way to delete them without removing newly added futures as well.
futuresToDelete.add(future); // Do not delete them directly here, as the indexes will get messed up and we will get "IOOBE".
}
}
for ( Future<Boolean> future : futuresToDelete )
UrlsController.futuresOfBackgroundTasks.remove(future); // We do not need it anymore. This is the safest way to delete them without removing newly added futures as well.
if ( numFailedTasks > 0 )
logger.warn(numFailedTasks + " out of " + sizeOfFutures + " tasks have failed!");
else