You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2018/08/08 00:23:11 UTC

[GitHub] jihoonson closed pull request #6075: validate non-empty String baseDataSource in MaterializedViewSuperviso…

jihoonson closed pull request #6075: validate non-empty String baseDataSource in MaterializedViewSuperviso…
URL: https://github.com/apache/incubator-druid/pull/6075
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/extensions-contrib/materialized-view-maintenance/src/main/java/io/druid/indexing/materializedview/MaterializedViewSupervisorSpec.java b/extensions-contrib/materialized-view-maintenance/src/main/java/io/druid/indexing/materializedview/MaterializedViewSupervisorSpec.java
index 69fcbcae00c..e77fec1b1b4 100644
--- a/extensions-contrib/materialized-view-maintenance/src/main/java/io/druid/indexing/materializedview/MaterializedViewSupervisorSpec.java
+++ b/extensions-contrib/materialized-view-maintenance/src/main/java/io/druid/indexing/materializedview/MaterializedViewSupervisorSpec.java
@@ -26,6 +26,7 @@
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
+import com.google.common.base.Strings;
 import io.druid.data.input.impl.DimensionSchema;
 import io.druid.data.input.impl.DimensionsSpec;
 import io.druid.indexer.HadoopIOConfig;
@@ -102,10 +103,9 @@ public MaterializedViewSupervisorSpec(
       @JacksonInject ChatHandlerProvider chatHandlerProvider
   )
   {
-    this.baseDataSource = Preconditions.checkNotNull(
-                            baseDataSource, 
-                            "baseDataSource cannot be null. Please provide a baseDataSource."
-                          );
+    Preconditions.checkArgument(!Strings.isNullOrEmpty(baseDataSource), "baseDataSource cannot be null or empty. Please provide a baseDataSource.");
+    this.baseDataSource = baseDataSource;
+
     this.dimensionsSpec = Preconditions.checkNotNull(
                             dimensionsSpec, 
                             "dimensionsSpec cannot be null. Please provide a dimensionsSpec"
diff --git a/extensions-contrib/materialized-view-maintenance/src/test/java/io/druid/indexing/materializedview/MaterializedViewSupervisorSpecTest.java b/extensions-contrib/materialized-view-maintenance/src/test/java/io/druid/indexing/materializedview/MaterializedViewSupervisorSpecTest.java
index 7a7951ee5ea..dd3a7342055 100644
--- a/extensions-contrib/materialized-view-maintenance/src/test/java/io/druid/indexing/materializedview/MaterializedViewSupervisorSpecTest.java
+++ b/extensions-contrib/materialized-view-maintenance/src/test/java/io/druid/indexing/materializedview/MaterializedViewSupervisorSpecTest.java
@@ -44,11 +44,17 @@
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.hamcrest.CoreMatchers;
+import org.junit.Rule;
+import org.junit.rules.ExpectedException;
 
 import java.io.IOException;
 
 public class MaterializedViewSupervisorSpecTest 
 {
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
   private ObjectMapper objectMapper = TestHelper.makeJsonMapper();
   
   @Before
@@ -143,4 +149,92 @@ public void testSupervisorSerialization() throws IOException
     Assert.assertEquals(expected.getDimensions(), spec.getDimensions());
     Assert.assertEquals(expected.getMetrics(), spec.getMetrics());
   }
+
+  @Test
+  public void testEmptyBaseDataSource() throws Exception
+  {
+    expectedException.expect(CoreMatchers.instanceOf(IllegalArgumentException.class));
+    expectedException.expectMessage(
+        "baseDataSource cannot be null or empty. Please provide a baseDataSource."
+    );
+    MaterializedViewSupervisorSpec materializedViewSupervisorSpec = new MaterializedViewSupervisorSpec(
+        "",
+        new DimensionsSpec(
+            Lists.newArrayList(
+                new StringDimensionSchema("isUnpatrolled"),
+                new StringDimensionSchema("metroCode"),
+                new StringDimensionSchema("namespace"),
+                new StringDimensionSchema("page"),
+                new StringDimensionSchema("regionIsoCode"),
+                new StringDimensionSchema("regionName"),
+                new StringDimensionSchema("user")
+            ),
+            null,
+            null
+        ),
+        new AggregatorFactory[]{
+            new CountAggregatorFactory("count"),
+            new LongSumAggregatorFactory("added", "added")
+        },
+        HadoopTuningConfig.makeDefaultTuningConfig(),
+        null,
+        null,
+        null,
+        null,
+        null,
+        objectMapper,
+        null,
+        null,
+        null,
+        null,
+        null,
+        new MaterializedViewTaskConfig(),
+        createMock(AuthorizerMapper.class),
+        new NoopChatHandlerProvider()
+    );
+  }
+
+  @Test
+  public void testNullBaseDataSource() throws Exception
+  {
+    expectedException.expect(CoreMatchers.instanceOf(IllegalArgumentException.class));
+    expectedException.expectMessage(
+        "baseDataSource cannot be null or empty. Please provide a baseDataSource."
+    );
+    MaterializedViewSupervisorSpec materializedViewSupervisorSpec = new MaterializedViewSupervisorSpec(
+        null,
+        new DimensionsSpec(
+            Lists.newArrayList(
+                new StringDimensionSchema("isUnpatrolled"),
+                new StringDimensionSchema("metroCode"),
+                new StringDimensionSchema("namespace"),
+                new StringDimensionSchema("page"),
+                new StringDimensionSchema("regionIsoCode"),
+                new StringDimensionSchema("regionName"),
+                new StringDimensionSchema("user")
+            ),
+            null,
+            null
+        ),
+        new AggregatorFactory[]{
+            new CountAggregatorFactory("count"),
+            new LongSumAggregatorFactory("added", "added")
+        },
+        HadoopTuningConfig.makeDefaultTuningConfig(),
+        null,
+        null,
+        null,
+        null,
+        null,
+        objectMapper,
+        null,
+        null,
+        null,
+        null,
+        null,
+        new MaterializedViewTaskConfig(),
+        createMock(AuthorizerMapper.class),
+        new NoopChatHandlerProvider()
+    );
+  }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org