Buggy code:
public class SubscriptionBitMapHandler { private static final String CONSTITUENT_TOPIC_CONSTANT = "other" ; private final String SPECIAL_CHARACTER_FOR_NULL = "*" ; protected ArrayList < Map < String , BitSet > > bitMapClustered ; private ArrayList < Map < String , BitSet > > bitMapLocal ; private Map < Integer , Map < String , LocalSubscription > > localSubscriptions ; private Map < Integer , Map < String , AndesSubscription > > clusteredSubscriptions ; private Map < String , Integer > localSubscriptionMapping ; private Map < String , Integer > clusteredSubscriptionMapping ; private int localSubscriptionCount ; private int clusteredSubscriptionCount ; private ArrayList < Integer > deletedLocals ; private ArrayList < Integer > deletedClusters ; public SubscriptionBitMapHandler ( ) { } public void addLocalSubscription ( String destination , LocalSubscription local ) { int columnIndexOfTheSubscriptionInBitMap ; if ( null == ( localSubscriptionMapping . get ( destination ) ) ) { if ( ( deletedLocals . size ( ) ) > 0 ) { columnIndexOfTheSubscriptionInBitMap = deletedLocals . remove ( 0 ) ; } else { columnIndexOfTheSubscriptionInBitMap = localSubscriptionCount ; ( localSubscriptionCount ) ++ ; } localSubscriptionMapping . put ( destination , columnIndexOfTheSubscriptionInBitMap ) ; localSubscriptions . put ( columnIndexOfTheSubscriptionInBitMap , new ConcurrentHashMap < String , LocalSubscription > ( ) ) ; String [ ] destinations = destination . split ( "\\." ) ; for ( int constituentPart = 0 ; constituentPart < ( destinations . length ) ; constituentPart ++ ) { if ( ( bitMapLocal . size ( ) ) <= constituentPart ) { Map < String , BitSet > newBitMapForIthConstituent ; newBitMapForIthConstituent = Collections . synchronizedMap ( new HashMap < String , BitSet > ( ) ) ; BitSet bitSet ; bitSet = new BitSet ( localSubscriptionCount ) ; bitSet . set ( 0 , localSubscriptionCount ) ; for ( int deleted : deletedLocals ) bitSet . clear ( deleted ) ; bitSet . clear ( columnIndexOfTheSubscriptionInBitMap ) ; newBitMapForIthConstituent . put ( SPECIAL_CHARACTER_FOR_NULL , bitSet ) ; BitSet bitSetForPreviousOther ; bitSetForPreviousOther = new BitSet ( ) ; if ( constituentPart != 0 ) { bitSetForPreviousOther = ( ( BitSet ) ( bitMapLocal . get ( ( constituentPart - 1 ) ) . get ( SubscriptionBitMapHandler . CONSTITUENT_TOPIC_CONSTANT ) . clone ( ) ) ) ; BitSet bitArrayForPreviousNull = ( ( BitSet ) ( bitMapLocal . get ( ( constituentPart - 1 ) ) . get ( SPECIAL_CHARACTER_FOR_NULL ) . clone ( ) ) ) ; bitSetForPreviousOther . and ( bitArrayForPreviousNull ) ; } BitSet bitSetForOther = bitSetForPreviousOther ; newBitMapForIthConstituent . put ( SubscriptionBitMapHandler . CONSTITUENT_TOPIC_CONSTANT , bitSetForOther ) ; bitMapLocal . add ( newBitMapForIthConstituent ) ; } Map < String , BitSet > bitMapForithConstituent = bitMapLocal . get ( constituentPart ) ; if ( ( "#" . equals ( destinations [ constituentPart ] ) ) || ( "*" . equals ( destinations [ constituentPart ] ) ) ) { for ( Map . Entry < String , BitSet > mapEntryForithBitMap : bitMapLocal . get ( constituentPart ) . entrySet ( ) ) { if ( ! ( SPECIAL_CHARACTER_FOR_NULL . equals ( mapEntryForithBitMap . getKey ( ) ) ) ) { mapEntryForithBitMap . getValue ( ) . set ( columnIndexOfTheSubscriptionInBitMap ) ; } else { if ( "#" . equals ( destinations [ constituentPart ] ) ) mapEntryForithBitMap . getValue ( ) . set ( columnIndexOfTheSubscriptionInBitMap ) ; } } } else { BitSet bitSetForspecificConstituentPartOfSubscription ; bitSetForspecificConstituentPartOfSubscription = bitMapForithConstituent . get ( destinations [ constituentPart ] ) ; if ( bitSetForspecificConstituentPartOfSubscription == null ) <START_BUG> bitSetForspecificConstituentPartOfSubscription = ( ( BitSet ) ( bitMapLocal . get ( constituentPart ) . get ( "other" ) . clone ( ) ) ) ; <END_BUG> bitSetForspecificConstituentPartOfSubscription . set ( columnIndexOfTheSubscriptionInBitMap ) ; bitMapForithConstituent . put ( destinations [ constituentPart ] , bitSetForspecificConstituentPartOfSubscription ) ; bitMapLocal . remove ( constituentPart ) ; bitMapLocal . add ( constituentPart , bitMapForithConstituent ) ; } } if ( "#" . equals ( destinations [ ( ( destinations . length ) - 1 ) ] ) ) { for ( int i = destinations . length ; i < ( bitMapLocal . size ( ) ) ; i ++ ) { for ( Map . Entry < String , BitSet > entry : bitMapLocal . get ( i ) . entrySet ( ) ) entry . getValue ( ) . set ( columnIndexOfTheSubscriptionInBitMap ) ; } } else { for ( int i = destinations . length ; i < ( bitMapLocal . size ( ) ) ; i ++ ) bitMapLocal . get ( i ) . get ( SPECIAL_CHARACTER_FOR_NULL ) . set ( columnIndexOfTheSubscriptionInBitMap ) ; } } columnIndexOfTheSubscriptionInBitMap = localSubscriptionMapping . get ( destination ) ; Map < String , LocalSubscription > localSubscriptionMap = localSubscriptions . get ( columnIndexOfTheSubscriptionInBitMap ) ; localSubscriptionMap . put ( local . getSubscriptionID ( ) , local ) ; localSubscriptions . put ( columnIndexOfTheSubscriptionInBitMap , localSubscriptionMap ) ; } public void addClusteredSubscription ( String destination , AndesSubscription andes ) { } private void removeSubscription ( int toBeRemoved , boolean isLocal ) { } public void removeLocalSubscription ( String subscriptionID ) { } public void removeClusteredSubscription ( String subscriptionID ) { } public ArrayList < LocalSubscription > findMatchingLocalSubscriptions ( String destination ) { } public ArrayList < AndesSubscription > findMatchingClusteredSubscriptions ( String destination ) { } public List < AndesSubscription > getAllClusteredSubscribedForDestination ( String destination ) { } public Map < String , LocalSubscription > getAllLocalSubscribedForDestination ( String destination ) { } public List < String > getAllDestinationsOfSubscriptions ( ) { } public Collection < Map < String , AndesSubscription > > getClusteredSubscriptions ( ) { } public Collection < Map < String , LocalSubscription > > getLocalSubscriptions ( ) { } public List < AndesSubscription > getAllClustered ( String destination , List < AndesSubscription > newSubscriptionList ) { } No newline ; at end ; of file ; }

Fix:
bitSetForspecificConstituentPartOfSubscription = ( ( BitSet ) ( bitMapLocal . get ( constituentPart ) . get ( SubscriptionBitMapHandler . CONSTITUENT_TOPIC_CONSTANT ) . clone ( ) ) ) ;