`AbstractKeyValueAdapter` casts to the requested type before `KeyValueTemplate` can skip mismatching values
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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(…).
- Lenguaje dominante
- Java
- Estrellas
- 157
- Forks
- 85
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de spring-projects/spring-data-keyvalue
-
Release 4.2.0-RC1 (2026.1.0)Abiertotype: task
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
-
Release 4.0.8 (2025.1.8)Abiertotype: task
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
-
Release 4.1.2 (2026.0.2)Abiertotype: task
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
-
type: task
Dificultad 4/5 3-5 días Aptitud para principiantes 20/100
-
type: enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
spring-projects/spring-data-keyvalue#688 · 1 comentario ·
Todos los issues de spring-projects/spring-data-keyvalue
Issues similares
-
[Bug] Logo style setting missing and `classic` style not applied across multiple platforms (v3.1.0)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Stirling-Tools/Stirling-PDF#8382 · 1 reacción ·
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
Los mantenedores suelen responder en 4 días
-
enhancement untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
opensearch-project/sql#5842 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
openhab/openhab-addons#21882 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
YunaiV/ruoyi-vue-pro#1273 ·
Los mantenedores suelen responder en 3 días