This is an automated email from the ASF dual-hosted git repository.

ppkarwasz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/logging-flume.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 278e4f2d7 Fix `TestRegexExtractorInterceptor*` (#436)
278e4f2d7 is described below

commit 278e4f2d7aaa055a01288c99f23e4bc0ddc0d8f7
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Fri May 29 19:11:47 2026 +0200

    Fix `TestRegexExtractorInterceptor*` (#436)
    
    While #431 migrated `RegexExtractorInterceptorMillisSerializer` correctly 
from Joda to Java time, it introduced a small bug in the tests, which assume 
that all dates are in `UTC`.
    
    The original extractor interpreted them instead in the local timezone.
---
 .../org/apache/flume/interceptor/TestRegexExtractorInterceptor.java   | 4 ++--
 .../interceptor/TestRegexExtractorInterceptorMillisSerializer.java    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/flume-ng-core/src/test/java/org/apache/flume/interceptor/TestRegexExtractorInterceptor.java
 
b/flume-ng-core/src/test/java/org/apache/flume/interceptor/TestRegexExtractorInterceptor.java
index 87032cefd..0b87c0b11 100644
--- 
a/flume-ng-core/src/test/java/org/apache/flume/interceptor/TestRegexExtractorInterceptor.java
+++ 
b/flume-ng-core/src/test/java/org/apache/flume/interceptor/TestRegexExtractorInterceptor.java
@@ -20,6 +20,7 @@ package org.apache.flume.interceptor;
 import java.time.Instant;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
+import java.time.ZoneOffset;
 import java.time.format.DateTimeFormatter;
 
 import org.apache.flume.Context;
@@ -169,8 +170,7 @@ public class TestRegexExtractorInterceptor {
     long now = (System.currentTimeMillis() / 60000L) * 60000L;
     String pattern = "yyyy-MM-dd HH:mm:ss,SSS";
     DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
-    LocalDateTime current = Instant.ofEpochMilli(now).atOffset(UTC)
-            .toLocalDateTime();
+    LocalDateTime current = LocalDateTime.ofInstant(Instant.ofEpochMilli(now), 
ZoneId.systemDefault());
     String body = formatter.format(current);
     Context context = new Context();
     // Skip the second group
diff --git 
a/flume-ng-core/src/test/java/org/apache/flume/interceptor/TestRegexExtractorInterceptorMillisSerializer.java
 
b/flume-ng-core/src/test/java/org/apache/flume/interceptor/TestRegexExtractorInterceptorMillisSerializer.java
index 3d400e391..73e5aa2fa 100644
--- 
a/flume-ng-core/src/test/java/org/apache/flume/interceptor/TestRegexExtractorInterceptorMillisSerializer.java
+++ 
b/flume-ng-core/src/test/java/org/apache/flume/interceptor/TestRegexExtractorInterceptorMillisSerializer.java
@@ -22,6 +22,7 @@ import org.apache.flume.Context;
 
 import java.time.Instant;
 import java.time.LocalDateTime;
+import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import org.junit.Test;
 
@@ -66,8 +67,7 @@ public class TestRegexExtractorInterceptorMillisSerializer {
 
     DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
     long time = (System.currentTimeMillis() / 1000L) * 1000L;
-    LocalDateTime current = Instant.ofEpochMilli(time).atOffset(UTC)
-              .toLocalDateTime();
+    LocalDateTime current = 
LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault());
     Assert.assertEquals(String.valueOf(time),
         fixture.serialize(formatter.format(current)));
   }

Reply via email to