carterkozak commented on code in PR #351:
URL: 
https://github.com/apache/httpcomponents-core/pull/351#discussion_r904113191


##########
httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/H2OnlyClientProtocolNegotiator.java:
##########
@@ -104,7 +106,8 @@ private void writeOutPreface(final IOSession session) 
throws IOException  {
         }
         if (!preface.hasRemaining()) {
             session.clearEvent(SelectionKey.OP_WRITE);
-            startProtocol(HttpVersion.HTTP_2, new 
ClientH2IOEventHandler(http2StreamHandlerFactory.create(ioSession)), null);
+            final ByteBuffer data = inBuf != null ? inBuf.data() : null;

Review Comment:
   We can avoid the unnecessary additional volatile read (I find this pattern 
helpful in general, especially when null checks are involved, though I realize 
in this case we never transition from non-null to null)
   ```suggestion
               final BufferedData inBufSnapshot = inBuf;
               final ByteBuffer data = inBufSnapshot != null ? 
inBufSnapshot.data() : null;
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to