Buggy code:
public class EventTapWriter implements EventWriter { @ VisibleForTesting static final String FLOW_ID_PROPERTY_NAME = "flowId" ; @ VisibleForTesting static final String HTTP_PROPERTY_NAME = "http" ; @ VisibleForTesting static final String EVENT_TYPE_PROPERTY_NAME = "eventType" ; private static final String HTTPS_PROPERTY_NAME = "https" ; private static final String QOS_DELIVERY_PROPERTY_NAME = "qos.delivery" ; private static final Logger log = Logger . get ( EventTapWriter . class ) ; private static final EventTapWriter . EventTypePolicy NULL_EVENT_TYPE_POLICY = new EventTapWriter . EventTypePolicy . Builder ( ) . build ( ) ; private final ServiceSelector selector ; private final ScheduledExecutorService executorService ; private final BatchProcessorFactory batchProcessorFactory ; private final EventTapFlowFactory eventTapFlowFactory ; private final boolean allowHttpConsumers ; private final AtomicReference < Map < String , EventTapWriter . EventTypePolicy > > eventTypePolicies = new AtomicReference < Map < String , EventTapWriter . EventTypePolicy > > ( ImmutableMap . < String , EventTapWriter . EventTypePolicy > of ( ) ) ; private final List < EventTapWriter . TapSpec > staticTapSpecs ; private Table < String , String , EventTapWriter . FlowInfo > flows = ImmutableTable . of ( ) ; private ScheduledFuture < ? > refreshJob ; private final Duration flowRefreshDuration ; private final QueueFactory queueFactory ; @ Inject public EventTapWriter ( @ ServiceType ( "eventTap" ) ServiceSelector selector , @ EventTap ScheduledExecutorService executorService , BatchProcessorFactory batchProcessorFactory , EventTapFlowFactory eventTapFlowFactory , EventTapConfig config , StaticEventTapConfig staticEventTapConfig , QueueFactory queueFactory ) { } @ PostConstruct public synchronized void start ( ) { } @ PreDestroy public synchronized void stop ( ) { } @ Managed public void refreshFlows ( ) { } @ Override public void write ( Event event ) { } @ Override public void distribute ( Event event ) throws IOException { } private Table < String , String , EventTapWriter . FlowInfo > constructFlowInfoFromTapSpec ( Iterable < EventTapWriter . TapSpec > tapSpecs ) { } private Table < String , String , EventTapWriter . FlowInfo > constructFlowsFromTable ( Table < String , String , EventTapWriter . FlowInfo . Builder > flows ) { } private EventTapWriter . EventTypePolicy constructPolicyForFlows ( EventTapWriter . EventTypePolicy existingPolicy , String eventType , Map < String , EventTapWriter . FlowInfo > flows ) throws IOException { EventTapWriter . EventTypePolicy . Builder policyBuilder = EventTapWriter . EventTypePolicy . builder ( ) ; EventTapWriter . log . debug ( "Constructing<seq2seq4repair_space>policy<seq2seq4repair_space>for<seq2seq4repair_space>%s" , eventType ) ; for ( Map . Entry < String , EventTapWriter . FlowInfo > flowEntry : flows . entrySet ( ) ) { String flowId = flowEntry . getKey ( ) ; EventTapWriter . FlowInfo updatedFlowInfo = flowEntry . getValue ( ) ; EventTapWriter . log . debug ( "**<seq2seq4repair_space>considering<seq2seq4repair_space>flow<seq2seq4repair_space>ID<seq2seq4repair_space>%s" , flowId ) ; Set < URI > destinations = ImmutableSet . copyOf ( updatedFlowInfo . destinations ) ; EventTapWriter . EventTypePolicy . FlowPolicy existingFlowPolicy = existingPolicy . flowPolicies . get ( flowId ) ; if ( ( existingFlowPolicy == null ) || ( ( existingFlowPolicy . qosEnabled ) != ( updatedFlowInfo . qosEnabled ) ) ) { EventTapWriter . log . debug ( "**-><seq2seq4repair_space>making<seq2seq4repair_space>new<seq2seq4repair_space>policy<seq2seq4repair_space>because<seq2seq4repair_space>%s" , ( existingFlowPolicy == null ? "existing<seq2seq4repair_space>is<seq2seq4repair_space>null" : "qos<seq2seq4repair_space>changed" ) ) ; EventTapFlow eventTapFlow ; if ( updatedFlowInfo . qosEnabled ) { eventTapFlow = eventTapFlowFactory . createQosEventTapFlow ( eventType , flowId , destinations ) ; } else { eventTapFlow = eventTapFlowFactory . createEventTapFlow ( eventType , flowId , destinations ) ; } EventTapWriter . log . debug ( "<seq2seq4repair_space>-><seq2seq4repair_space>made<seq2seq4repair_space>flow<seq2seq4repair_space>with<seq2seq4repair_space>destinations<seq2seq4repair_space>%s" , destinations ) ; <START_BUG> Queue < Event > queue = queueFactory . create ( flowId ) ; <END_BUG> BatchProcessor < Event > batchProcessor = batchProcessorFactory . createBatchProcessor ( EventTapWriter . createBatchProcessorName ( eventType , flowId ) , eventTapFlow , queue ) ; policyBuilder . addFlowPolicy ( flowId , batchProcessor , eventTapFlow , updatedFlowInfo . qosEnabled ) ; batchProcessor . start ( ) ; } else if ( ! ( destinations . equals ( existingFlowPolicy . eventTapFlow . getTaps ( ) ) ) ) { EventTapWriter . log . debug ( "**-><seq2seq4repair_space>changing<seq2seq4repair_space>taps<seq2seq4repair_space>from<seq2seq4repair_space>%s<seq2seq4repair_space>to<seq2seq4repair_space>%s" , existingFlowPolicy . eventTapFlow . getTaps ( ) , destinations ) ; existingFlowPolicy . eventTapFlow . setTaps ( destinations ) ; policyBuilder . addFlowPolicy ( flowId , existingFlowPolicy ) ; } else { EventTapWriter . log . debug ( "**-><seq2seq4repair_space>keeping<seq2seq4repair_space>as<seq2seq4repair_space>is<seq2seq4repair_space>with<seq2seq4repair_space>destinations<seq2seq4repair_space>%s" , existingFlowPolicy . eventTapFlow . getTaps ( ) ) ; policyBuilder . addFlowPolicy ( flowId , existingFlowPolicy ) ; } } return policyBuilder . build ( ) ; } private void stopExistingPoliciesNoLongerInUse ( Map < String , EventTapWriter . EventTypePolicy > existingPolicies , Map < String , EventTapWriter . EventTypePolicy > newPolicies ) { } private void stopExistingPolicyIfNoLongerInUse ( String eventType , EventTapWriter . EventTypePolicy existingPolicy , EventTapWriter . EventTypePolicy newPolicy ) { } private EventTapWriter . EventTypePolicy getPolicyForEvent ( Event event ) { } private void stopBatchProcessor ( String eventType , String flowId , BatchProcessor < Event > processor ) { } private List < EventTapWriter . TapSpec > createTapSpecFromDiscovery ( Iterable < ServiceDescriptor > descriptors ) { } private static List < EventTapWriter . TapSpec > createTapSpecFromConfig ( StaticEventTapConfig staticEventTapConfig ) { } private static URI safeUriFromString ( String uri ) { } private static String createBatchProcessorName ( String eventType , String flowId ) { } static class FlowInfo { private final boolean qosEnabled ; private final Set < URI > destinations ; private FlowInfo ( boolean qosEnabled , Set < URI > destinations ) { } static EventTapWriter . FlowInfo . Builder builder ( ) { } static class Builder { private boolean qosEnabled = false ; private ImmutableSet . Builder < URI > destinations = ImmutableSet . builder ( ) ; public EventTapWriter . FlowInfo . Builder setQosEnabled ( boolean enabled ) { } public EventTapWriter . FlowInfo . Builder addDestination ( URI destination ) { } public EventTapWriter . FlowInfo build ( ) { } } } static class EventTypePolicy { public final Map < String , EventTapWriter . EventTypePolicy . FlowPolicy > flowPolicies ; private EventTypePolicy ( Map < String , EventTapWriter . EventTypePolicy . FlowPolicy > flowPolicies ) { }

Fix:
Queue < Event > queue = queueFactory . create ( EventTapWriter . createBatchProcessorName ( eventType , flowId ) ) ;