我正在编写一个使用 cassandra-unit 的商店单元测试。
public class StoreTest {
public void before() throws Exception {
EmbeddedCassandraServerHelper.startEmbeddedCassandra();
DataLoader dataLoader = new DataLoader("mydata", "127.0.0.1:9171");
dataLoader.load(new ClassPathJsonDataSet("cassandra.json"));
}
@After
public void after() throws Exception {
EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
}
@Test
public void testSomething() {
// test code
}
}
测试运行良好,能够连接到内存中的 cassandra 实例,并返回合理的结果。但是,当我关闭 cassandra 时,日志中出现以下异常。
17:05:48.666 [StorageServiceShutdownHook] INFO o.a.cassandra.thrift.ThriftServer - Stop listening to thrift clients
17:05:48.667 [StorageServiceShutdownHook] INFO org.apache.cassandra.gms.Gossiper - Announcing shutdown
17:05:48.782 [GossipTasks:1] DEBUG o.a.c.c.DebuggableThreadPoolExecutor - Task cancelled
java.util.concurrent.CancellationException: null
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:250) ~[na:1.7.0_21]
at java.util.concurrent.FutureTask.get(FutureTask.java:111) ~[na:1.7.0_21]
at org.apache.cassandra.concurrent.DebuggableThreadPoolExecutor.extractThrowable(DebuggableThreadPoolExecutor.java:230) [cassandra-all-1.2.0.jar:1.2.0]
at org.apache.cassandra.concurrent.DebuggableThreadPoolExecutor.logExceptionsAfterExecute(DebuggableThreadPoolExecutor.java:194) [cassandra-all-1.2.0.jar:1.2.0]
at org.apache.cassandra.concurrent.DebuggableScheduledThreadPoolExecutor.afterExecute(DebuggableScheduledThreadPoolExecutor.java:46) [cassandra-all-1.2.0.jar:1.2.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1153) [na:1.7.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_21]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_21]
17:05:49.667 [StorageServiceShutdownHook] INFO o.a.cassandra.net.MessagingService - Waiting for messaging service to quiesce
17:05:49.668 [ACCEPT-/27.0.0.1] INFO o.a.cassandra.net.MessagingService - MessagingService shutting down server thread.
这是从哪里来的,我该如何防止它发生?