ImmutableContext and ImmutableStructure truncate Instant values to milliseconds

Đang mở Phù hợp với người mới
#2,070 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@RaphaelFakhri đang làm issue này rồi.

Từ ngày 4/11/2026.

  • #2071 của @RaphaelFakhri — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu bằng cách đọc Value.clone() và các đường dẫn khởi tạo, đọc của ImmutableStructure được mô tả trong issue. Kiểm tra ImmutableStructureTest.MutatingGetInstantValueShouldNotChangeOriginalValue, hiện đang cắt ngắn đầu vào đến độ chính xác mili giây. Công việc được xem là hoàn tất khi một instant có độ chính xác dưới mili giây được trả về nguyên vẹn qua getValue(key).asInstant(), asMap() và asObjectMap().

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
129
Fork
62
Merge trung bình
6 giờ 37 phút
Pull request đã merge (30 ngày)
12

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của open-feature/java-sdk

Tất cả issue của open-feature/java-sdk

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.