ImmutableContext and ImmutableStructure truncate Instant values to milliseconds

未关闭 适合新手
#2,070 0 条评论 0 个 reaction 已指派 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 分钟
30 天内合并 PR
12

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

open-feature/java-sdk 的其他 Issue

查看 open-feature/java-sdk 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。