From fb96e7d0b15d253464c5d441fcdbcaf6f1cf343e Mon Sep 17 00:00:00 2001 From: Charles Allen Date: Thu, 4 Aug 2016 17:52:31 -0700 Subject: [PATCH 1/6] Allow compilation as Java8 source and target for everything except API --- api/pom.xml | 8 ++++++++ pom.xml | 8 ++++++++ .../druid/query/timeboundary/TimeBoundaryQueryTest.java | 2 +- .../java/io/druid/client/CachingClusteredClientTest.java | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index d494af174e4c..f1dd7406c596 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -133,6 +133,14 @@ org.apache.maven.plugins maven-release-plugin + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + + diff --git a/pom.xml b/pom.xml index a8bbdff1350e..61a57a2679a2 100644 --- a/pom.xml +++ b/pom.xml @@ -977,6 +977,14 @@ true + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + diff --git a/processing/src/test/java/io/druid/query/timeboundary/TimeBoundaryQueryTest.java b/processing/src/test/java/io/druid/query/timeboundary/TimeBoundaryQueryTest.java index 7740712500b9..1c332fb23dc6 100644 --- a/processing/src/test/java/io/druid/query/timeboundary/TimeBoundaryQueryTest.java +++ b/processing/src/test/java/io/druid/query/timeboundary/TimeBoundaryQueryTest.java @@ -78,7 +78,7 @@ public void testContextSerde() throws Exception ); - Assert.assertEquals(1, serdeQuery.getContextValue("priority")); + Assert.assertEquals(new Integer(1), serdeQuery.getContextValue("priority")); Assert.assertEquals(true, serdeQuery.getContextValue("useCache")); Assert.assertEquals(true, serdeQuery.getContextValue("populateCache")); Assert.assertEquals(true, serdeQuery.getContextValue("finalize")); diff --git a/server/src/test/java/io/druid/client/CachingClusteredClientTest.java b/server/src/test/java/io/druid/client/CachingClusteredClientTest.java index 6cd7dcfa774e..b81f1ee1b9a8 100644 --- a/server/src/test/java/io/druid/client/CachingClusteredClientTest.java +++ b/server/src/test/java/io/druid/client/CachingClusteredClientTest.java @@ -395,7 +395,7 @@ public void onFailure(Throwable t) } return task instanceof Callable ? delegate.submit((Callable) task) : - delegate.submit((Runnable) task); + (ListenableFuture) delegate.submit((Runnable) task); } @Override From 0df17e189e08aa0166bec51e97279f77775f8404 Mon Sep 17 00:00:00 2001 From: leventov Date: Tue, 14 Mar 2017 17:06:15 -0600 Subject: [PATCH 2/6] Remove conditions in tests which assume that we may run with Java 7 --- .../ReferenceCountingResourceHolderTest.java | 12 ------------ .../java/io/druid/collections/StupidPoolTest.java | 6 ------ .../druid/client/cache/MemcacheClientPoolTest.java | 6 ------ 3 files changed, 24 deletions(-) diff --git a/common/src/test/java/io/druid/collections/ReferenceCountingResourceHolderTest.java b/common/src/test/java/io/druid/collections/ReferenceCountingResourceHolderTest.java index ba73fe6cd163..087860e17242 100644 --- a/common/src/test/java/io/druid/collections/ReferenceCountingResourceHolderTest.java +++ b/common/src/test/java/io/druid/collections/ReferenceCountingResourceHolderTest.java @@ -91,12 +91,6 @@ public void close() throws IOException @Test(timeout = 60_000) public void testResourceHandlerClearedByJVM() throws InterruptedException { - if (System.getProperty("java.version").startsWith("1.7")) { - // This test is unreliable on Java 7, probably GC is not triggered by System.gc(). It is not a problem because - // this test should ever pass on any version of Java to prove that ReferenceCountingResourceHolder doesn't - // introduce leaks itself and actually cleans the leaked resources. - return; - } long initialLeakedResources = ReferenceCountingResourceHolder.leakedResources(); final AtomicBoolean released = new AtomicBoolean(false); makeReleasingHandler(released); // Don't store the handler in a variable and don't close it, the object leaked @@ -106,12 +100,6 @@ public void testResourceHandlerClearedByJVM() throws InterruptedException @Test(timeout = 60_000) public void testResourceHandlerWithReleaserClearedByJVM() throws InterruptedException { - if (System.getProperty("java.version").startsWith("1.7")) { - // This test is unreliable on Java 7, probably GC is not triggered by System.gc(). It is not a problem because - // this test should ever pass on any version of Java to prove that ReferenceCountingResourceHolder doesn't - // introduce leaks itself and actually cleans the leaked resources. - return; - } long initialLeakedResources = ReferenceCountingResourceHolder.leakedResources(); final AtomicBoolean released = new AtomicBoolean(false); // createDanglingReleaser() need to be a separate method because otherwise JVM preserves a ref to Holder on stack diff --git a/common/src/test/java/io/druid/collections/StupidPoolTest.java b/common/src/test/java/io/druid/collections/StupidPoolTest.java index 7d3eedd08460..df31c7afb8cd 100644 --- a/common/src/test/java/io/druid/collections/StupidPoolTest.java +++ b/common/src/test/java/io/druid/collections/StupidPoolTest.java @@ -73,12 +73,6 @@ public void testExceptionInResourceHolderGet() throws IOException @Test(timeout = 60_000) public void testResourceHandlerClearedByJVM() throws InterruptedException { - if (System.getProperty("java.version").startsWith("1.7")) { - // This test is unreliable on Java 7, probably GC is not triggered by System.gc(). It is not a problem because - // this test should ever pass on any version of Java to prove that StupidPool doesn't introduce leaks itself and - // actually cleans the leaked objects. - return; - } String leakedString = createDanglingObjectHandler(); // Wait until dangling object string is returned to the pool for (int i = 0; i < 6000 && poolOfString.leakedObjectsCount() == 0; i++) { diff --git a/server/src/test/java/io/druid/client/cache/MemcacheClientPoolTest.java b/server/src/test/java/io/druid/client/cache/MemcacheClientPoolTest.java index 0ce83617a333..022bc319d970 100644 --- a/server/src/test/java/io/druid/client/cache/MemcacheClientPoolTest.java +++ b/server/src/test/java/io/druid/client/cache/MemcacheClientPoolTest.java @@ -57,12 +57,6 @@ public void testSimpleUsage() @Test public void testClientLeakDetected() throws InterruptedException { - if (System.getProperty("java.version").startsWith("1.7")) { - // This test is unreliable on Java 7, probably GC is not triggered by System.gc(). It is not a problem because - // this test should ever pass on any version of Java to prove that MemcacheClientPool doesn't introduce leaks - // itself. - return; - } long initialLeakedClients = MemcacheClientPool.leakedClients(); createDanglingClient(); // Wait until Closer runs From ec6625ef55998b7387e11bed7b681758d32294e0 Mon Sep 17 00:00:00 2001 From: leventov Date: Tue, 14 Mar 2017 17:06:30 -0600 Subject: [PATCH 3/6] Update easymock to 3.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 61a57a2679a2..477616c0c79e 100644 --- a/pom.xml +++ b/pom.xml @@ -647,7 +647,7 @@ org.easymock easymock - 3.3 + 3.4 test From 7d3e79566fd1457f9085c8b7107519d1e67ce8fd Mon Sep 17 00:00:00 2001 From: leventov Date: Tue, 14 Mar 2017 17:53:25 -0600 Subject: [PATCH 4/6] Make Animal Sniffer to check Java 1.8 usage; remove redundant druid-caffeine-cache configuration --- extensions-core/caffeine-cache/pom.xml | 34 -------------------------- pom.xml | 2 +- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/extensions-core/caffeine-cache/pom.xml b/extensions-core/caffeine-cache/pom.xml index 3370b09b3596..12fbe0f0f828 100644 --- a/extensions-core/caffeine-cache/pom.xml +++ b/extensions-core/caffeine-cache/pom.xml @@ -65,38 +65,4 @@ test - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - org.codehaus.mojo - animal-sniffer-maven-plugin - - - - check-java-api - test - - check - - - - org.codehaus.mojo.signature - - java18 - 1.0 - - - - - - - diff --git a/pom.xml b/pom.xml index 477616c0c79e..cb7cdf700e4d 100644 --- a/pom.xml +++ b/pom.xml @@ -811,7 +811,7 @@ org.codehaus.mojo.signature - java17 + java18 1.0 From 05b84a139392d52bccc99a2aa39a8393398b5504 Mon Sep 17 00:00:00 2001 From: leventov Date: Tue, 14 Mar 2017 18:51:28 -0600 Subject: [PATCH 5/6] Use try-with-resources in LargeColumnSupportedComplexColumnSerializerTest.testSanity() --- ...nSupportedComplexColumnSerializerTest.java | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/processing/src/test/java/io/druid/segment/serde/LargeColumnSupportedComplexColumnSerializerTest.java b/processing/src/test/java/io/druid/segment/serde/LargeColumnSupportedComplexColumnSerializerTest.java index bba412f58bc8..a7e7b98cf42d 100644 --- a/processing/src/test/java/io/druid/segment/serde/LargeColumnSupportedComplexColumnSerializerTest.java +++ b/processing/src/test/java/io/druid/segment/serde/LargeColumnSupportedComplexColumnSerializerTest.java @@ -56,35 +56,33 @@ public void testSanity() throws IOException 2500 * Longs.BYTES }; - for (int k = 0; k < columnSizes.length; k++) { - for (int j = 0; j < cases.length; j++) { - IOPeon peon = new TmpFileIOPeon(); + for (int columnSize : columnSizes) { + for (int aCase : cases) { File tmpFile = FileUtils.getTempDirectory(); - final FileSmoosher v9Smoosher = new FileSmoosher(tmpFile); - - LargeColumnSupportedComplexColumnSerializer serializer = LargeColumnSupportedComplexColumnSerializer - .createWithColumnSize(peon, "test", serde.getObjectStrategy(), columnSizes[k]); HyperLogLogCollector baseCollector = HyperLogLogCollector.makeLatestCollector(); - - serializer.open(); - for (int i = 0; i < cases[j]; i++) { - HyperLogLogCollector collector = HyperLogLogCollector.makeLatestCollector(); - byte[] hashBytes = fn.hashLong(i).asBytes(); - collector.add(hashBytes); - baseCollector.fold(collector); - serializer.serialize(collector); + try (IOPeon peon = new TmpFileIOPeon(); + FileSmoosher v9Smoosher = new FileSmoosher(tmpFile)) { + + LargeColumnSupportedComplexColumnSerializer serializer = LargeColumnSupportedComplexColumnSerializer + .createWithColumnSize(peon, "test", serde.getObjectStrategy(), columnSize); + + serializer.open(); + for (int i = 0; i < aCase; i++) { + HyperLogLogCollector collector = HyperLogLogCollector.makeLatestCollector(); + byte[] hashBytes = fn.hashLong(i).asBytes(); + collector.add(hashBytes); + baseCollector.fold(collector); + serializer.serialize(collector); + } + serializer.close(); + + try (final SmooshedWriter channel = v9Smoosher.addWithSmooshedWriter( + "test", + serializer.getSerializedSize() + )) { + serializer.writeToChannel(channel, v9Smoosher); + } } - serializer.close(); - - final SmooshedWriter channel = v9Smoosher.addWithSmooshedWriter( - "test", - serializer.getSerializedSize() - ); - serializer.writeToChannel(channel, v9Smoosher); - - channel.close(); - peon.close(); - v9Smoosher.close(); SmooshedFileMapper mapper = Smoosh.map(tmpFile); final ColumnBuilder builder = new ColumnBuilder() @@ -97,7 +95,7 @@ public void testSanity() throws IOException ComplexColumn complexColumn = column.getComplexColumn(); HyperLogLogCollector collector = HyperLogLogCollector.makeLatestCollector(); - for (int i = 0; i < cases[j]; i++) { + for (int i = 0; i < aCase; i++) { collector.fold((HyperLogLogCollector) complexColumn.getRowValue(i)); } Assert.assertEquals(baseCollector.estimateCardinality(), collector.estimateCardinality(), 0.0); From 5b08f7e77b03009899393b0b674163afff352cb6 Mon Sep 17 00:00:00 2001 From: Charles Allen Date: Tue, 14 Mar 2017 19:55:28 -0700 Subject: [PATCH 6/6] Remove java7 special for druid-api --- api/pom.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index f1dd7406c596..d494af174e4c 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -133,14 +133,6 @@ org.apache.maven.plugins maven-release-plugin - - org.apache.maven.plugins - maven-compiler-plugin - - 1.7 - 1.7 - -