Skip to content

Commit 4ea9405

Browse files
OsaSoftmp911de
authored andcommitted
Fix NPE in CrudRepositoryExtensions.
Closes #3187
1 parent b4d2391 commit 4ea9405

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/kotlin/org/springframework/data/repository/CrudRepositoryExtensions.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ package org.springframework.data.repository
1919
* Retrieves an entity by its id.
2020
*
2121
* @param id the entity id.
22-
* @return the entity with the given id or `null` if none found
22+
* @return the entity with the given id or `null` if none found.
2323
* @author Sebastien Deleuze
24+
* @author Oscar Hernandez
2425
* @since 2.1.4
2526
*/
26-
fun <T, ID> CrudRepository<T, ID>.findByIdOrNull(id: ID): T? = findById(id!!).orElse(null)
27+
fun <T, ID: Any> CrudRepository<T, ID>.findByIdOrNull(id: ID): T? = findById(id).orElse(null)

0 commit comments

Comments
 (0)