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_r313302446

 File path: 
 @@ -205,9 +207,17 @@ public Response createPortTransaction(
         final int transportProtocolVersion = 
         try {
-            // Execute handshake.
-            initiateServerProtocol(req, peer, transportProtocolVersion);
+            HttpFlowFileServerProtocol serverProtocol = 
initiateServerProtocol(req, peer, transportProtocolVersion);
+            if (PORT_TYPE_OUTPUT.equals(portType)) {
+                List<Connection> connectionList = 
+                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");
 Review comment:
   I agree with the idea of using 204 in this case. Regardless of using 200 or 
204, current Java HTTP S2S client will treat such response codes as unexpected 
and throws an exception. Then users will see following warning message in 
   2019-08-13 18:37:39,475 WARN [Timer-Driven Process Thread-9] 
o.a.nifi.remote.client.http.HttpClient Penalizing a peer 
Peer[url=http://HW13076.local:8080/nifi-api] due to java.io.IOException: 
Unexpected response code: 200 errCode:Abort errMessage:No flowfiles available
   2019-08-13 18:37:45,593 INFO [Timer-Driven Process Thread-9] 
o.a.nifi.remote.client.http.HttpClient Couldn't find a valid peer to 
communicate with.
   In order to make this improvement happen while supporting old S2S clients, I 
think we need to:
   - Increase HTTP S2S protocol version from 1 to 2. Let's use 204 if we 
increase protocol version. Please refer:
       - 'Protocol version management' at this [wiki 
       - You can find related code by searching usage of [this 
   - Return 204 only for clients using protocol version 2 or higher. Keep 
acting the same for older clients.
   - Update Java HTTP S2S client, too, to properly handle 204. 
   This requires more changes than I thought, but will provide ideal response 
code (204) and backward compatibility. How do you think?

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:

With regards,
Apache Git Services

Reply via email to