Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`AbstractKeyValueAdapter` casts to the requested type before `KeyValueTemplate` can skip mismatching values

Đang mở
#697 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

@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
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
databases

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ả

type: bug

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

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 spring-projects/spring-data-keyvalue

Tất cả issue của spring-projects/spring-data-keyvalue

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.