Source:
<code>public void handle(HeartbeatResponse heartbeatResponse, RequestFuture<Void> future) { sensors.heartbeatSensor.record(response.requestLatencyMs()); Errors error = heartbeatResponse.error(); if (error == Errors.NONE) { log.debug("Received successful Heartbeat response"); future.complete(null); } else if (error == Errors.COORDINATOR_NOT_AVAILABLE || error == Errors.NOT_COORDINATOR) { log.info("Attempt to heartbeat failed since coordinator is either not started or not valid", coordinator()); markCoordinatorUnknown(); future.raise(error); } else if (error == Errors.REBALANCE_IN_PROGRESS) { log.info("Attempt to heartbeat failed since group is rebalancing"); requestRejoin(); future.raise(error); } else if (error == Errors.ILLEGAL_GENERATION || error == Errors.UNKNOWN_MEMBER_ID || <START> error == Errors.FENCED_INSTANCE_ID) { <END> if (generationUnchanged()) { log.info("Attempt to heartbeat failed with generation and group instance id due to {}, resetting generation", sentGeneration, rebalanceConfig.groupInstanceId, error.message()); resetGenerationOnResponseError(ApiKeys.HEARTBEAT, error); future.raise(error); } else { log.info("Attempt to heartbeat failed with stale generation and group instance id due to {}, ignoring the error", sentGeneration, rebalanceConfig.groupInstanceId, error.message()); future.complete(null); } } else if (error == Errors.GROUP_AUTHORIZATION_FAILED) { future.raise(GroupAuthorizationException.forGroupId(rebalanceConfig.groupId)); } else { future.raise(new KafkaException("Unexpected error in heartbeat response: " + error.message())); } }</code><technical_language>If consumer legitimately fenced, is safe rejoin group resetting member id? lead a ping-pong scenario</technical_language>

Target:
public void handle(HeartbeatResponse heartbeatResponse, RequestFuture<Void> future) { sensors.heartbeatSensor.record(response.requestLatencyMs()); Errors error = heartbeatResponse.error(); if (error == Errors.NONE) { log.debug("Received successful Heartbeat response"); future.complete(null); } else if (error == Errors.COORDINATOR_NOT_AVAILABLE || error == Errors.NOT_COORDINATOR) { log.info("Attempt to heartbeat failed since coordinator is either not started or not valid", coordinator()); markCoordinatorUnknown(); future.raise(error); } else if (error == Errors.REBALANCE_IN_PROGRESS) { log.info("Attempt to heartbeat failed since group is rebalancing"); requestRejoin(); future.raise(error); } else if (error == Errors.ILLEGAL_GENERATION || error == Errors.UNKNOWN_MEMBER_ID || error == Errors.FENCED_INSTANCE_ID) { if (generationUnchanged()) { log.info("Attempt to heartbeat with and group instance id failed due to {}, resetting generation", sentGeneration, rebalanceConfig.groupInstanceId, error); resetGenerationOnResponseError(ApiKeys.HEARTBEAT, error); future.raise(error); } else { log.info("Attempt to heartbeat with stale and group instance id failed due to {}, ignoring the error", sentGeneration, rebalanceConfig.groupInstanceId, error); future.complete(null); } } else if (error == Errors.GROUP_AUTHORIZATION_FAILED) { future.raise(GroupAuthorizationException.forGroupId(rebalanceConfig.groupId)); } else { future.raise(new KafkaException("Unexpected error in heartbeat response: " + error.message())); } }