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

fanningpj pushed a commit to branch pjfanning-patch-2
in repository https://gitbox.apache.org/repos/asf/drill.git

commit 99bbde8c7f675305b7fccfe4779fe1f9153c7eff
Author: PJ Fanning <[email protected]>
AuthorDate: Sun Oct 27 00:03:32 2024 +0100

    Fix DateFormat in DateGen.java
---
 .../main/java/org/apache/drill/exec/store/mock/DateGen.java   | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/DateGen.java 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/DateGen.java
index cc5b63aad6..47c3990300 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/DateGen.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/DateGen.java
@@ -44,13 +44,16 @@ public class DateGen extends AbstractFieldGen {
   public DateGen() {
     // Start a year ago.
     baseTime = System.currentTimeMillis() - ONE_YEAR;
-    fmt = new SimpleDateFormat("yyyy-mm-DD");
+    fmt = new SimpleDateFormat("yyyy-MM-dd");
   }
 
   @Override
   public void setValue() {
-    long randTime = baseTime + baseTime + rand.nextInt(365) * ONE_DAY;
-    String str = fmt.format(new Date(randTime));
-    colWriter.setString(str);
+    final long randTime = baseTime + baseTime + rand.nextInt(365) * ONE_DAY;
+    final Date date = new Date(randTime);
+    // SimpleDateFormat is not thread safe
+    synchronized(fmt) {
+      colWriter.setString(fmt.format(date));
+    }
   }
 }

Reply via email to