Java 8 cyclic inference warning

Your current code returns a Stream<String>, so you need an extra step to return a string:

Optional<String> auth = cookies.stream()
            .filter(c -> c.getName().equals("auth"))
            .map(Cookie::getValue)
            .findAny();

Note that it returns an Optional<String> because there may be no Cookie that matches “auth”. If you want to use a default if “auth” is not found you can use:

String auth = cookies.stream()
            .filter(c -> c.getName().equals("auth"))
            .map(Cookie::getValue)
            .findAny().orElse("");

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)