Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFCORE-1149] Ensure open input streams are closed after the operatio… #1262

Merged
merged 1 commit into from
Nov 25, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@
import io.undertow.util.Headers;
import org.jboss.as.controller.ModelController;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.client.Operation;
import org.jboss.as.controller.client.OperationBuilder;
import org.jboss.as.controller.client.OperationMessageHandler;
import org.jboss.as.core.security.AccessMechanism;
import org.jboss.dmr.ModelNode;
import org.xnio.IoUtils;

/**
* Generic http POST handler accepting a single operation and multiple input streams passed as part of
Expand Down Expand Up @@ -171,13 +173,21 @@ public void operationPrepared(final ModelController.OperationTransaction transac
} : ModelController.OperationTransactionControl.COMMIT;

ModelNode response;
final Operation builtOp = builder.build();
try {
operation.get(OPERATION_HEADERS, ACCESS_MECHANISM).set(AccessMechanism.HTTP.toString());
response = modelController.execute(operation, OperationMessageHandler.DISCARD, control, builder.build());
response = modelController.execute(operation, OperationMessageHandler.DISCARD, control, builtOp);
} catch (Throwable t) {
ROOT_LOGGER.modelRequestError(t);
Common.sendError(exchange, opParam.isEncode(), t.getLocalizedMessage());
return;
} finally {
// Close any input streams that were open
if (builtOp.isAutoCloseStreams()) {
for (InputStream in : builtOp.getInputStreams()) {
IoUtils.safeClose(in);
}
}
}

callback.sendResponse(response);
Expand Down