Skip to content

Commit

Permalink
Fix MWTELE 127 130 131 (#20)
Browse files Browse the repository at this point in the history
* Fix MWTELE-130

* Fix MWTELE-131

* Temporary fix for MWTELE-127
  • Loading branch information
kittylyst authored Dec 6, 2023
1 parent 78f5d2f commit dff25aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
17 changes: 11 additions & 6 deletions src/main/java/com/redhat/insights/agent/AgentMain.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Copyright (C) Red Hat 2023 */
package com.redhat.insights.agent;

import com.redhat.insights.InsightsException;
import com.redhat.insights.InsightsReportController;
import com.redhat.insights.http.InsightsFileWritingClient;
import com.redhat.insights.http.InsightsHttpClient;
Expand Down Expand Up @@ -70,7 +71,7 @@ public static void startAgent(String agentArgs, Instrumentation instrumentation)
return;
}

BlockingQueue<JarInfo> jarsToSend = new LinkedBlockingQueue<>();
final BlockingQueue<JarInfo> jarsToSend = new LinkedBlockingQueue<>();
try {
logger.info("Starting Red Hat Insights client");
new AgentMain(config, jarsToSend).start();
Expand Down Expand Up @@ -118,7 +119,6 @@ static boolean shouldContinue(AgentConfiguration config) {
/**
* Parse the agent arguments from the form "key1=value1;key2=value2;..."
*
* @param logger
* @param agentArgs
* @return
*/
Expand Down Expand Up @@ -162,17 +162,22 @@ private static boolean shouldLookForCerts(AgentConfiguration config) {

private void start() {
final InsightsReport report = AgentBasicReport.of(configuration);
final PEMSupport pem = new PEMSupport(logger, configuration);

Supplier<InsightsHttpClient> httpClientSupplier;
if (configuration.isDebug() || configuration.isFileOnly()) {
httpClientSupplier = () -> new InsightsFileWritingClient(logger, configuration);
} else {
final PEMSupport pem = new PEMSupport(logger, configuration);
httpClientSupplier =
() -> new InsightsAgentHttpClient(configuration, () -> pem.createTLSContext());
}
final InsightsReportController controller =
InsightsReportController.of(logger, configuration, report, httpClientSupplier, waitingJars);
controller.generate();
try {
final InsightsReportController controller =
InsightsReportController.of(
logger, configuration, report, httpClientSupplier, waitingJars);
controller.generate();
} catch (InsightsException e) {
logger.info("Unable to start Red Hat Insights client: " + e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class AgentSubreport implements InsightsSubreport {

static {
activeGuesses.put("org.springframework.boot.SpringApplication", __ -> "Spring Boot");
activeGuesses.put("org.springframework.boot.loader.Launcher", __ -> "Spring Boot");
activeGuesses.put("org.jboss.modules.Module", AgentSubreport::fingerprintJBoss);
activeGuesses.put(
"io.quarkus.bootstrap.runner.QuarkusEntryPoint", AgentSubreport::fingerprintQuarkus);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/redhat/insights/agent/Attach.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void main(String[] args) {
System.exit(1);
}
URL jarUrl = AgentMain.class.getProtectionDomain().getCodeSource().getLocation();
System.out.println("Trying to attach: " + jarUrl);
// System.out.println("Trying to attach: " + jarUrl);
String agentJar = jarUrl.toExternalForm().replaceFirst("^file:", "");

String pid = args[0];
Expand All @@ -26,9 +26,9 @@ public static void main(String[] args) {
VirtualMachine vm = VirtualMachine.attach(pid);
vm.loadAgent(agentJar, options);
vm.detach();
} catch (IOException e) {
} catch (AgentLoadException | IOException e) {
// Probable Java version mismatch, ignore
} catch (AgentLoadException | AttachNotSupportedException | AgentInitializationException e) {
} catch (AttachNotSupportedException | AgentInitializationException e) {
throw new RuntimeException(e);
}
}
Expand Down

0 comments on commit dff25aa

Please sign in to comment.