Align VaporReference and ConcreteReference Nullability name() Formatting
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
Hướng nghiên cứu
Bắt đầu với ConcreteReference.name(), VaporReference.name() và JavaWriterVisitor.visit(VaporReference) trong module gapic-generator-java để lần theo nơi áp dụng định dạng nullable. Bổ sung độ bao phủ golden cho các lớp bên trong nullable và các kiểu generic, sau đó xác minh rằng tên của các tham chiếu lồng nhau được định dạng nhất quán.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Issue Details
There is a behavioral inconsistency in how JSpecify @Nullable annotations are prepended to class names between ConcreteReference and VaporReference in the gapic-generator-java AST. This technical debt is captured in the code via // TODO(miraleung): Give this behavioral parity with ConcreteReference.
ConcreteReference.name()manually and dynamically prepends@Nullableto the class name ifisNullable()is true:if (isNullable()) { sb.append("@Nullable"); sb.append(SPACE); } sb.append(simpleName());VaporReference.name()does not include this check in its name formation. Instead, nullability prepending forVaporReferencewas implemented purely inside the writer phase inJavaWriterVisitor.visit(VaporReference).
This inconsistency causes issues when reference names are dynamically constructed or compared (for example, when a VaporReference or ConcreteReference is nested as a generic parameter inside another reference, since the parent's build() method calls r.name() on its generics to build its own name string).
To unblock the initial JSpecify @Nullable PR, a temporary patch was applied to copy over the minimal behavior, but we need a clean, long-term alignment.
Proposed Follow-up Work:
- Add a dedicated golden test case capturing the behavior of nullable inner classes and generic types to ensure we prevent regressions.
- Refactor
VaporReferenceandConcreteReferenceto use a consistent representation of nullability formatting inname(). - Investigate if we can simplify
ConcreteReferenceby removing the manual string formatting inside the AST class entirely, centralizing the nullability formatting logic inside theJavaWriterVisitor.
Environment
- OS Type and Version: Linux
- Java Version and JDK Vendor: Java 11+
- Module:
sdk-platform-java/gapic-generator-java
Dependencies
com.google.api:gapic-generator-java
Reproducer
The issue can be reproduced by comparing the string returned by name() for a nullable VaporReference vs a nullable ConcreteReference:
// ConcreteReference name will contain "@Nullable"
ConcreteReference.builder()
.setClazz(String.class)
.setIsNullable(true)
.build()
.name(); // Returns "@Nullable String"
// VaporReference name will NOT contain "@Nullable"
VaporReference.builder()
.setName("MyClass")
.setPakkage("com.google")
.setIsNullable(true)
.build()
.name(); // Returns "MyClass"
This causes formatting differences when these references are nested inside collection types (e.g. List<@Nullable String> vs List<MyClass>).
- Ngôn ngữ chính
- Java
- Star
- 2.1k
- Fork
- 1.2k
- Merge trung bình
- 2 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 192
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/google-cloud-java
-
[java-core] Timestamp.of(java.sql.Timestamp) is one second late for a time less than a second before the epochCó thể đã có người làm @Vcode2407 đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
googleapis/google-cloud-java#14636 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[java-firestore] UserDataConverter encodes a pre-epoch Date with negative nanos, so the write is refusedCó thể đã có người làm @wu-hui đã nhận 23 ngày trước. Đang mởpriority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
googleapis/google-cloud-java#14635 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[java-firestore] UserDataConverter throws IndexOutOfBoundsException on an empty __binary__ valueCó thể đã có người làm @wu-hui đã nhận 23 ngày trước. Đang mởpriority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
googleapis/google-cloud-java#14634 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[java-firestore] CustomClassMapper.convertBigDecimal calls .abs() on Double, unintentionally flipping negative values to positiveCó thể làm lại được @wu-hui đã nhận 45 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
googleapis/google-cloud-java#14533 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Github CI failing when trying to install xmllintCó thể đã có người làm @blakeli0 đã nhận 81 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
googleapis/google-cloud-java#14132 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của googleapis/google-cloud-java
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 84/100
cpp-best-practices/project_validator#251 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend enhancement
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 70/100
damodharg6/payledger#16 ·
-
[Bug]: An initiative list with no current entry logs an error on every changeCó thể đã có người làm @dwizard0 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày