@@ -165,9 +165,11 @@ public Optional<List<String>> snippets(boolean includeStartupScript) throws Dock
165
165
while (!(snippet = reader .readLine ()).isEmpty ()) {
166
166
snippets .add (cleanCode (snippet ));
167
167
}
168
- return Optional .of (includeStartupScript ? snippets
169
- : snippets .subList (startupScriptSize , snippets .size ()));
170
- } catch (IOException ex ) {
168
+ return Optional .of (
169
+ includeStartupScript
170
+ ? snippets
171
+ : snippets .subList (startupScriptSize , snippets .size ()));
172
+ } catch (Exception ex ) {
171
173
LOGGER .warn ("Unexpected error." , ex );
172
174
close ();
173
175
throw new DockerException (ex );
@@ -234,30 +236,14 @@ private void updateLastTimeout() {
234
236
private void checkContainerOK () throws DockerException {
235
237
try {
236
238
if (dockerService .isDead (containerName ())) {
237
- try {
238
- close ();
239
- } finally {
240
- throw new DockerException ("Container of session " + id + " is dead" );
241
- }
239
+ throw new IOException ("Container of session " + id + " is dead" );
242
240
}
243
- String OK = reader .readLine ();
244
- if (OK == null ) {
245
- try {
246
- close ();
247
- } finally {
248
- throw new DockerException ("Container of session " + id + " is dead" );
249
- }
250
- }
251
- if (!OK .equals ("OK" )) {
252
- try {
253
- close ();
254
- } finally {
255
- throw new DockerException (
256
- "Container of session " + id + " returned invalid info : " + OK );
257
- }
241
+ String ok = reader .readLine ();
242
+ if (ok == null || !ok .equals ("OK" )) {
243
+ throw new IOException ("Container of session " + id + " is dead because status was " + ok );
258
244
}
259
245
} catch (IOException ex ) {
260
- LOGGER . warn ( "Unexpected error." , ex );
246
+ close ( );
261
247
throw new DockerException (ex );
262
248
}
263
249
}
0 commit comments