Why does this line cause a NullPointerException:
List<Foo> foos = new ArrayList<Foo>(userDetailsService.getFoos(currentUser));
The getFoos method simply returns a Collection of Foos:
public Collection<Foo> getFoos(final String username)
I can’t tell if the NullPointerException refers to getFoos returning null or some problem with the cast from a Collection to an ArrayList.
Depends on the stacktrace. Head to the first line. If it points to
java.util.ArrayList.<init>, thengetFoos()has returnednull. Or if it points to the particular line in your question, thenuserDetailsServiceisnull.