gnodet-bot commented on code in PR #31010: URL: https://github.com/apache/camel/pull/31010#discussion_r4721635419
########## components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyConverters.java: ########## @@ -0,0 +1,57 @@ +/* + * 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.camel.component.iggy; + +import java.util.Locale; + +import org.apache.camel.Converter; +import org.apache.iggy.message.Partitioning; + +/** + * Converts the text of the partitioning option to the Iggy {@link Partitioning}. + */ +@Converter(generateLoader = true) +public final class IggyConverters { + + private static final String PARTITION_ID = "partitionid:"; + private static final String MESSAGES_KEY = "messageskey:"; + + private IggyConverters() { + // Utility Class + } + + /** + * Converts balanced, partitionId:<partition id> or messagesKey:<key> (the prefixes are not + * case-sensitive) to a {@link Partitioning}. + */ + @Converter + public static Partitioning toPartitioning(String text) { + String value = text.trim(); + String lower = value.toLowerCase(Locale.ROOT); + if (lower.equals("balanced")) { + return Partitioning.balanced(); + } + if (lower.startsWith(PARTITION_ID)) { + return Partitioning.partitionId(Long.valueOf(value.substring(PARTITION_ID.length()).trim())); + } + if (lower.startsWith(MESSAGES_KEY)) { + return Partitioning.messagesKey(value.substring(MESSAGES_KEY.length())); Review Comment: 🐛 **Bug:** `messagesKey` branch does not call `.trim()` after `substring`, unlike the `partitionId` branch above. A header value like `"messagesKey: order-1"` (with a space after the colon) produces a key `" order-1"` (leading space included), silently routing to the wrong partition or creating a new key. ```suggestion return Partitioning.messagesKey(value.substring(MESSAGES_KEY.length()).trim()); ``` ########## components/camel-iggy/src/main/java/org/apache/camel/component/iggy/IggyConfiguration.java: ########## @@ -265,10 +272,15 @@ public void setPartitionId(Long partitionId) { this.partitionId = partitionId; } + @Deprecated(since = "4.24.0") public int getConsumersCount() { return consumersCount; Review Comment: 💡 **Nit:** `getConsumersCount()` has `@Deprecated(since = "4.24.0")` but no Javadoc `@deprecated` tag, while `setConsumersCount()` has both. Add the Javadoc block to keep the pair consistent — IDEs and Javadoc renderers surface the `@deprecated` prose to callers: ```suggestion /** * @deprecated the consumer polls the topic with one task, so a value above 1 only adds idle threads */ @Deprecated(since = "4.24.0") public int getConsumersCount() { ``` -- 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]
