Source:
<code>protected synchronized void handleEvent(CoordinatorEvent event) { _log.info("START: Handle event " + event.getType() + ", Instance: " + _adapter.getInstanceName()); <START> boolean isLeader = _adapter.isLeader(); if (skipLeaderEvent(event.getType(), isLeader)) { <END> _log.info("Skipping event isLeader {}", event.getType(), isLeader); return; } try { switch (event.getType()) { case LEADER_DO_ASSIGNMENT: handleLeaderDoAssignment((Boolean) event.getEventMetadata()); break; case HANDLE_ASSIGNMENT_CHANGE: synchronized (_assignedDatastreamTasks) { handleAssignmentChange(false); } break; case HANDLE_DATASTREAM_CHANGE_WITH_UPDATE: synchronized (_assignedDatastreamTasks) { handleAssignmentChange(true); } break; case HANDLE_ADD_OR_DELETE_DATASTREAM: handleDatastreamAddOrDelete(); break; case HANDLE_INSTANCE_ERROR: handleInstanceError((CoordinatorEvent.HandleInstanceError) event); break; case HEARTBEAT: handleHeartbeat(); break; case LEADER_PARTITION_ASSIGNMENT: if (event.getEventMetadata() == null) { _log.error("Datastream group is not found when performing partition assignment, ignore the assignment"); } else { performPartitionAssignment((String) event.getEventMetadata()); } break; case LEADER_PARTITION_MOVEMENT: performPartitionMovement((Long) event.getEventMetadata()); break; default: String errorMessage = String.format("Unknown event type %s.", event.getType()); ErrorLogger.logAndThrowDatastreamRuntimeException(_log, errorMessage, null); break; } } catch (Exception e) { _metrics.updateKeyedMeter(CoordinatorMetrics.getKeyedMeter(event.getType()), 1); _log.error("ERROR: event + " + event + " failed.", e); } _log.info("END: Handle event " + event); }</code><technical_language>nit: I this'd more intuitive/straightforward if expressed as: java if (isLeaderEvent(event) && !isLeader) { _log.info(...); return; }</technical_language>

Target:
protected synchronized void handleEvent(CoordinatorEvent event) { _log.info("START: Handle event " + event.getType() + ", Instance: " + _adapter.getInstanceName()); boolean isLeader = _adapter.isLeader(); if (!isLeader && isLeaderEvent(event.getType())) { _log.info("Skipping event isLeader {}", event.getType(), isLeader); return; } try { switch (event.getType()) { case LEADER_DO_ASSIGNMENT: handleLeaderDoAssignment((Boolean) event.getEventMetadata()); break; case HANDLE_ASSIGNMENT_CHANGE: synchronized (_assignedDatastreamTasks) { handleAssignmentChange(false); } break; case HANDLE_DATASTREAM_CHANGE_WITH_UPDATE: synchronized (_assignedDatastreamTasks) { handleAssignmentChange(true); } break; case HANDLE_ADD_OR_DELETE_DATASTREAM: handleDatastreamAddOrDelete(); break; case HANDLE_INSTANCE_ERROR: handleInstanceError((CoordinatorEvent.HandleInstanceError) event); break; case HEARTBEAT: handleHeartbeat(); break; case LEADER_PARTITION_ASSIGNMENT: if (event.getEventMetadata() == null) { _log.error("Datastream group is not found when performing partition assignment, ignore the assignment"); } else { performPartitionAssignment((String) event.getEventMetadata()); } break; case LEADER_PARTITION_MOVEMENT: performPartitionMovement((Long) event.getEventMetadata()); break; default: String errorMessage = String.format("Unknown event type %s.", event.getType()); ErrorLogger.logAndThrowDatastreamRuntimeException(_log, errorMessage, null); break; } } catch (Exception e) { _metrics.updateKeyedMeter(CoordinatorMetrics.getKeyedMeter(event.getType()), 1); _log.error("ERROR: event + " + event + " failed.", e); } _log.info("END: Handle event " + event); }