ImmutableContext and ImmutableStructure truncate Instant values to milliseconds

オープン 初心者向け
#2,070 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@RaphaelFakhri がすでに取り組んでいます。

2026年11月4日 から。

  • #2071 @RaphaelFakhri による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
backend

調査の方向性

まず Value.clone() と、issue に記載されている ImmutableStructure の構築経路と読み取り経路を確認してください。現在、入力をミリ秒単位に切り捨てている ImmutableStructureTest.MutatingGetInstantValueShouldNotChangeOriginalValue を確認してください。ミリ秒未満の精度を持つ instant が、getValue(key).asInstant()、asMap()、asObjectMap() を通じて変更されずに返されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

An Instant stored in an ImmutableStructure or ImmutableContext loses its sub-millisecond precision. getValue(key).asInstant(), asMap() and asObjectMap() return an instant truncated to milliseconds, so the value read back is not equal to the value stored.

Value.clone() copies instants with Instant.ofEpochMilli(instant.toEpochMilli()), and ImmutableStructure clones every value on construction and on each read.

Expected behavior

The stored Instant is returned unchanged. Instant is immutable, so a copy is not needed.

Steps to reproduce

Instant instant = Instant.ofEpochSecond(1_700_000_000L, 123_456_789L);
EvaluationContext ctx = new ImmutableContext(Map.of("t", new Value(instant)));

System.out.println(instant);                          // 2023-11-14T22:13:20.123456789Z
System.out.println(ctx.getValue("t").asInstant());    // 2023-11-14T22:13:20.123Z

Instant.now() has microsecond or finer resolution on Java 9 and later, so contexts built from Instant.now() are affected in practice. The existing ImmutableStructureTest.MutatingGetInstantValueShouldNotChangeOriginalValue test calls truncatedTo(ChronoUnit.MILLIS) to avoid this.

主要言語
Java
スター
129
フォーク
62
平均マージ
6時間 37分
マージ済み PR(30日)
12

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

open-feature/java-sdk のほかの issue

open-feature/java-sdk の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。