`YamlProcessor.getFlattenedMap` with `includeEmpty` returns a `null` key for an empty root mapping
Maintainer thường phản hồi trong vòng 1 ngày
@erfannvb đang làm issue này rồi.
Từ ngày 20/10/2026.
Đá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
- 78/100
Hướng nghiên cứu
Issue xác định YamlProcessor.getFlattenedMap và buildFlattenedMap, cùng với một trường hợp tái hiện cho mapping YAML gốc rỗng. Hãy đọc các phương thức đó và theo dõi cách đường dẫn gốc được xử lý khi includeEmpty là true; bài kiểm thử được cung cấp cho thấy kết quả mong đợi. Hoàn thành khi làm phẳng {} tạo ra một map rỗng không có khóa null, trong khi hành vi hiện có với các đầu vào khác vẫn được giữ nguyên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When getFlattenedMap(source, true, emptyValue) (added in 7.0.4 by #36197) is given an empty root map, such as a YAML document consisting of {}, it returns {null=emptyValue}. buildFlattenedMap stores an empty map under its parent path, and at the root that path is null.
class YamlProcessorEmptyRootTest {
@Test
void flattenedMapOfEmptyRootMappingHasNoNullKey() {
List<Map<String, Object>> result = new FlatteningYamlProcessor("{}").flatten();
assertThat(result).hasSize(1);
assertThat(result.get(0)).doesNotContainKey(null);
}
static class FlatteningYamlProcessor extends YamlProcessor {
FlatteningYamlProcessor(String yaml) {
setResources(new ByteArrayResource(yaml.getBytes()));
}
List<Map<String, Object>> flatten() {
List<Map<String, Object>> result = new ArrayList<>();
process((properties, map) -> result.add(getFlattenedMap(map, true, "")));
return result;
}
}
}
On 7.0.9 this fails with {null=""}. getFlattenedMap(map) returns {} for the same input.
The return type is Map<String, Object> in a @NullMarked package, so callers don't expect a null key. I'd expect an empty map: the root has no key under which the empty entry could be recorded.
This affects Spring Boot 4.1, whose OriginTrackedYamlLoader uses this method since spring-projects/spring-boot#48958. A {} document in an application.yml now gives an EnumerablePropertySource whose getPropertyNames() returns [null] (4.0.x returned []).
- Ngôn ngữ chính
- Java
- Star
- 60.3k
- Fork
- 38.7k
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 38
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 spring-projects/spring-framework
-
`WebClient` with default codecs drops `ProblemDetail` extension membersCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởstatus: waiting-for-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
spring-projects/spring-framework#37503 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
StandardApiVersionDeprecationHandler generates nonconforming Sunset HTTP datesCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởstatus: waiting-for-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
spring-projects/spring-framework#37486 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
FastByteArrayOutputStream input stream rejects valid skip(long) argumentsCó thể làm lại được @hickey-ai đã nhận 13 ngày trước và không có pull request nào đang mở. Đang mởstatus: waiting-for-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
spring-projects/spring-framework#37471 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
LinkedCaseInsensitiveMap.keySet().remove returns false after removing a null-valued entryCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởstatus: waiting-for-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
spring-projects/spring-framework#37470 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ServerSentEventHttpMessageReader does not recognize data fields without a colonCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởin: web status: waiting-for-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
spring-projects/spring-framework#37461 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của spring-projects/spring-framework
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
aws/context-ontology-accelerator#325 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
The README tells to run `mvn jeo:disassemble`, which fails with `No plugin found for prefix 'jeo'`Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
objectionary/jeo-maven-plugin#1938 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
oVirt/ovirt-engine#1219 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
pending:code-area pending:issue-category to-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:core bug priority:p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
aomarai/minecraft-mcp#247 ·
Maintainer thường phản hồi trong vòng 1 ngày