Buggy code:
public class QueryConstruct { private static final Logger LOGGER = LoggerFactory . getLogger ( QueryEncoding . class ) ; public static Map < Integer , SubQueryPlan > instantiate ( final List < PlanFragmentEncoding > fragments , final QueryConstruct . ConstructArgs args ) throws CatalogException { } public static void setQueryExecutionOptions ( final Map < Integer , SubQueryPlan > plans , final FTMode ftMode , @ Nonnull final Set < ProfilingMode > profilingMode ) { } private static void setOrVerifyFragmentWorkers ( @ Nonnull final PlanFragmentEncoding fragment , @ Nonnull final Collection < Integer > workers , @ Nonnull final String currentTask ) { } private static void setAndVerifyScans ( final List < PlanFragmentEncoding > fragments , final QueryConstruct . ConstructArgs args ) throws CatalogException { } private static void sanityCheckEdges ( final List < PlanFragmentEncoding > fragments ) { Map < Integer , PlanFragmentEncoding > producerMap = Maps . newHashMap ( ) ; <START_BUG> Multimap < Integer , PlanFragmentEncoding > consumerMap = HashMultimap . create ( ) ; <END_BUG> final Set < Integer > soleConsumer = Sets . newHashSet ( ) ; for ( PlanFragmentEncoding fragment : fragments ) { for ( OperatorEncoding < ? > operator : fragment . operators ) { if ( operator instanceof AbstractConsumerEncoding ) { AbstractConsumerEncoding < ? > consumer = ( ( AbstractConsumerEncoding < ? > ) ( operator ) ) ; consumerMap . put ( consumer . argOperatorId , fragment ) ; } else if ( operator instanceof AbstractProducerEncoding ) { AbstractProducerEncoding < ? > producer = ( ( AbstractProducerEncoding < ? > ) ( operator ) ) ; Integer opId = producer . opId ; PlanFragmentEncoding oldFragment = producerMap . put ( opId , fragment ) ; if ( oldFragment != null ) { Preconditions . checkArgument ( false , "Two<seq2seq4repair_space>different<seq2seq4repair_space>operators<seq2seq4repair_space>cannot<seq2seq4repair_space>produce<seq2seq4repair_space>the<seq2seq4repair_space>same<seq2seq4repair_space>opId<seq2seq4repair_space>%s.<seq2seq4repair_space>Fragments:<seq2seq4repair_space>%s<seq2seq4repair_space>%s" , opId , fragment . fragmentIndex , oldFragment . fragmentIndex ) ; } if ( ! ( ( operator instanceof LocalMultiwayProducerEncoding ) || ( operator instanceof EOSControllerEncoding ) ) ) { soleConsumer . add ( opId ) ; } } else if ( operator instanceof IDBControllerEncoding ) { IDBControllerEncoding idbController = ( ( IDBControllerEncoding ) ( operator ) ) ; Integer opId = idbController . opId ; PlanFragmentEncoding oldFragment = producerMap . put ( opId , fragment ) ; if ( oldFragment != null ) { Preconditions . checkArgument ( false , "Two<seq2seq4repair_space>different<seq2seq4repair_space>operators<seq2seq4repair_space>cannot<seq2seq4repair_space>produce<seq2seq4repair_space>the<seq2seq4repair_space>same<seq2seq4repair_space>opId<seq2seq4repair_space>%s.<seq2seq4repair_space>Fragments:<seq2seq4repair_space>%s<seq2seq4repair_space>%s" , opId , fragment . fragmentIndex , oldFragment . fragmentIndex ) ; } soleConsumer . add ( opId ) ; } } } Set < Integer > consumedNotProduced = Sets . difference ( consumerMap . keySet ( ) , producerMap . keySet ( ) ) ; Preconditions . checkArgument ( consumedNotProduced . isEmpty ( ) , "Missing<seq2seq4repair_space>producer(s)<seq2seq4repair_space>for<seq2seq4repair_space>consumer(s):<seq2seq4repair_space>%s" , consumedNotProduced ) ; Set < Integer > producedNotConsumed = Sets . difference ( producerMap . keySet ( ) , consumerMap . keySet ( ) ) ; Preconditions . checkArgument ( producedNotConsumed . isEmpty ( ) , "Missing<seq2seq4repair_space>consumer(s)<seq2seq4repair_space>for<seq2seq4repair_space>producer(s):<seq2seq4repair_space>%s" , producedNotConsumed ) ; for ( Integer opId : soleConsumer ) { Collection < PlanFragmentEncoding > consumers = consumerMap . get ( opId ) ; Preconditions . checkArgument ( ( ( consumers . size ( ) ) == 1 ) , "Producer<seq2seq4repair_space>%s<seq2seq4repair_space>only<seq2seq4repair_space>supports<seq2seq4repair_space>a<seq2seq4repair_space>single<seq2seq4repair_space>consumer,<seq2seq4repair_space>not<seq2seq4repair_space>%s" , opId , consumers . size ( ) ) ; } } private static void verifyAndPropagateEdgeConstraints ( final List < PlanFragmentEncoding > fragments ) { } private static void setAndVerifySingletonConstraints ( final List < PlanFragmentEncoding > fragments , final QueryConstruct . ConstructArgs args ) { } private static void fillInRealOperatorAndWorkerIDs ( final List < PlanFragmentEncoding > fragments ) { } private static void assignWorkersToFragments ( final List < PlanFragmentEncoding > fragments , final QueryConstruct . ConstructArgs args ) throws CatalogException { } private static RootOperator instantiateFragment ( final PlanFragmentEncoding planFragment , final QueryConstruct . ConstructArgs args , final Map < PlanFragmentEncoding , RootOperator > instantiatedFragments , final Map < Integer , PlanFragmentEncoding > opOwnerFragment , final Map < Integer , Operator > allOperators ) { } public static SubQuery getRelationTupleUpdateSubQuery ( final Map < RelationKey , RelationWriteMetadata > relationsWritten , final Server server ) { } public static JsonSubQuery setDoWhileCondition ( final String condition ) { } public static final class ConstructArgs { private final Server server ; private final long queryId ; public ConstructArgs ( @ Nonnull final Server server , final long queryId ) { } public long getQueryId ( ) { } public Server getServer ( ) { } } }

Fix:
Multimap < Integer , PlanFragmentEncoding > consumerMap = ArrayListMultimap . create ( ) ;