From 3563fd6e2a0a87d827c77c0e2a9eadedc4c6fb14 Mon Sep 17 00:00:00 2001 From: LSmyrnaios Date: Wed, 7 Feb 2024 18:34:28 +0200 Subject: [PATCH] - Try to get the cause of the exception of the callable-tasks which handle parquet-files. - Update License. - Update dependencies. --- LICENSE | 2 +- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- installAndRun.sh | 2 +- .../urls_controller/components/ScheduledTasks.java | 4 ++-- .../urls_controller/util/ParquetFileUtils.java | 12 +++++++++++- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/LICENSE b/LICENSE index 3ddb6ba..c90d3b3 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2021-2023 Athena Research and Innovation Center (ARC) + Copyright 2021-2024 OpenAIRE AMKE Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/build.gradle b/build.gradle index 9680442..4a1ca43 100644 --- a/build.gradle +++ b/build.gradle @@ -110,7 +110,7 @@ dependencies { // Add back some updated version of the needed dependencies. implementation 'org.apache.thrift:libthrift:0.17.0' // Newer versions (>=0.18.X) are not compatible with JAVA 8. - implementation 'com.fasterxml.woodstox:woodstox-core:6.5.1' + implementation 'com.fasterxml.woodstox:woodstox-core:6.6.0' // https://mvnrepository.com/artifact/org.json/json implementation 'org.json:json:20231013' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e09..a80b22c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/installAndRun.sh b/installAndRun.sh index 431e833..12536db 100755 --- a/installAndRun.sh +++ b/installAndRun.sh @@ -26,7 +26,7 @@ if [[ justRun -eq 1 && shouldRunInDocker -eq 1 ]]; then justRun=0 fi -gradleVersion="8.5" +gradleVersion="8.6" if [[ justRun -eq 0 ]]; then diff --git a/src/main/java/eu/openaire/urls_controller/components/ScheduledTasks.java b/src/main/java/eu/openaire/urls_controller/components/ScheduledTasks.java index d959be7..b71d9c9 100644 --- a/src/main/java/eu/openaire/urls_controller/components/ScheduledTasks.java +++ b/src/main/java/eu/openaire/urls_controller/components/ScheduledTasks.java @@ -112,7 +112,7 @@ public class ScheduledTasks { if ( ! future.get() ) // Get and see if an exception is thrown. This blocks the current thread, until the task of the future has finished. numFailedTasks ++; } catch (ExecutionException ee) { // These can be serious errors like an "out of memory exception" (Java HEAP). - // The stacktrace of the "ExecutionException" is the one of thi code and not the code which ran inside the background-task. Try to get the cause. + // The stacktrace of the "ExecutionException" is the one of the current code and not the code which ran inside the background-task. Try to get the cause. Throwable throwable = ee.getCause(); if ( throwable == null ) { logger.warn("No cause was retrieved for the \"ExecutionException\"!"); @@ -308,7 +308,7 @@ public class ScheduledTasks { } // Any error is already logged. - // TODO - Export more complex data; , , + // TODO - Export more complex data; , , // , ..., , ... } diff --git a/src/main/java/eu/openaire/urls_controller/util/ParquetFileUtils.java b/src/main/java/eu/openaire/urls_controller/util/ParquetFileUtils.java index fccfc62..9fef898 100644 --- a/src/main/java/eu/openaire/urls_controller/util/ParquetFileUtils.java +++ b/src/main/java/eu/openaire/urls_controller/util/ParquetFileUtils.java @@ -43,6 +43,7 @@ import java.util.ArrayList; import java.util.Base64; import java.util.List; import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.stream.Collectors; @@ -700,7 +701,16 @@ public class ParquetFileUtils { return new SumParquetSuccess(false, false, ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errMsg)); } } catch (Exception e) { - logger.error("", e); + Throwable throwable = e; + if ( e instanceof ExecutionException ) { + // The stacktrace of the "ExecutionException" is the one of the current code and not the code which ran inside the background-task. Try to get the cause. + throwable = e.getCause(); + if ( throwable == null ) { + logger.warn("No cause was retrieved for the \"ExecutionException\"!"); + throwable = e; + } + } + logger.error("", throwable); // We do not know if the failed "future" refers to a "payload" or to a "attempt". // So we cannot increase a specific counter. That's ok, the only drawback if that we may try to "load" the non-existent data and get an exception. }