Skip to content

Commit

Permalink
Merge pull request #3064 from GDLMadushanka/address
Browse files Browse the repository at this point in the history
Fix NPE in management API for endpoints
  • Loading branch information
GDLMadushanka authored Dec 22, 2023
2 parents 954f503 + 4e86371 commit 4910ae3
Showing 1 changed file with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,17 @@ private void handleTracing(String performedBy, JsonObject payload, MessageContex
SynapseConfiguration configuration = msgCtx.getConfiguration();
Endpoint endpoint = configuration.getEndpoint(endpointName);
if (endpoint != null) {
AspectConfiguration aspectConfiguration = ((AbstractEndpoint) endpoint).getDefinition().getAspectConfiguration();
JSONObject info = new JSONObject();
info.put(ENDPOINT_NAME, endpointName);
response = Utils.handleTracing(performedBy, Constants.AUDIT_LOG_TYPE_ENDPOINT_TRACE,
Constants.ENDPOINTS, info, aspectConfiguration, endpointName,
axisMsgCtx);
if (((AbstractEndpoint) endpoint).getDefinition() != null) {
AspectConfiguration aspectConfiguration = ((AbstractEndpoint) endpoint).getDefinition()
.getAspectConfiguration();
JSONObject info = new JSONObject();
info.put(ENDPOINT_NAME, endpointName);
response = Utils.handleTracing(performedBy, Constants.AUDIT_LOG_TYPE_ENDPOINT_TRACE,
Constants.ENDPOINTS, info, aspectConfiguration, endpointName, axisMsgCtx);
} else {
response = Utils.createJsonError("Tracing is not supported for this endpoint", axisMsgCtx,
Constants.BAD_REQUEST);
}
} else {
response = Utils.createJsonError("Specified endpoint ('" + endpointName + "') not found", axisMsgCtx,
Constants.BAD_REQUEST);
Expand Down Expand Up @@ -223,9 +228,13 @@ private JSONObject getEndpointAsJson(Endpoint endpoint) {
OMElement synapseConfiguration = EndpointSerializer.getElementFromEndpoint(endpoint);
endpointObject.put(Constants.SYNAPSE_CONFIGURATION, synapseConfiguration);
endpointObject.put(IS_ACTIVE, isEndpointActive(endpoint));
String tracingState = ((AbstractEndpoint) endpoint).getDefinition().getAspectConfiguration().isTracingEnabled() ? Constants.ENABLED : Constants.DISABLED;
endpointObject.put(TRACING, tracingState);

if (((AbstractEndpoint) endpoint).getDefinition() != null) {
String tracingState = ((AbstractEndpoint) endpoint).getDefinition().getAspectConfiguration()
.isTracingEnabled() ? Constants.ENABLED : Constants.DISABLED;
endpointObject.put(TRACING, tracingState);
} else {
endpointObject.put(TRACING, Constants.DISABLED);
}
return endpointObject;
}

Expand Down

0 comments on commit 4910ae3

Please sign in to comment.