You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by sc...@apache.org on 2025/09/15 17:26:54 UTC
(kafka) branch trunk updated: MINOR: Fix an off-by-one issue in ValuesTest (#20520)
This is an automated email from the ASF dual-hosted git repository.
schofielaj pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 3fcc0c28779 MINOR: Fix an off-by-one issue in ValuesTest (#20520)
3fcc0c28779 is described below
commit 3fcc0c287795c6a591216617e0d5a02bd6fdbfc3
Author: Alex <we...@gmail.com>
AuthorDate: Tue Sep 16 01:26:47 2025 +0800
MINOR: Fix an off-by-one issue in ValuesTest (#20520)
This test case ensures that the parser can convert ISO8601 correctly.
However, when the local time falls on a different day than the UTC time,
there will be an off-by-one issue.
I changed the test to convert the local time and then compare it with
the expected local time. This should fix the off-by-one issue.
[Reference
link](https://github.com/apache/kafka/pull/18611#discussion_r2318146619)
Reviewers: Andrew Schofield <as...@confluent.io>
---------
Signed-off-by: Alex <we...@gmail.com>
---
.../api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java b/connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java
index 6be0b4a3772..d100be29b4d 100644
--- a/connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java
+++ b/connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java
@@ -30,7 +30,6 @@ import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.time.Instant;
-import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
@@ -903,7 +902,7 @@ public class ValuesTest {
// ISO8601 strings - accept a string matching pattern "yyyy-MM-dd"
LocalDateTime localTimeTruncated = localTime.truncatedTo(ChronoUnit.DAYS);
- java.util.Date d3 = Values.convertToDate(Date.SCHEMA, LocalDate.ofEpochDay(days).format(DateTimeFormatter.ISO_LOCAL_DATE));
+ java.util.Date d3 = Values.convertToDate(Date.SCHEMA, localTime.format(DateTimeFormatter.ISO_LOCAL_DATE));
LocalDateTime date3 = LocalDateTime.ofInstant(Instant.ofEpochMilli(d3.getTime()), ZoneId.systemDefault());
assertEquals(localTimeTruncated, date3);