github-advanced-security[bot] commented on code in PR #15434:
URL: https://github.com/apache/druid/pull/15434#discussion_r1405788337
##########
processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyBufferAggregatorTest.java:
##########
@@ -198,4 +189,77 @@
Assert.assertEquals("1.0", result);
}
+
+ @Test
+ public void testMvds()
+ {
+ List<String> mvd = Lists.newArrayList("AAAA", "AAAAB", "AAAC");
+ final Object[] mvds = {null, "CCCC", mvd, "BBBB", "EEEE"};
+ Integer maxStringBytes = 1024;
+
+ TestObjectColumnSelector<Object> objectColumnSelector = new
TestObjectColumnSelector<>(mvds);
+
+ StringAnyBufferAggregator agg = new StringAnyBufferAggregator(
+ objectColumnSelector,
+ maxStringBytes, true
+ );
+
+ ByteBuffer buf = ByteBuffer.allocate(factory.getMaxIntermediateSize() * 2);
+ int position = 0;
+
+ int[] positions = new int[]{0, 1, 43, 100, 189};
+ Arrays.stream(positions).forEach(i -> agg.init(buf, i));
+
+ //noinspection ForLoopReplaceableByForEach
+ for (int i = 0; i < mvds.length; i++) {
+ aggregateBuffer(objectColumnSelector, agg, buf, positions[i]);
+ }
+ String result = ((String) agg.get(buf, position));
+ Assert.assertNull(result);
+
+ for (int i = 0; i < positions.length; i++) {
+ if (i == 2) {
+ Assert.assertEquals(mvd.toString(), agg.get(buf, positions[2]));
+ } else {
+ Assert.assertEquals(mvds[i], agg.get(buf, positions[i]));
+ }
+ }
+ }
+
+ @Test
+ public void testMvdsWithCustomAggregate()
+ {
+ List<String> mvd = Lists.newArrayList("AAAA", "AAAAB", "AAAC");
+ final Object[] mvds = {null, "CCCC", mvd, "BBBB", "EEEE"};
+ Integer maxStringBytes = 1024;
Review Comment:
## Boxed variable is never null
The variable 'maxStringBytes' is only assigned values of primitive type and
is never 'null', but it is declared with the boxed type 'Integer'.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6005)
##########
processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyBufferAggregatorTest.java:
##########
@@ -198,4 +189,77 @@
Assert.assertEquals("1.0", result);
}
+
+ @Test
+ public void testMvds()
+ {
+ List<String> mvd = Lists.newArrayList("AAAA", "AAAAB", "AAAC");
+ final Object[] mvds = {null, "CCCC", mvd, "BBBB", "EEEE"};
+ Integer maxStringBytes = 1024;
Review Comment:
## Boxed variable is never null
The variable 'maxStringBytes' is only assigned values of primitive type and
is never 'null', but it is declared with the boxed type 'Integer'.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6004)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]