From 3eda16988c6c84d6a084b331d3a2c0d5f8a06196 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Sun, 7 Apr 2019 11:05:26 +0200 Subject: [PATCH] Fixed ClassCastException. Cannot cast Handler[] down to ContextHandlerCollection[]. Signed-off-by: Simone Bordet --- .../eclipse/jetty/server/handler/ContextHandler.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java index 6b8fbcc8be53..b6ca0460a457 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java @@ -1605,10 +1605,13 @@ else if (contextPath.length() > 1 && contextPath.endsWith("/")) if (getServer() != null && (getServer().isStarting() || getServer().isStarted())) { - ContextHandlerCollection[] contextCollections = - (ContextHandlerCollection[])getServer().getChildHandlersByClass(ContextHandlerCollection.class); - for (int h = 0; contextCollections != null && h < contextCollections.length; h++) - contextCollections[h].mapContexts(); + Class handlerClass = ContextHandlerCollection.class; + Handler[] contextCollections = getServer().getChildHandlersByClass(handlerClass); + if (contextCollections != null) + { + for (Handler contextCollection : contextCollections) + handlerClass.cast(contextCollection).mapContexts(); + } } }