I have method that returns `Map<String, String&...
# spring
t
I have method that returns
Map<String, String>?
. This method is in a Custom Implementation for Spring Data Repositories (exactly as described here: https://docs.spring.io/spring-data/jpa/docs/2.1.6.RELEASE/reference/html/#repositories.custom-implementations). My problem: when I
return urlRequestResult?.value as Map<String, String>?
(using restTemplate to do the request here) it returns an
empty LinkedHashMap
, but if I evaluate it in debug mode it returns
null
(as I was expecting when
urlRequestResult
is null) Is it a bug or am I doing something wrong here?
s
time to employ println() 😎 I suggested putting a line of
println(urlRequestResult)
just before the return statement. I expect urlRequestResult to be non-null with an empty map in value (while not in debug). nullvalues normally don’t generate emty maps (or anything really)
t
Sorry, last week was crazy 🤪 So… I debugged and my method actually returns
null
, but spring transforms it to
LinkedHashMap
when receives it. I couldn’t debug more to find where it’s happening, I’ll try later this week. Another test I’ve made is to put this method in the same class of the invoker (Service Layer) and the method returned
null
as expected (the same body method)