This is an automated email from the ASF dual-hosted git repository.

preetham02 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit a1a2bc2393ff1cef1c783701e7382078e1cc64bb
Author: Michael Blow <michael.b...@couchbase.com>
AuthorDate: Mon Jul 7 00:27:36 2025 -0400

    [NO ISSUE][HYR][HTTP] Fix omitted access log on some netty responses
    
    The CLFLogger had assumptions that if a DefaultFullHttpResponse was
    not received, it would receive one or more DefaultHttpContent
    instances followed by a LastHttpContent. In reality, Netty is free to
    return a DefaultHttpContent that also implements LastHttpContent,
    which causes the CLF log entry to never be emitted.
    
    Ext-ref: MB-67407
    Change-Id: I8aa6c6e8e61eb63a83dd259afbe30b08969128eb
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20027
    Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
    Tested-by: Michael Blow <mb...@apache.org>
    Reviewed-by: Michael Blow <mb...@apache.org>
---
 .../main/java/org/apache/hyracks/http/server/CLFLogger.java | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git 
a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/CLFLogger.java
 
b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/CLFLogger.java
index a24ed9575b..6476ab9e3d 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/CLFLogger.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/CLFLogger.java
@@ -34,10 +34,8 @@ import io.netty.channel.socket.nio.NioSocketChannel;
 import io.netty.handler.codec.http.DefaultFullHttpResponse;
 import io.netty.handler.codec.http.DefaultHttpContent;
 import io.netty.handler.codec.http.DefaultHttpResponse;
-import io.netty.handler.codec.http.HttpContent;
 import io.netty.handler.codec.http.HttpHeaderNames;
 import io.netty.handler.codec.http.HttpRequest;
-import io.netty.handler.codec.http.HttpResponse;
 import io.netty.handler.codec.http.LastHttpContent;
 
 //Based in part on LoggingHandler from Netty
@@ -99,18 +97,15 @@ public class CLFLogger extends ChannelDuplexHandler {
 
     @Override
     public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise 
promise) {
-        if (msg instanceof DefaultHttpResponse) {
-            HttpResponse resp = (DefaultHttpResponse) msg;
+        if (msg instanceof DefaultHttpResponse resp) {
             statusCode = resp.status().code();
             if (msg instanceof DefaultFullHttpResponse) {
-                lastChunk = true;
                 respSize = 
resp.headers().getInt(HttpHeaderNames.CONTENT_LENGTH, 0);
             }
-        } else if (msg instanceof DefaultHttpContent) {
-            HttpContent content = (DefaultHttpContent) msg;
-
+        } else if (msg instanceof DefaultHttpContent content) {
             respSize += content.content().readableBytes();
-        } else if (msg instanceof LastHttpContent) {
+        }
+        if (msg instanceof LastHttpContent) {
             lastChunk = true;
         }
 

Reply via email to