Make AvailableEncoders & AvailableDecoders implement Closable.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2021-04-21 21:46:28 +10:00
parent ab08d1a1c6
commit 5b13006a59
2 changed files with 6 additions and 2 deletions

View File

@ -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<RegisteredDecoder>
public class AvailableDecoders implements Iterable<RegisteredDecoder>, Closeable
{
private final List<RegisteredDecoder> registeredDecoders = new ArrayList<>();
private final EndpointConfig config;
@ -208,6 +209,7 @@ public class AvailableDecoders implements Iterable<RegisteredDecoder>
return registeredDecoders.stream();
}
@Override
public void close()
{
registeredDecoders.forEach(RegisteredDecoder::destroyInstance);

View File

@ -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<Class<?>>
public class AvailableEncoders implements Predicate<Class<?>>, Closeable
{
private static final Logger LOG = LoggerFactory.getLogger(RegisteredDecoder.class);
@ -309,6 +310,7 @@ public class AvailableEncoders implements Predicate<Class<?>>
return registeredEncoders.stream().anyMatch(registered -> registered.isType(type));
}
@Override
public void close()
{
registeredEncoders.forEach(RegisteredEncoder::destroyInstance);