This is an automated email from the ASF dual-hosted git repository.
cgivre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git
The following commit(s) were added to refs/heads/master by this push:
new d5358d6449 Fix DateFormat in DateGen.java (#2959)
d5358d6449 is described below
commit d5358d64499ad83f941349879c6f88fa85c490f2
Author: PJ Fanning <[email protected]>
AuthorDate: Thu Mar 13 15:12:13 2025 +0100
Fix DateFormat in DateGen.java (#2959)
---
.../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..248696655a 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 + rand.nextInt(365) * ONE_DAY;
+ final Date date = new Date(randTime);
+ // SimpleDateFormat is not thread safe
+ synchronized(fmt) {
+ colWriter.setString(fmt.format(date));
+ }
}
}