Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1648 from mactaggart/cassandra-session
Browse files Browse the repository at this point in the history
Check if Cassandra session is closed before using
  • Loading branch information
apanicker-nflx committed Apr 20, 2020
2 parents 6071b51 + 9552387 commit 0705f48
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Expand Up @@ -118,6 +118,10 @@ public List<EventHandler> getEventHandlersForEvent(String event, boolean activeO
}

private void refreshEventHandlersCache() {
if (session.isClosed()) {
LOGGER.warn("session is closed");
return;
}
try {
Map<String, EventHandler> map = new HashMap<>();
getAllEventHandlersFromDB().forEach(eventHandler -> map.put(eventHandler.getName(), eventHandler));
Expand Down
Expand Up @@ -266,6 +266,10 @@ public List<WorkflowDef> getAllWorkflowDefs() {
}

private void refreshTaskDefsCache() {
if (session.isClosed()) {
LOGGER.warn("session is closed");
return;
}
try {
Map<String, TaskDef> map = new HashMap<>();
getAllTaskDefsFromDB().forEach(taskDef -> map.put(taskDef.getName(), taskDef));
Expand Down
Expand Up @@ -57,7 +57,7 @@ public class CassandraDAOTest {
private final ObjectMapper objectMapper = new JsonMapperProvider().get();

private static EmbeddedCassandra embeddedCassandra;
private Session session;
private static Session session;

private CassandraMetadataDAO metadataDAO;
private CassandraExecutionDAO executionDAO;
Expand All @@ -69,11 +69,11 @@ public class CassandraDAOTest {
@BeforeClass
public static void init() throws Exception {
embeddedCassandra = new EmbeddedCassandra();
session = embeddedCassandra.getSession();
}

@Before
public void setUp() {
session = embeddedCassandra.getSession();
Statements statements = new Statements(testConfiguration);
metadataDAO = new CassandraMetadataDAO(session, objectMapper, testConfiguration, statements);
executionDAO = new CassandraExecutionDAO(session, objectMapper, testConfiguration, statements);
Expand All @@ -83,6 +83,7 @@ public void setUp() {
@AfterClass
public static void teardown() {
embeddedCassandra.cleanupData();
session.close();
}

@Test
Expand Down

0 comments on commit 0705f48

Please sign in to comment.