aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main/java
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2024-05-07 14:39:01 +0200
committersonartech <sonartech@sonarsource.com>2024-05-13 20:02:41 +0000
commitff63883b5b6b1fc03f7395173ed45706df2b9d41 (patch)
tree8ec5c3747d57245cc1298e10d085af990429d2ef /sonar-scanner-engine/src/main/java
parente3c71f1d9ee688f5cab44a6e86b2928cb4fca3ab (diff)
downloadsonarqube-ff63883b5b6b1fc03f7395173ed45706df2b9d41.tar.gz
sonarqube-ff63883b5b6b1fc03f7395173ed45706df2b9d41.zip
SONAR-22152 Silent NoClassDefFoundError: ThrowableProxy from JGit
Diffstat (limited to 'sonar-scanner-engine/src/main/java')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java
index 19b90c180fa..2a105bc466a 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java
@@ -25,6 +25,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
+import org.eclipse.jgit.internal.util.ShutdownHook;
+import org.slf4j.LoggerFactory;
import org.sonar.api.utils.MessageException;
import org.sonar.scanner.bootstrap.EnvironmentConfig;
import org.sonar.scanner.bootstrap.SpringGlobalContainer;
@@ -73,6 +75,16 @@ public final class Batch {
SpringGlobalContainer.create(scannerProperties, components).execute();
} catch (RuntimeException e) {
throw handleException(e);
+ } finally {
+ // Workaround for SONAR-22152
+ // Call the cleanup method ourselves to avoid ClassNotFound errors when the Shutdown hook is called after the classloader is closed
+ try {
+ var cleanupMethod = ShutdownHook.class.getDeclaredMethod("cleanup");
+ cleanupMethod.setAccessible(true);
+ cleanupMethod.invoke(ShutdownHook.INSTANCE);
+ } catch (Exception e) {
+ LoggerFactory.getLogger(Batch.class).debug("Failed to call JGit cleanup method", e);
+ }
}
return this;
}