DateTimeFormatter is used in static context, but not thread safe
- 主要言語
- Java
- スター
- 3.1k
- フォーク
- 1.6k
- 平均マージ
- 3日 12時間
- マージ済み PR(30日)
- 33
説明
DateTimeFormatter is used in static context but not thread safe, a formatter instance is created in PrimitiveStringifer.DateStringifier, and DateStringifier is created in static final DATE_STRINGIFIER, TIMESTAMP_MILLIS_STRINGIFIER, TIMESTAMP_MICROS_STRINGIFIER, TIMESTAMP_NANOS_STRINGIFIER, TIMESTAMP_MILLIS_UTC_STRINGIFIER, TIMESTAMP_MICROS_UTC_STRINGIFIER, and TIMESTAMP_NANOS_UTC_STRINGIFIER.
This causes exceptions like the following to be thrown from parquet-code:
java.lang.ArrayIndexOutOfBoundsException: Index 633 out of bounds for length 13
stacktrace:
at java.base/sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(BaseCalendar.java:457)
at java.base/java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2358)
at java.base/java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2273)
at java.base/java.util.Calendar.setTimeInMillis(Calendar.java:1827)
at java.base/java.util.Calendar.setTime(Calendar.java:1793)
at java.base/java.text.SimpleDateFormat.format(SimpleDateFormat.java:978)
at java.base/java.text.SimpleDateFormat.format(SimpleDateFormat.java:971)
at java.base/java.text.DateFormat.format(DateFormat.java:339)
at java.base/java.text.Format.format(Format.java:159)
at org.apache.parquet.schema.PrimitiveStringifier$DateStringifier.toFormattedString(PrimitiveStringifier.java:265)
at org.apache.parquet.schema.PrimitiveStringifier$DateStringifier.stringify(PrimitiveStringifier.java:256)
at org.apache.parquet.column.statistics.IntStatistics.stringify(IntStatistics.java:92)
at org.apache.parquet.column.statistics.IntStatistics.stringify(IntStatistics.java:25)
at org.apache.parquet.column.statistics.Statistics.minAsString(Statistics.java:423)
(... unrelated code)
A simple solution would be to change those from static to non static values.
I can create a PR if the solution is ok by the maintainers of the library.
**Environment**: Linux, OpenJDK 17 (based on docker image openjdk:17-slim)
**Reporter**: [Shani Elharrar](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=shani.elha)
**Note**: *This issue was originally created as [PARQUET-2240](https://issues.apache.org/jira/browse/PARQUET-2240). Please see the [migration documentation](https://issues.apache.org/jira/browse/PARQUET-2502) for further details.*
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
PrimitiveStringifier.DateStringifier から始め、特にスタックトレースに示されている toFormattedString と stringify のパスを確認し、issue で名前が挙げられている 7 つの static stringifier instance を調査してください。並行フォーマット時に失敗することを確認し、共有利用で報告された例外が発生しなくなったことをプロジェクトの関連テストで確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- data-engineering
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100