@@ -410,27 +410,22 @@ static final class KeyAwareClientCallListener<ResponseT>
410410
411411 @ Override
412412 public void onMessage (ResponseT message ) {
413+ ByteString transactionId = null ;
413414 if (message instanceof PartialResultSet ) {
414415 PartialResultSet response = (PartialResultSet ) message ;
415416 if (response .hasCacheUpdate () && call .channelFinder != null ) {
416417 call .channelFinder .update (response .getCacheUpdate ());
417418 }
418- ByteString transactionId = transactionIdFromMetadata (response );
419- if (transactionId != null ) {
420- call .maybeRecordAffinity (transactionId );
421- }
419+ transactionId = transactionIdFromMetadata (response );
422420 } else if (message instanceof ResultSet ) {
423421 ResultSet response = (ResultSet ) message ;
424- ByteString transactionId = transactionIdFromMetadata (response );
425- if (transactionId != null ) {
426- call .maybeRecordAffinity (transactionId );
427- }
422+ transactionId = transactionIdFromMetadata (response );
428423 } else if (message instanceof Transaction ) {
429424 Transaction response = (Transaction ) message ;
430- ByteString transactionId = transactionIdFromTransaction (response );
431- if ( transactionId != null ) {
432- call . maybeRecordAffinity (transactionId );
433- }
425+ transactionId = transactionIdFromTransaction (response );
426+ }
427+ if (transactionId != null ) {
428+ call . maybeRecordAffinity ( transactionId );
434429 }
435430 super .onMessage (message );
436431 }
0 commit comments