File tree 1 file changed +8
-7
lines changed
libs/elasticsearch-core/src/main/java/org/elasticsearch/core/internal/io
1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -87,26 +87,27 @@ public static void close(final Iterable<? extends Closeable> objects) throws IOE
87
87
* @see #close(Closeable...)
88
88
*/
89
89
public static void close (final Exception ex , final Iterable <? extends Closeable > objects ) throws IOException {
90
+ Exception error = ex ;
90
91
for (final Closeable object : objects ) {
91
92
try {
92
93
if (object != null ) {
93
94
object .close ();
94
95
}
95
96
} catch (final IOException | RuntimeException e ) {
96
- if (ex == null ) {
97
- ex = e ;
97
+ if (error == null ) {
98
+ error = e ;
98
99
} else {
99
- ex .addSuppressed (e );
100
+ error .addSuppressed (e );
100
101
}
101
102
}
102
103
}
103
104
104
- if (ex != null ) {
105
- if (ex instanceof IOException ) {
106
- throw (IOException ) ex ;
105
+ if (error != null ) {
106
+ if (error instanceof IOException ) {
107
+ throw (IOException ) error ;
107
108
} else {
108
109
// since we only assigned an IOException or a RuntimeException to ex above, in this case ex must be a RuntimeException
109
- throw (RuntimeException ) ex ;
110
+ throw (RuntimeException ) error ;
110
111
}
111
112
}
112
113
}
You can’t perform that action at this time.
0 commit comments