NIFI-13568 MiNiFi Fix concurrent SAXParser issue in manifest parsing

Signed-off-by: Ferenc Erdei <erdei.ferenc90@gmail.com>
This closes #9098.
This commit is contained in:
Ferenc Kis 2024-07-11 16:29:20 +02:00 committed by Ferenc Erdei
parent b0f419be2c
commit c31fb9d373
No known key found for this signature in database
GPG Key ID: 023D856C60E92F96
2 changed files with 17 additions and 7 deletions

View File

@ -74,7 +74,10 @@ public class C2OperationManager implements Runnable {
@Override @Override
public void run() { public void run() {
processRestartState(); processRestartState();
processOperationsInLoop();
}
private void processOperationsInLoop() {
while (true) { while (true) {
C2Operation operation; C2Operation operation;
try { try {
@ -91,10 +94,17 @@ public class C2OperationManager implements Runnable {
continue; continue;
} }
C2OperationAck c2OperationAck = operationHandler.handle(operation); C2OperationAck operationAck;
if (!requiresRestart(operationHandler, c2OperationAck)) { try {
LOGGER.debug("No restart is required. Sending ACK to C2 server {}", c2OperationAck); operationAck = operationHandler.handle(operation);
sendAcknowledge(c2OperationAck); } catch (Exception e) {
LOGGER.error("Failed to process operation " + operation, e);
continue;
}
if (!requiresRestart(operationHandler, operationAck)) {
LOGGER.debug("No restart is required. Sending ACK to C2 server {}", operationAck);
sendAcknowledge(operationAck);
continue; continue;
} }
@ -109,8 +119,8 @@ public class C2OperationManager implements Runnable {
try { try {
C2OperationState failedState = restartState.get(); C2OperationState failedState = restartState.get();
LOGGER.debug("Restart handler returned with a failed state {}", failedState); LOGGER.debug("Restart handler returned with a failed state {}", failedState);
c2OperationAck.setOperationState(failedState); operationAck.setOperationState(failedState);
sendAcknowledge(c2OperationAck); sendAcknowledge(operationAck);
} finally { } finally {
operationQueueDAO.cleanup(); operationQueueDAO.cleanup();
LOGGER.debug("Heartbeats are enabled again"); LOGGER.debug("Heartbeats are enabled again");

View File

@ -271,7 +271,7 @@ public class C2NifiClientService {
} }
} }
private RuntimeInfoWrapper generateRuntimeInfo() { private synchronized RuntimeInfoWrapper generateRuntimeInfo() {
AgentManifest agentManifest = new AgentManifest(runtimeManifestService.getManifest()); AgentManifest agentManifest = new AgentManifest(runtimeManifestService.getManifest());
agentManifest.setSupportedOperations(supportedOperationsProvider.getSupportedOperations()); agentManifest.setSupportedOperations(supportedOperationsProvider.getSupportedOperations());
return new RuntimeInfoWrapper(getAgentRepositories(), agentManifest, getQueueStatus()); return new RuntimeInfoWrapper(getAgentRepositories(), agentManifest, getQueueStatus());