ijokarumawak commented on a change in pull request #3647: NIFI-6530 - HTTP
SiteToSite server returns 201 in case no data is ava…
URL: https://github.com/apache/nifi/pull/3647#discussion_r321076934
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/DataTransferResource.java
##########
@@ -205,9 +208,20 @@ public Response createPortTransaction(
final int transportProtocolVersion =
validationResult.transportProtocolVersion;
try {
- // Execute handshake.
- initiateServerProtocol(req, peer, transportProtocolVersion);
+ HttpFlowFileServerProtocol serverProtocol =
initiateServerProtocol(req, peer, transportProtocolVersion);
+
+ int protocolVersion =
Integer.parseUnsignedInt(req.getHeader(PROTOCOL_VERSION));
+ if ((protocolVersion >= 2) && PORT_TYPE_OUTPUT.equals(portType)) {
+ List<Connection> connectionList =
serverProtocol.getPort().getIncomingConnections();
+ if (connectionList.stream().allMatch(c ->
c.getFlowFileQueue().isEmpty())) {
+ // Transaction could be created, but there is nothing to
transfer. Just return 200.
+ logger.debug("Output port has no flowfiles to transfer,
returning 200");
+ return
noCache(Response.status(Response.Status.NO_CONTENT)).type(MediaType.TEXT_PLAIN).entity("No
flowfiles available").build();
Review comment:
A transaction is already created at this point, by the preceding following
line:
```
final String transactionId = transactionManager.createTransaction();
```
The created transaction will be removed by the back-ground maintenance
thread, but we should remove it from here immediately by calling
`transactionManager.cancelTransaction(transactionId)`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services