kirktrue commented on code in PR #17731: URL: https://github.com/apache/kafka/pull/17731#discussion_r2196247913
########## core/src/main/scala/kafka/network/SocketServer.scala: ########## @@ -1133,23 +1133,27 @@ private[kafka] class Processor( expiredConnectionsKilledCount.record(null, 1, 0) } else { val connectionId = receive.source - val context = new RequestContext(header, connectionId, channel.socketAddress, Optional.of(channel.socketPort()), - channel.principal, listenerName, securityProtocol, channel.channelMetadataRegistry.clientInformation, - isPrivilegedListener, channel.principalSerde) - - val req = new RequestChannel.Request(processor = id, context = context, - startTimeNanos = nowNanos, memoryPool, receive.payload, requestChannel.metrics, None) - + var requestAndSize: Option[RequestAndSize] = None // KIP-511: ApiVersionsRequest is intercepted here to catch the client software name // and version. It is done here to avoid wiring things up to the api layer. if (header.apiKey == ApiKeys.API_VERSIONS) { - val apiVersionsRequest = req.body[ApiVersionsRequest] + val result = RequestContext.staticParseRequest(header, receive.payload, connectionId, listenerName, channel.principal) + val apiVersionsRequest = result.request.asInstanceOf[ApiVersionsRequest] if (apiVersionsRequest.isValid) { channel.channelMetadataRegistry.registerClientInformation(new ClientInformation( apiVersionsRequest.data.clientSoftwareName, apiVersionsRequest.data.clientSoftwareVersion)) Review Comment: Is it possible to move the chunk of code that checks for `API_VERSIONS` from after `req` is create to before `context` is created? Then the `RequestContext` can use the `ClientInformation` that was just registered in the channel metadata registry a few lines above. Thus not having to change `RequestContext` to make it mutable. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org