diff --git a/jetty-memcached/jetty-memcached-sessions/src/main/java/org/eclipse/jetty/memcached/session/MemcachedSessionDataMap.java b/jetty-memcached/jetty-memcached-sessions/src/main/java/org/eclipse/jetty/memcached/session/MemcachedSessionDataMap.java index 13012f15211..16869a53e09 100644 --- a/jetty-memcached/jetty-memcached-sessions/src/main/java/org/eclipse/jetty/memcached/session/MemcachedSessionDataMap.java +++ b/jetty-memcached/jetty-memcached-sessions/src/main/java/org/eclipse/jetty/memcached/session/MemcachedSessionDataMap.java @@ -23,6 +23,7 @@ import java.io.IOException; import org.eclipse.jetty.server.session.SessionContext; import org.eclipse.jetty.server.session.SessionData; import org.eclipse.jetty.server.session.SessionDataMap; +import org.eclipse.jetty.util.component.AbstractLifeCycle; import net.rubyeye.xmemcached.MemcachedClient; import net.rubyeye.xmemcached.XMemcachedClientBuilder; @@ -34,7 +35,7 @@ import net.rubyeye.xmemcached.XMemcachedClientBuilder; * * Uses memcached as a cache for SessionData. */ -public class MemcachedSessionDataMap implements SessionDataMap +public class MemcachedSessionDataMap extends AbstractLifeCycle implements SessionDataMap { public static final String DEFAULT_HOST = "localhost"; public static final String DEFAULT_PORT = "11211"; @@ -125,4 +126,19 @@ public class MemcachedSessionDataMap implements SessionDataMap _client.delete(id); return true; //delete returns false if the value didn't exist } + + + + @Override + protected void doStop() throws Exception + { + super.doStop(); + if (_client != null) + { + _client.shutdown(); + _client = null; + } + } + + } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionDataMap.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionDataMap.java index ab5a51f2c72..fd1d4449d43 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionDataMap.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionDataMap.java @@ -18,12 +18,14 @@ package org.eclipse.jetty.server.session; +import org.eclipse.jetty.util.component.LifeCycle; + /** * SessionDataMap * * A map style access to SessionData keyed by the session id. */ -public interface SessionDataMap +public interface SessionDataMap extends LifeCycle { /** * Initialize this data map for the diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionDataStore.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionDataStore.java index 5e070b34ea6..f93bc5bab05 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionDataStore.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionDataStore.java @@ -29,7 +29,7 @@ import org.eclipse.jetty.util.component.LifeCycle; * A store for the data contained in a Session object. The store * would usually be persistent. */ -public interface SessionDataStore extends SessionDataMap, LifeCycle +public interface SessionDataStore extends SessionDataMap { /** diff --git a/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/MemcachedTestServer.java b/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/MemcachedTestServer.java index 8c4564f3615..0476a5d0a39 100644 --- a/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/MemcachedTestServer.java +++ b/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/MemcachedTestServer.java @@ -132,6 +132,14 @@ public class MemcachedTestServer extends AbstractTestServer return expiredIds; } + + @Override + protected void doStop() throws Exception + { + super.doStop(); + } + + } /**