ableegoldman commented on a change in pull request #10512:
URL: https://github.com/apache/kafka/pull/10512#discussion_r610944206
##########
File path: docs/upgrade.html
##########
@@ -49,8 +49,10 @@ <h5><a id="upgrade_300_notable"
href="#upgrade_300_notable">Notable changes in 3
were removed. These methods were not intended to be public API and
there is no replacement.</li>
<li>The <code>NoOffsetForPartitionException.partition()</code> method
was removed. Please use <code>partitions()</code>
instead.</li>
- <li>The Scala <code>kafka.common.MessageFormatter</code> was removed.
Plese use the Java <code>org.apache.kafka.common.MessageFormatter</code>.</li>
+ <li>The Scala <code>kafka.common.MessageFormatter</code> was removed.
Please use the Java <code>org.apache.kafka.common.MessageFormatter</code>.</li>
<li>The <code>MessageFormatter.init(Properties)</code> method was
removed. Please use <code>configure(Map)</code> instead.</li>
+ <li>The deprecated
<code>org.apache.kafka.clients.consumer.internals.PartitionAssignor</code> and
related classes have been removed. Please use
Review comment:
```suggestion
<li>The deprecated
<code>org.apache.kafka.clients.consumer.internals.PartitionAssignor</code>
class has been removed. Please use
```
See my reply on the original comment 🙂
##########
File path:
clients/src/test/java/org/apache/kafka/clients/consumer/ConsumerPartitionAssignorTest.java
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.clients.consumer;
+
+
+import org.apache.kafka.common.KafkaException;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+
+import static
org.apache.kafka.clients.consumer.ConsumerPartitionAssignor.getAssignorInstances;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class ConsumerPartitionAssignorTest {
+
+ private List<String> classNames;
+ private List<Object> classTypes;
+
+ @Test
+ public void shouldInstantiateAssignor() {
+ classNames = Collections.singletonList(StickyAssignor.class.getName());
+ List<ConsumerPartitionAssignor> assignors =
getAssignorInstances(classNames, Collections.emptyMap());
+ assertTrue(assignors.get(0) instanceof StickyAssignor);
+ }
+
+ @Test
+ public void shouldInstantiateListOfAssignors() {
+ classNames = Arrays.asList(StickyAssignor.class.getName(),
CooperativeStickyAssignor.class.getName());
+ List<ConsumerPartitionAssignor> assignors =
getAssignorInstances(classNames, Collections.emptyMap());
+ assertTrue(assignors.get(0) instanceof StickyAssignor);
+ }
+
+ @Test
+ public void shouldThrowKafkaExceptionOnNonAssignor() {
+ classNames = Collections.singletonList(String.class.getName());
+ assertThrows(KafkaException.class, () ->
getAssignorInstances(classNames, Collections.emptyMap()));
+ }
+
+ @Test
+ public void shouldThrowKafkaExceptionOnAssignorNotFound() {
+ classNames = Collections.singletonList("Non-existent assignor");
+ assertThrows(KafkaException.class, () ->
getAssignorInstances(classNames, Collections.emptyMap()));
+ }
+
+ @Test
+ public void shouldInstantiateFromClassType() {
Review comment:
I think it would make sense to style this test (and
`shouldInstantiateFromListOfClassTypes` below) more like
`shouldInstantiateAssignors` now, ie where we actually validate the assignors
that are returned (eg `assertTrue(assignors.get(0) instanceof
StickyAssignor)`). Previously this test was just making sure that we adaptor
would work and we wouldn't throw an exception when constructing the consumer,
that's why it's like this
##########
File path:
clients/src/test/java/org/apache/kafka/clients/consumer/ConsumerPartitionAssignorTest.java
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.clients.consumer;
+
+
+import org.apache.kafka.common.KafkaException;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+
+import static
org.apache.kafka.clients.consumer.ConsumerPartitionAssignor.getAssignorInstances;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class ConsumerPartitionAssignorTest {
+
+ private List<String> classNames;
+ private List<Object> classTypes;
+
+ @Test
+ public void shouldInstantiateAssignor() {
+ classNames = Collections.singletonList(StickyAssignor.class.getName());
+ List<ConsumerPartitionAssignor> assignors =
getAssignorInstances(classNames, Collections.emptyMap());
+ assertTrue(assignors.get(0) instanceof StickyAssignor);
+ }
+
+ @Test
+ public void shouldInstantiateListOfAssignors() {
+ classNames = Arrays.asList(StickyAssignor.class.getName(),
CooperativeStickyAssignor.class.getName());
+ List<ConsumerPartitionAssignor> assignors =
getAssignorInstances(classNames, Collections.emptyMap());
+ assertTrue(assignors.get(0) instanceof StickyAssignor);
Review comment:
we should do this `assertTrue` thing for the CooperativeStickyAssignor
as well
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]