Skip to content

Commit

Permalink
Log destination ATS Agent address on ConnectTimeoutException or simil…
Browse files Browse the repository at this point in the history
…ar SocketException
  • Loading branch information
svilen-d committed Jul 19, 2024
1 parent eeee156 commit 8be3516
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -116,6 +118,7 @@ public Object executeAction( ActionRequest actionRequest ) throws AgentException
//get the client
AgentService agentServicePort = AgentServicePool.getInstance().getClient(atsAgent);

final String COMM_ERROR = "Error connecting or communicating with agent at ";
try {
//FIXME: swap with ActionWrapper
byte[] resultAsBytes = agentServicePort.executeAction(componentName, actionName,
Expand All @@ -128,6 +131,8 @@ public Object executeAction( ActionRequest actionRequest ) throws AgentException

result = objectInStream.readObject();

} catch (SocketException e) { // includes ConnectException
throw new AgentException(COMM_ERROR + atsAgent, e);
} catch (IOException ioe) {
throw new AgentException("Could not deserialize returned result from agent at " + atsAgent,
ioe);
Expand All @@ -149,7 +154,13 @@ public Object executeAction( ActionRequest actionRequest ) throws AgentException
atsAgent);

} catch (Exception e) {
throw new AgentException(e.getMessage(), e);
String msg;
if (e.getCause() != null && e.getCause() instanceof SocketTimeoutException) {
msg = COMM_ERROR + atsAgent;
} else {
msg = e.getMessage();
}
throw new AgentException(msg, e);
}

return result;
Expand Down

0 comments on commit 8be3516

Please sign in to comment.