Skip to content

Commit

Permalink
MINOR: Tiny optimization to avoid mapping twice on the results.
Browse files Browse the repository at this point in the history
As pointed out by granthenke in apache#196, error can be wrapped in JShort directly to avoid second map.

Author: David Jacot <[email protected]>

Reviewers: Grant Henke, Gwen Shapira

Closes apache#714 from dajac/wrap-jshort
  • Loading branch information
dajac authored and gwenshap committed Dec 23, 2015
1 parent bde49e3 commit ba6f141
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/scala/kafka/server/KafkaApis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class KafkaApis(val requestChannel: RequestChannel,
val result = replicaManager.becomeLeaderOrFollower(correlationId, leaderAndIsrRequest, metadataCache, onLeadershipChange)
new LeaderAndIsrResponse(result.errorCode, result.responseMap.mapValues(new JShort(_)).asJava)
} else {
val result = leaderAndIsrRequest.partitionStates.asScala.keys.map((_, Errors.CLUSTER_AUTHORIZATION_FAILED.code)).toMap
new LeaderAndIsrResponse(Errors.CLUSTER_AUTHORIZATION_FAILED.code, result.mapValues(new JShort(_)).asJava)
val result = leaderAndIsrRequest.partitionStates.asScala.keys.map((_, new JShort(Errors.CLUSTER_AUTHORIZATION_FAILED.code))).toMap
new LeaderAndIsrResponse(Errors.CLUSTER_AUTHORIZATION_FAILED.code, result.asJava)
}

requestChannel.sendResponse(new Response(request, new ResponseSend(request.connectionId, responseHeader, leaderAndIsrResponse)))
Expand Down

0 comments on commit ba6f141

Please sign in to comment.