summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorValerij Fredriksen <valerijf@oath.com>2018-12-07 15:33:17 +0100
committerValerij Fredriksen <valerijf@oath.com>2018-12-07 15:33:17 +0100
commit5f848c88c26cb41c01e3338a46f383a61d89a969 (patch)
tree3fbcc6acfe996edb0a1241c29b5d435a5b0ee70c /application
parentce1b30a518593155aad5e233ef40f068e23a93de (diff)
Add Exceptions.findCause()
Diffstat (limited to 'application')
-rw-r--r--application/src/main/java/com/yahoo/application/Application.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/application/src/main/java/com/yahoo/application/Application.java b/application/src/main/java/com/yahoo/application/Application.java
index 88140873b7b..64ced48edd3 100644
--- a/application/src/main/java/com/yahoo/application/Application.java
+++ b/application/src/main/java/com/yahoo/application/Application.java
@@ -20,6 +20,7 @@ import com.yahoo.search.rendering.Renderer;
import com.yahoo.text.StringUtilities;
import com.yahoo.text.Utf8;
import com.yahoo.vespa.model.VespaModel;
+import com.yahoo.yolean.Exceptions;
import org.xml.sax.SAXException;
import java.io.File;
@@ -315,8 +316,9 @@ public final class Application implements AutoCloseable {
break;
} catch (Error e) { // the container thinks this is really serious, in this case is it not in the cause is a BindException
// catch bind error and reset container
- if (e.getCause() != null && e.getCause().getCause() != null && e.getCause().getCause() instanceof BindException) {
- exception = (Exception) e.getCause().getCause();
+ Optional<BindException> bindException = Exceptions.findCause(e, BindException.class);
+ if (bindException.isPresent()) {
+ exception = bindException.get();
com.yahoo.container.Container.resetInstance(); // this is needed to be able to recreate the container from config again
} else {
throw new Exception(e.getCause());