Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip the agent jar while generating the report #222

Merged
merged 1 commit into from
Jun 10, 2024
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
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);
}
}