diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/decoders/AvailableDecoders.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/decoders/AvailableDecoders.java index 8538262e148..57ebb056319 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/decoders/AvailableDecoders.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/decoders/AvailableDecoders.java @@ -13,6 +13,7 @@ package org.eclipse.jetty.websocket.javax.common.decoders; +import java.io.Closeable; import java.io.InputStream; import java.io.Reader; import java.nio.ByteBuffer; @@ -29,7 +30,7 @@ import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; -public class AvailableDecoders implements Iterable +public class AvailableDecoders implements Iterable, Closeable { private final List registeredDecoders = new ArrayList<>(); private final EndpointConfig config; @@ -208,6 +209,7 @@ public class AvailableDecoders implements Iterable return registeredDecoders.stream(); } + @Override public void close() { registeredDecoders.forEach(RegisteredDecoder::destroyInstance); diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/encoders/AvailableEncoders.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/encoders/AvailableEncoders.java index 0da52610678..7fde07746c5 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/encoders/AvailableEncoders.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/encoders/AvailableEncoders.java @@ -13,6 +13,7 @@ package org.eclipse.jetty.websocket.javax.common.encoders; +import java.io.Closeable; import java.lang.reflect.InvocationTargetException; import java.nio.ByteBuffer; import java.util.LinkedList; @@ -32,7 +33,7 @@ import org.eclipse.jetty.websocket.javax.common.decoders.RegisteredDecoder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AvailableEncoders implements Predicate> +public class AvailableEncoders implements Predicate>, Closeable { private static final Logger LOG = LoggerFactory.getLogger(RegisteredDecoder.class); @@ -309,6 +310,7 @@ public class AvailableEncoders implements Predicate> return registeredEncoders.stream().anyMatch(registered -> registered.isType(type)); } + @Override public void close() { registeredEncoders.forEach(RegisteredEncoder::destroyInstance);