Skip to content

Commit

Permalink
fix: skip the agent jar while generating the report
Browse files Browse the repository at this point in the history
In certain circumstances (eg when running using mvn spring-boot:run)
analyzing the agent jar would cause LinkageError. We now skip the agent
jar to avoid causing this problem.

Fixes MWTELE-232
  • Loading branch information
quintesse committed May 20, 2024
1 parent 4711027 commit 10a889d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions api/src/main/java/com/redhat/insights/jars/JarAnalyzer.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/* Copyright (C) Red Hat 2023 */
/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.jars;

import com.redhat.insights.logging.InsightsLogger;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Paths;
import java.util.*;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
Expand Down Expand Up @@ -253,6 +254,11 @@ private boolean isModularJdkJar(URL url) {
* @return True if the jar file should be added, else false.
*/
private boolean shouldAttemptAdd(final String jarFile) {
return !ignoreJars.contains(jarFile);
String agentJarFile =
Paths.get(JarAnalyzer.class.getProtectionDomain().getCodeSource().getLocation().getFile())
.getFileName()
.toString();

return !ignoreJars.contains(jarFile) && !jarFile.equals(agentJarFile);
}
}

0 comments on commit 10a889d

Please sign in to comment.