Buggy code:
public class HttpShardHandler extends ShardHandler { private HttpShardHandlerFactory httpShardHandlerFactory ; private CompletionService < ShardResponse > completionService ; private Set < Future < ShardResponse > > pending ; private Map < String , List < String > > shardToURLs ; private HttpClient httpClient ; public HttpShardHandler ( HttpShardHandlerFactory httpShardHandlerFactory , HttpClient httpClient ) { } private static class SimpleSolrResponse extends SolrResponse { long elapsedTime ; NamedList < Object > nl ; @ Override public long getElapsedTime ( ) { } @ Override public NamedList < Object > getResponse ( ) { } @ Override public void setResponse ( NamedList < Object > rsp ) { } } private List < String > getURLs ( String shard ) { } @ Override public void submit ( final ShardRequest sreq , final String shard , final ModifiableSolrParams params ) { } @ Override public ShardResponse takeCompletedIncludingErrors ( ) { } @ Override public ShardResponse takeCompletedOrError ( ) { } private ShardResponse take ( boolean bailOnError ) { } @ Override public void cancelAll ( ) { } @ Override public void checkDistributed ( ResponseBuilder rb ) { SolrQueryRequest req = rb . req ; SolrParams params = req . getParams ( ) ; rb . isDistrib = params . getBool ( "distrib" , req . getCore ( ) . getCoreDescriptor ( ) . getCoreContainer ( ) . isZooKeeperAware ( ) ) ; String shards = params . get ( SHARDS ) ; boolean hasShardURL = ( shards != null ) && ( ( shards . indexOf ( '//' ) ) > 0 ) ; rb . isDistrib = hasShardURL | ( rb . isDistrib ) ; if ( rb . isDistrib ) { ClusterState clusterState = null ; Map < String , Slice > slices = null ; CoreDescriptor coreDescriptor = req . getCore ( ) . getCoreDescriptor ( ) ; CloudDescriptor cloudDescriptor = coreDescriptor . getCloudDescriptor ( ) ; ZkController zkController = coreDescriptor . getCoreContainer ( ) . getZkController ( ) ; if ( shards != null ) { List < String > lst = StrUtils . splitSmart ( shards , "," , true ) ; rb . shards = lst . toArray ( new String [ lst . size ( ) ] ) ; rb . slices = new String [ rb . shards . length ] ; if ( zkController != null ) { for ( int i = 0 ; i < ( rb . shards . length ) ; i ++ ) { if ( ( rb . shards [ i ] . indexOf ( '//' ) ) < 0 ) { rb . slices [ i ] = rb . shards [ i ] ; rb . shards [ i ] = null ; } } } } else if ( zkController != null ) { clusterState = zkController . getClusterState ( ) ; String shardKeys = params . get ( SHARD_KEYS ) ; slices = new HashMap < String , Slice > ( ) ; String collections = params . get ( "collection" ) ; if ( collections != null ) { List < String > collectionList = StrUtils . splitSmart ( collections , "," , true ) ; for ( String collectionName : collectionList ) { addSlices ( slices , clusterState , params , collectionName , shardKeys , true ) ; } } else { String collectionName = cloudDescriptor . getCollectionName ( ) ; addSlices ( slices , clusterState , params , collectionName , shardKeys , false ) ; } rb . slices = slices . keySet ( ) . toArray ( new String [ slices . size ( ) ] ) ; rb . shards = new String [ rb . slices . length ] ; } if ( zkController != null ) { String ourSlice = cloudDescriptor . getShardId ( ) ; String ourCollection = cloudDescriptor . getCollectionName ( ) ; <START_BUG> if ( ( ( ( rb . slices . length ) == 1 ) && ( ( rb . slices [ 0 ] . equals ( ourSlice ) ) || ( rb . slices [ 0 ] . equals ( ( ( ourCollection + "_" ) + ourSlice ) ) ) ) ) && ( ACTIVE . equals ( cloudDescriptor . getLastPublished ( ) ) ) ) { <END_BUG> boolean shortCircuit = params . getBool ( "shortCircuit" , true ) ; String targetHandler = params . get ( SHARDS_QT ) ; shortCircuit = shortCircuit && ( targetHandler == null ) ; if ( shortCircuit ) { rb . isDistrib = false ; return ; } } for ( int i = 0 ; i < ( rb . shards . length ) ; i ++ ) { if ( ( rb . shards [ i ] ) == null ) { if ( clusterState == null ) { clusterState = zkController . getClusterState ( ) ; slices = clusterState . getSlicesMap ( cloudDescriptor . getCollectionName ( ) ) ; } String sliceName = rb . slices [ i ] ; Slice slice = slices . get ( sliceName ) ; if ( slice == null ) { rb . shards [ i ] = "" ; continue ; } Map < String , Replica > sliceShards = slice . getReplicasMap ( ) ; Set < String > liveNodes = clusterState . getLiveNodes ( ) ; StringBuilder sliceShardsStr = new StringBuilder ( ) ; boolean first = true ; for ( ZkNodeProps nodeProps : sliceShards . values ( ) ) { ZkCoreNodeProps coreNodeProps = new ZkCoreNodeProps ( nodeProps ) ; if ( ( ! ( liveNodes . contains ( coreNodeProps . getNodeName ( ) ) ) ) || ( ! ( coreNodeProps . getState ( ) . equals ( ACTIVE ) ) ) ) continue ; if ( first ) { first = false ; } else { sliceShardsStr . append ( '|' ) ; } String url = coreNodeProps . getCoreUrl ( ) ;

Fix:
if ( ( ( ( ( rb . slices . length ) == 1 ) && ( ( rb . slices [ 0 ] ) != null ) ) && ( ( rb . slices [ 0 ] . equals ( ourSlice ) ) || ( rb . slices [ 0 ] . equals ( ( ( ourCollection + "_" ) + ourSlice ) ) ) ) ) && ( ACTIVE . equals ( cloudDescriptor . getLastPublished ( ) ) ) ) {