@@ -481,49 +481,50 @@ public List<Completion> executePipeline(
481481 responseMsg [i ] = sendQuery (messages [i ]);
482482 }
483483 while (readCounter < messages .length ) {
484- for (int j = 0 ; j < responseMsg [readCounter ]; j ++) {
484+ readCounter ++;
485+ for (int j = 0 ; j < responseMsg [readCounter - 1 ]; j ++) {
485486 results .addAll (
486487 readResponse (
487488 stmt ,
488- messages [readCounter ],
489+ messages [readCounter - 1 ],
489490 fetchSize ,
490491 maxRows ,
491492 resultSetConcurrency ,
492493 resultSetType ,
493494 closeOnCompletion ));
494495 }
495- readCounter ++;
496496 }
497497 }
498498 return results ;
499499 } catch (SQLException sqlException ) {
500-
501- // read remaining results
502- for (int i = readCounter + 1 ; i < messages .length ; i ++) {
503- for (int j = 0 ; j < responseMsg [i ]; j ++) {
504- try {
505- results .addAll (
506- readResponse (
507- stmt ,
508- messages [i ],
509- fetchSize ,
510- maxRows ,
511- resultSetConcurrency ,
512- resultSetType ,
513- closeOnCompletion ));
514- } catch (SQLException e ) {
515- // eat
500+ if (!closed ) {
501+ // read remaining results
502+ for (int i = readCounter ; i < messages .length ; i ++) {
503+ for (int j = 0 ; j < responseMsg [i ]; j ++) {
504+ try {
505+ results .addAll (
506+ readResponse (
507+ stmt ,
508+ messages [i ],
509+ fetchSize ,
510+ maxRows ,
511+ resultSetConcurrency ,
512+ resultSetType ,
513+ closeOnCompletion ));
514+ } catch (SQLException e ) {
515+ // eat
516+ }
516517 }
517518 }
518- }
519519
520- // prepare associated to PrepareStatement need to be uncached
521- for (Completion result : results ) {
522- if (result instanceof PrepareResultPacket && stmt instanceof ServerPreparedStatement ) {
523- try {
524- ((PrepareResultPacket ) result ).decrementUse (this , (ServerPreparedStatement ) stmt );
525- } catch (SQLException e ) {
526- // eat
520+ // prepare associated to PrepareStatement need to be uncached
521+ for (Completion result : results ) {
522+ if (result instanceof PrepareResultPacket && stmt instanceof ServerPreparedStatement ) {
523+ try {
524+ ((PrepareResultPacket ) result ).decrementUse (this , (ServerPreparedStatement ) stmt );
525+ } catch (SQLException e ) {
526+ // eat
527+ }
527528 }
528529 }
529530 }
0 commit comments