Skip to content

Commit

Permalink
Use Log4j ParameterizedMessage for string substitutions
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Oct 7, 2024
1 parent bc9961e commit 86ac8ea
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessageFactory;
import org.opensearch.ExceptionsHelper;
import org.opensearch.action.DocWriteRequest.OpType;
import org.opensearch.action.admin.indices.create.CreateIndexRequest;
Expand Down Expand Up @@ -804,11 +805,14 @@ private void handleStateUpdateException(
getAndUpdateResourceInStateDocumentWithRetries(workflowId, newResource, operation, retries - 1, listener);
return;
}
StringBuilder sb = new StringBuilder("Failed to update workflow state for ");
sb.append(workflowId).append(" on step ").append(newResource.workflowStepId());
sb.append(" to ").append(operation.equals(OpType.DELETE) ? "delete" : "add");
sb.append(" resource ").append(newResource.resourceType()).append(" ").append(newResource.resourceId());
String errorMessage = sb.toString();
String errorMessage = ParameterizedMessageFactory.INSTANCE.newMessage(
"Failed to update workflow state for {} on step {} to {} resource {} {}",
workflowId,
newResource.workflowStepId(),
operation.equals(OpType.DELETE) ? "delete" : "add",
newResource.resourceType(),
newResource.resourceId()
).getFormattedMessage();
logger.error(errorMessage, e);
listener.onFailure(new FlowFrameworkException(errorMessage, ExceptionsHelper.status(e)));
}
Expand Down

0 comments on commit 86ac8ea

Please sign in to comment.