From bc73b3b0bfc7b9a095fca0016823f438c4719775 Mon Sep 17 00:00:00 2001 From: Col-E Date: Mon, 25 Sep 2023 07:35:59 -0400 Subject: [PATCH] Update VM properties map after loading the agent server so that reconnecting on the desired port works Without updating the properties map, our side doesn't know the server is running and tries to kick off a new one on a new port, which fails since the server is actually already running. --- .../coley/recaf/services/attach/BasicAttachManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/recaf-core/src/main/java/software/coley/recaf/services/attach/BasicAttachManager.java b/recaf-core/src/main/java/software/coley/recaf/services/attach/BasicAttachManager.java index 0bf353161..f098ceec2 100644 --- a/recaf-core/src/main/java/software/coley/recaf/services/attach/BasicAttachManager.java +++ b/recaf-core/src/main/java/software/coley/recaf/services/attach/BasicAttachManager.java @@ -335,6 +335,12 @@ public WorkspaceRemoteVmResource createRemoteResource(VirtualMachineDescriptor i else agentArgs += ",namelessThreads"; virtualMachine.loadAgent(agentAbsolutePath, agentArgs); + + // The agent server will update some properties to indicate its active. + // We need to update our map so that we can see this indicator so that we can extract + // the port that the server is running on if we want to reconnect. + Properties systemProperties = virtualMachine.getSystemProperties(); + virtualMachinePropertiesMap.put(item, systemProperties); } catch (AgentLoadException ex) { // The agent jar file is written in Java 8. But Recaf uses Java 11+. // This is a problem on OUR side because Java 11+ handles agent interactions differently.