aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-08-29 11:19:46 +0200
committerHarald Musum <musum@oath.com>2018-08-29 11:19:46 +0200
commit276a84412940995ade11aca4c9f43e4ca87e17f9 (patch)
treed28e4d63ce74da1b609821c169c60f170d61780b /node-admin
parent89e6983eb08238e4912aeabb7b001ad966cfb23b (diff)
Avoid class loading issues by doing try and catch when closing
Make sure to not use something from a class that might have been unloaded by catching exception and rethrowing.
Diffstat (limited to 'node-admin')
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/ConfigServerApiImpl.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/ConfigServerApiImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/ConfigServerApiImpl.java
index be82e615f7a..3a9fa3d2533 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/ConfigServerApiImpl.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/ConfigServerApiImpl.java
@@ -31,6 +31,7 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import javax.net.ssl.HostnameVerifier;
import java.io.IOException;
+import java.io.UncheckedIOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.util.ArrayList;
@@ -39,7 +40,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import static com.yahoo.vespa.hosted.node.admin.task.util.file.IOExceptionUtil.uncheck;
import static java.util.Collections.singleton;
/**
@@ -174,7 +174,14 @@ public class ConfigServerApiImpl implements ConfigServerApi {
@Override
public void close() {
- uncheck(client::close);
+ // Need to do try and catch, using e.g. uncheck(client::close) might fail because
+ // components are deconstructed in random order and if the bundle containing uncheck has been
+ // unloaded it will fail with NoClassDefFoundError
+ try {
+ client.close();
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
}
private void setContentTypeToApplicationJson(HttpRequestBase request) {