Skip to content

Commit

Permalink
[ issue #10 ] Proper dictionary unregistration when ClientShutDownHook
Browse files Browse the repository at this point in the history
executes close()
  • Loading branch information
agazzarini committed Sep 3, 2014
1 parent 7ff0cb7 commit fe4882b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.gazzax.labs.jena.nosql.cassandra;

import org.gazzax.labs.jena.nosql.fwk.dictionary.TopLevelDictionary;
import org.gazzax.labs.jena.nosql.fwk.factory.ClientShutdownHook;
import org.gazzax.labs.jena.nosql.fwk.log.Log;
import org.gazzax.labs.jena.nosql.fwk.log.MessageCatalog;
Expand All @@ -16,14 +17,17 @@
public class CassandraClientShutdownHook implements ClientShutdownHook {
private static final Log LOGGER = new Log(LoggerFactory.getLogger(ClientShutdownHook.class));
private final Session session;
final TopLevelDictionary dictionary;

/**
* Builds a new Cassandra Client shutdown hook.
*
* @param session the connection to Cassandra.
* @param dictionary the dictionary in use.
*/
public CassandraClientShutdownHook(final Session session) {
public CassandraClientShutdownHook(final Session session, final TopLevelDictionary dictionary) {
this.session = session;
this.dictionary = dictionary;
}

@Override
Expand All @@ -33,5 +37,6 @@ public void close() {
} catch (final Exception exception) {
LOGGER.error(MessageCatalog._00099_CLIENT_SHUTDOWN_FAILURE, exception);
}
dictionary.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public TopLevelDictionary getDictionary() {

@Override
public ClientShutdownHook getClientShutdownHook() {
return new CassandraClientShutdownHook(session);
return new CassandraClientShutdownHook(session, dictionary);
}

@Override
Expand Down

0 comments on commit fe4882b

Please sign in to comment.