You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "sjhajharia (via GitHub)" <gi...@apache.org> on 2025/05/31 16:53:20 UTC
[PR] MINOR: Cleanup Connect Module (2/n) [kafka]
sjhajharia opened a new pull request, #19871:
URL: https://github.com/apache/kafka/pull/19871
Now that Kafka support Java 17, this PR makes some changes in connect module. The changes in this PR are limited to only some files. A future PR(s) shall follow.
The changes mostly include:
- Collections.emptyList(), Collections.singletonList() and Arrays.asList() are replaced with List.of()
- Collections.emptyMap() and Collections.singletonMap() are replaced with Map.of()
- Collections.singleton() is replaced with Set.of()
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Cleanup Connect Module (2/n) [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #19871:
URL: https://github.com/apache/kafka/pull/19871#issuecomment-2998675714
A label of 'needs-attention' was automatically added to this PR in order to raise the
attention of the committers. Once this issue has been triaged, the `triage` label
should be removed to prevent this automation from happening again.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Cleanup Connect Module (2/n) [kafka]
Posted by "sjhajharia (via GitHub)" <gi...@apache.org>.
sjhajharia commented on PR #19871:
URL: https://github.com/apache/kafka/pull/19871#issuecomment-3061304994
Hey @chia7712 @frankvicky
Given that you both reviewed the first PR in this series, could you pls take a look at this one too if possible.
Thanks in advance!
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Cleanup Connect Module (2/n) [kafka]
Posted by "sjhajharia (via GitHub)" <gi...@apache.org>.
sjhajharia commented on PR #19871:
URL: https://github.com/apache/kafka/pull/19871#issuecomment-3097320355
Hey @chia7712
The build is green. If you could pls go ahead and merge the same.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Cleanup Connect Module (2/n) [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #19871:
URL: https://github.com/apache/kafka/pull/19871#discussion_r2217862544
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:
##########
@@ -187,17 +185,12 @@ public Schema typeSchema(boolean isOptional) {
@Override
public Long toType(Config config, Date orig) {
Long unixTimeMillis = Timestamp.fromLogical(Timestamp.SCHEMA, orig);
Review Comment:
`Long` -> `long`
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Cleanup Connect Module (2/n) [kafka]
Posted by "sjhajharia (via GitHub)" <gi...@apache.org>.
sjhajharia commented on PR #19871:
URL: https://github.com/apache/kafka/pull/19871#issuecomment-3083995053
Gentle reminder @chia7712 @frankvicky
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Cleanup Connect Module (2/n) [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 merged PR #19871:
URL: https://github.com/apache/kafka/pull/19871
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Cleanup Connect Module (2/n) [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #19871:
URL: https://github.com/apache/kafka/pull/19871#issuecomment-3066499609
A label of 'needs-attention' was automatically added to this PR in order to raise the
attention of the committers. Once this issue has been triaged, the `triage` label
should be removed to prevent this automation from happening again.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Cleanup Connect Module (2/n) [kafka]
Posted by "sjhajharia (via GitHub)" <gi...@apache.org>.
sjhajharia commented on PR #19871:
URL: https://github.com/apache/kafka/pull/19871#issuecomment-3086776844
Thanks @chia7712
I have addressed the comments!
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Cleanup Connect Module (2/n) [kafka]
Posted by "sjhajharia (via GitHub)" <gi...@apache.org>.
sjhajharia commented on code in PR #19871:
URL: https://github.com/apache/kafka/pull/19871#discussion_r2217865581
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:
##########
@@ -187,17 +185,12 @@ public Schema typeSchema(boolean isOptional) {
@Override
public Long toType(Config config, Date orig) {
Long unixTimeMillis = Timestamp.fromLogical(Timestamp.SCHEMA, orig);
Review Comment:
Thank you
Fixed the same.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Cleanup Connect Module (2/n) [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #19871:
URL: https://github.com/apache/kafka/pull/19871#issuecomment-2953488861
A label of 'needs-attention' was automatically added to this PR in order to raise the
attention of the committers. Once this issue has been triaged, the `triage` label
should be removed to prevent this automation from happening again.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Cleanup Connect Module (2/n) [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #19871:
URL: https://github.com/apache/kafka/pull/19871#discussion_r2214031048
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/MaskField.java:
##########
@@ -65,32 +65,30 @@ public abstract class MaskField<R extends ConnectRecord<R>> implements Transform
private static final String PURPOSE = "mask fields";
- private static final Map<Class<?>, Function<String, ?>> REPLACEMENT_MAPPING_FUNC = new HashMap<>();
- private static final Map<Class<?>, Object> PRIMITIVE_VALUE_MAPPING = new HashMap<>();
-
- static {
- PRIMITIVE_VALUE_MAPPING.put(Boolean.class, Boolean.FALSE);
- PRIMITIVE_VALUE_MAPPING.put(Byte.class, (byte) 0);
- PRIMITIVE_VALUE_MAPPING.put(Short.class, (short) 0);
- PRIMITIVE_VALUE_MAPPING.put(Integer.class, 0);
- PRIMITIVE_VALUE_MAPPING.put(Long.class, 0L);
- PRIMITIVE_VALUE_MAPPING.put(Float.class, 0f);
- PRIMITIVE_VALUE_MAPPING.put(Double.class, 0d);
- PRIMITIVE_VALUE_MAPPING.put(BigInteger.class, BigInteger.ZERO);
- PRIMITIVE_VALUE_MAPPING.put(BigDecimal.class, BigDecimal.ZERO);
- PRIMITIVE_VALUE_MAPPING.put(Date.class, new Date(0));
- PRIMITIVE_VALUE_MAPPING.put(String.class, "");
-
- REPLACEMENT_MAPPING_FUNC.put(Byte.class, v -> Values.convertToByte(null, v));
- REPLACEMENT_MAPPING_FUNC.put(Short.class, v -> Values.convertToShort(null, v));
- REPLACEMENT_MAPPING_FUNC.put(Integer.class, v -> Values.convertToInteger(null, v));
- REPLACEMENT_MAPPING_FUNC.put(Long.class, v -> Values.convertToLong(null, v));
- REPLACEMENT_MAPPING_FUNC.put(Float.class, v -> Values.convertToFloat(null, v));
- REPLACEMENT_MAPPING_FUNC.put(Double.class, v -> Values.convertToDouble(null, v));
- REPLACEMENT_MAPPING_FUNC.put(String.class, Function.identity());
- REPLACEMENT_MAPPING_FUNC.put(BigDecimal.class, BigDecimal::new);
- REPLACEMENT_MAPPING_FUNC.put(BigInteger.class, BigInteger::new);
- }
+ private static final Map<Class<?>, Function<String, ?>> REPLACEMENT_MAPPING_FUNC = Map.ofEntries(
Review Comment:
```java
private static final Map<Class<?>, Function<String, ?>> REPLACEMENT_MAPPING_FUNC = Map.of(
Byte.class, v -> Values.convertToByte(null, v),
Short.class, v -> Values.convertToShort(null, v),
Integer.class, v -> Values.convertToInteger(null, v),
Long.class, v -> Values.convertToLong(null, v),
Float.class, v -> Values.convertToFloat(null, v),
Double.class, v -> Values.convertToDouble(null, v),
String.class, Function.identity(),
BigDecimal.class, BigDecimal::new,
BigInteger.class, BigInteger::new
);
```
##########
connect/transforms/src/test/java/org/apache/kafka/connect/transforms/MaskFieldTest.java:
##########
@@ -64,25 +61,25 @@ public class MaskFieldTest {
.field("map", SchemaBuilder.map(Schema.STRING_SCHEMA, Schema.STRING_SCHEMA))
.field("withDefault", SchemaBuilder.string().optional().defaultValue("default").build())
.build();
- private static final Map<String, Object> VALUES = new HashMap<>();
+ private static final Map<String, Object> VALUES = Map.ofEntries(
+ Map.entry("magic", 42),
+ Map.entry("bool", true),
+ Map.entry("byte", (byte) 42),
+ Map.entry("short", (short) 42),
+ Map.entry("int", 42),
+ Map.entry("long", 42L),
+ Map.entry("float", 42f),
+ Map.entry("double", 42d),
+ Map.entry("string", "55.121.20.20"),
+ Map.entry("date", new Date()),
+ Map.entry("bigint", new BigInteger("42")),
+ Map.entry("bigdec", new BigDecimal("42.0")),
+ Map.entry("list", List.of(42)),
+ Map.entry("map", Map.of("key", "value"))
+ );
private static final Struct VALUES_WITH_SCHEMA = new Struct(SCHEMA);
Review Comment:
Could you please rewrite it too?
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org