`AbstractKeyValueAdapter` casts to the requested type before `KeyValueTemplate` can skip mismatching values
@mp911de đang làm issue này rồi.
Từ ngày 5/10/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Read AbstractKeyValueAdapter.get/delete and KeyValueTemplate.findById, then compare MapKeyValueAdapter with RedisKeyValueAdapter. Confirm the behavior through the findById, findAllById, and delete examples, and resolve whether delete should preserve mismatched entries before adding regression coverage.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When a keyspace is shared by a type hierarchy, findById(id, Subtype.class) throws instead of returning Optional.empty() if the stored value is a supertype instance. AbstractKeyValueAdapter.get(id, keyspace, type) calls type.cast(…) on the stored value, so the type check in KeyValueTemplate.findById(…) is never reached.
@KeySpace("persons")
class Person {
@Id String id;
}
class Employee extends Person {}
KeyValueTemplate template = new KeyValueTemplate(new MapKeyValueAdapter());
template.insert("1", new Person());
template.findAll(Employee.class); // []
template.findById("1", Employee.class); // UncategorizedKeyValueException caused by ClassCastException
delete(id, keyspace, type) uses the same cast. template.delete("1", Employee.class) removes the Person entry and then throws, so the caller sees a failure although the entry is gone, and no AfterDeleteEvent is published.
Reproduced with MapKeyValueAdapter on main. Before DATAKV-187 the adapter used an unchecked (T) cast, so the mismatching value reached the type check in KeyValueTemplate.findById(…); the switch to type.cast(…) made it throw.
For get(…), returning null when the value is not an instance of the requested type would make findById(…) consistent with findAll(…).
For delete(…), should an entry whose value is not of the requested type be left in place, or is removing it and then throwing acceptable? For reference, RedisKeyValueAdapter.delete(…) calls the typed get(…) first and removes the entry only if that returns a value.
findAllById(…) from #696 goes through the same typed get(…) and currently behaves like findById(…).
- Ngôn ngữ chính
- Java
- Star
- 157
- Fork
- 85
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- 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-data-keyvalue
-
Release 4.2.0-RC1 (2026.1.0)Đang mởtype: task
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
-
Release 4.0.8 (2025.1.8)Đang mởtype: task
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
-
Release 4.1.2 (2026.0.2)Đang mởtype: task
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
-
type: task
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
-
type: enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
spring-projects/spring-data-keyvalue#688 · 1 bình luận ·
Tất cả issue của spring-projects/spring-data-keyvalue
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
portfolio-performance/portfolio#6119 ·
Maintainer thường phản hồi trong vòng 8 ngày
-
Bump up AWS SDK to 2.54.3Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jenkinsci/ec2-plugin#2041 ·
-
L: github:actions L: php:composer
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
dependabot/dependabot-core#16493 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
SHOW EDIT of a subclass for an object of its superclass: the form fails to open with AssertionErrorĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100