Improperly implemented UserDetailsService

Report a typo

The code below is an implementation of UserDetailsService. Your task is to study the code and find a mistake.

Java
@Service
public class UserDetailsServiceImpl implements UserDetailsService {
    @Autowired
    UserRepository userRepo;

    @Override
    public AppUser loadUserByUsername(String username) throws UsernameNotFoundException {
        AppUser user = userRepo.findUserByUsername(username);

        if (user == null) {
            throw new UsernameNotFoundException("Not found: " + username);
        }

        return user;
    }
}
Kotlin
@Service
class UserDetailsServiceImpl(
    val userRepo: UserRepository
) : UserDetailsService {

    override fun loadUserByUsername(username: String): AppUser {
        return userRepo.findUserByUsername(username) ?: throw UsernameNotFoundException("Not found: $username")
    }
}

The AppUser class doesn't implement any interface.

Select one option from the list
___

Create a free account to access the full topic