[Java][FlightSQL] JDBC driver returns pre-1970 dates one day late when a Calendar is supplied
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
Direzione di ricerca
Inizia da DateTimeUtils.getTimestampValue(long), quindi esamina ArrowFlightJdbcDateVectorAccessor.getDate(Calendar) e il test esistente per le date negative. Riproduci il caso 1950-06-01 01:00:00 UTC con un offset del calendario e verifica che i calcoli del giorno dell’epoca e dell’ora utilizzino limiti di giorno corrispondenti. Il lavoro è completato quando le date precedenti al 1970 con calendari forniti restituiscono la data corretta e il test di regressione passa.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug, including details regarding any error messages, version, and platform.
DateTimeUtils.getTimestampValue(long) splits epoch milliseconds into an epoch day and a time within that day. The old code used / and %:
public static Timestamp getTimestampValue(long millisWithCalendar) {
long milliseconds = millisWithCalendar;
if (milliseconds < 0) {
// LocalTime#ofNanoDay only accepts positive values
milliseconds -= ((milliseconds / MILLIS_PER_DAY) - 1) * MILLIS_PER_DAY;
}
return Timestamp.valueOf(
LocalDateTime.of(
LocalDate.ofEpochDay(millisWithCalendar / MILLIS_PER_DAY),
LocalTime.ofNanoOfDay(TimeUnit.MILLISECONDS.toNanos(milliseconds % MILLIS_PER_DAY))));
}
Both operators round toward zero. For dates before 1970, the code adjusted the negative remainder because LocalTime.ofNanoOfDay rejects it. It did not adjust the epoch day. When the input was negative and not exactly midnight, the day and remainder then referred to different days. The date came back one day late.
For example, -618102000000 ms is 1950-06-01 01:00:00 UTC. Division by 86400000 truncates to -7153, which is 1950-06-02. The remainder is 3600000 ms, or 01:00. The old result was 1950-06-02 01:00:00. Math.floorDiv returns -7154, the correct epoch day for 1950-06-01.
How this happens in JDBC
ArrowFlightJdbcDateVectorAccessor.getDate(Calendar) applies the calendar offset before calling this method. A DATE starts at midnight, but any difference between the supplied calendar zone and the JVM default moves it away from midnight. Passing a Calendar is the documented way to read a date in a specific zone. As a result, every pre-1970 date read this way came back one day late. Any non-zero offset can expose the bug. Historical offsets can include seconds, such as +05:53:28.
The existing negative test used -618105600000, exactly 1950-06-01 00:00:00 UTC. At midnight, truncating division and floor division agree, so that test could not expose the bug.
The fix uses Math.floorDiv and Math.floorMod for both parts and removes the manual adjustment. Positive values behave as before. A test now covers 1950-06-01 01:00:00 UTC.
This affects flight-sql-jdbc-core on main and in 19.0.0. It is platform independent. Issues #732 and #324 cover broader timestamp and time-zone behavior. This report is only about the integer-division bug above.
- Lingua principale
- Java
- Stelle
- 95
- Fork
- 154
- Merge medio
- 2g 10h
- PR unite (30g)
- 11
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/arrow-java
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
apache/arrow-java#1261 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/arrow-java#1236 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/arrow-java#1230 ·
-
Type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
apache/arrow-java#1205 ·
-
Type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
apache/arrow-java#1196 · 1 commento ·
Tutte le issue di apache/arrow-java
Issue simili
-
executions.Query — startDate and timeRange filters are sent with inverted comparison operators Apertaarea/plugin
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
kestra-io/plugin-kestra#190 ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
apache/rocketmq-dashboard#5064 ·