diff --git a/extensions/namespace-lookup/src/main/java/io/druid/server/namespace/cache/NamespaceExtractionCacheManager.java b/extensions/namespace-lookup/src/main/java/io/druid/server/namespace/cache/NamespaceExtractionCacheManager.java index 27782c9f852..d07f384658f 100644 --- a/extensions/namespace-lookup/src/main/java/io/druid/server/namespace/cache/NamespaceExtractionCacheManager.java +++ b/extensions/namespace-lookup/src/main/java/io/druid/server/namespace/cache/NamespaceExtractionCacheManager.java @@ -363,7 +363,7 @@ public abstract class NamespaceExtractionCacheManager tasksStarted.incrementAndGet(); final String newVersion = runnable.call(); if (preVersion != null && preVersion.equals(newVersion)) { - throw new IllegalStateException("Already exists"); + throw new CancellationException(String.format("Version `%s` already exists", preVersion)); } if (newVersion != null) { lastVersion.put(namespaceName, newVersion); @@ -379,6 +379,9 @@ public abstract class NamespaceExtractionCacheManager } else { log.error(t, "Failed update namespace [%s]", namespace); } + if(Thread.currentThread().isInterrupted()) { + throw Throwables.propagate(t); + } } } }; diff --git a/extensions/namespace-lookup/src/test/java/io/druid/server/namespace/cache/JDBCExtractionNamespaceTest.java b/extensions/namespace-lookup/src/test/java/io/druid/server/namespace/cache/JDBCExtractionNamespaceTest.java index 00837af9fd0..8b05a77d1a2 100644 --- a/extensions/namespace-lookup/src/test/java/io/druid/server/namespace/cache/JDBCExtractionNamespaceTest.java +++ b/extensions/namespace-lookup/src/test/java/io/druid/server/namespace/cache/JDBCExtractionNamespaceTest.java @@ -140,33 +140,29 @@ public class JDBCExtractionNamespaceTest ); handle.createStatement(String.format("TRUNCATE TABLE %s", tableName)).setQueryTimeout(1).execute(); handle.commit(); - closer.register( - new Closeable() - { - @Override - public void close() throws IOException - { - // Register first so it gets run last and checks for cleanup - final NamespaceExtractionCacheManager.NamespaceImplData implData = - extractionCacheManager.implData.get(namespace); - if (implData != null && implData.future != null) { - implData.future.cancel(true); - Assert.assertTrue(implData.future.isDone()); - } - } + closer.register(new Closeable() + { + @Override + public void close() throws IOException + { + handle.createStatement("DROP TABLE " + tableName).setQueryTimeout(1).execute(); + handle.close(); + } + }); + closer.register(new Closeable() + { + @Override + public void close() throws IOException + { + // Register first so it gets run last and checks for cleanup + final NamespaceExtractionCacheManager.NamespaceImplData implData = extractionCacheManager.implData.get( + namespace); + if (implData != null && implData.future != null) { + implData.future.cancel(true); + Assert.assertTrue(implData.future.isDone()); } - ); - closer.register( - new Closeable() - { - @Override - public void close() throws IOException - { - handle.createStatement("DROP TABLE " + tableName).setQueryTimeout(1).execute(); - handle.close(); - } - } - ); + } + }); for (Map.Entry entry : renames.entrySet()) { try { insertValues(entry.getKey(), entry.getValue(), "2015-01-01 00:00:00"); @@ -427,7 +423,6 @@ public class JDBCExtractionNamespaceTest assertUpdated(extractionNamespace.getNamespace(), "foo", "bar"); } - @Ignore // https://github.com/druid-io/druid/issues/2160 @Test(timeout = 60_000L) public void testFindNew() throws NoSuchFieldException, IllegalAccessException, ExecutionException, InterruptedException