@@ -152,7 +152,6 @@ public Lucene103PostingsWriter(SegmentWriteState state) throws IOException {
152
152
metaOut = state .directory .createOutput (metaFileName , state .context );
153
153
IndexOutput posOut = null ;
154
154
IndexOutput payOut = null ;
155
- boolean success = false ;
156
155
try {
157
156
docOut = state .directory .createOutput (docFileName , state .context );
158
157
CodecUtil .writeIndexHeader (
@@ -205,11 +204,9 @@ public Lucene103PostingsWriter(SegmentWriteState state) throws IOException {
205
204
}
206
205
this .payOut = payOut ;
207
206
this .posOut = posOut ;
208
- success = true ;
209
- } finally {
210
- if (!success ) {
211
- IOUtils .closeWhileHandlingException (metaOut , docOut , posOut , payOut );
212
- }
207
+ } catch (Throwable t ) {
208
+ IOUtils .closeWhileSuppressingExceptions (t , metaOut , docOut , posOut , payOut );
209
+ throw t ;
213
210
}
214
211
215
212
docDeltaBuffer = new int [BLOCK_SIZE ];
@@ -694,38 +691,37 @@ public void encodeTerm(
694
691
@ Override
695
692
public void close () throws IOException {
696
693
// TODO: add a finish() at least to PushBase? DV too...?
697
- boolean success = false ;
698
694
try {
699
- if (docOut != null ) {
700
- CodecUtil .writeFooter (docOut );
701
- }
702
- if (posOut != null ) {
703
- CodecUtil .writeFooter (posOut );
704
- }
705
- if (payOut != null ) {
706
- CodecUtil .writeFooter (payOut );
707
- }
708
- if (metaOut != null ) {
709
- metaOut .writeInt (maxNumImpactsAtLevel0 );
710
- metaOut .writeInt (maxImpactNumBytesAtLevel0 );
711
- metaOut .writeInt (maxNumImpactsAtLevel1 );
712
- metaOut .writeInt (maxImpactNumBytesAtLevel1 );
713
- metaOut .writeLong (docOut .getFilePointer ());
695
+ try {
696
+ if (docOut != null ) {
697
+ CodecUtil .writeFooter (docOut );
698
+ }
714
699
if (posOut != null ) {
715
- metaOut .writeLong (posOut .getFilePointer ());
716
- if (payOut != null ) {
717
- metaOut .writeLong (payOut .getFilePointer ());
700
+ CodecUtil .writeFooter (posOut );
701
+ }
702
+ if (payOut != null ) {
703
+ CodecUtil .writeFooter (payOut );
704
+ }
705
+ if (metaOut != null ) {
706
+ metaOut .writeInt (maxNumImpactsAtLevel0 );
707
+ metaOut .writeInt (maxImpactNumBytesAtLevel0 );
708
+ metaOut .writeInt (maxNumImpactsAtLevel1 );
709
+ metaOut .writeInt (maxImpactNumBytesAtLevel1 );
710
+ metaOut .writeLong (docOut .getFilePointer ());
711
+ if (posOut != null ) {
712
+ metaOut .writeLong (posOut .getFilePointer ());
713
+ if (payOut != null ) {
714
+ metaOut .writeLong (payOut .getFilePointer ());
715
+ }
718
716
}
717
+ CodecUtil .writeFooter (metaOut );
719
718
}
720
- CodecUtil .writeFooter (metaOut );
719
+ } catch (Throwable t ) {
720
+ IOUtils .closeWhileSuppressingExceptions (t , metaOut , docOut , posOut , payOut );
721
+ throw t ;
721
722
}
722
- success = true ;
723
+ IOUtils . close ( metaOut , docOut , posOut , payOut ) ;
723
724
} finally {
724
- if (success ) {
725
- IOUtils .close (metaOut , docOut , posOut , payOut );
726
- } else {
727
- IOUtils .closeWhileHandlingException (metaOut , docOut , posOut , payOut );
728
- }
729
725
metaOut = docOut = posOut = payOut = null ;
730
726
}
731
727
}
0 commit comments