diff --git a/src/main/java/org/takes/facets/auth/PsBasic.java b/src/main/java/org/takes/facets/auth/PsBasic.java index 9b87e3e46..7677b63e2 100644 --- a/src/main/java/org/takes/facets/auth/PsBasic.java +++ b/src/main/java/org/takes/facets/auth/PsBasic.java @@ -54,6 +54,8 @@ * * @since 0.20 * @checkstyle ClassDataAbstractionCouplingCheck (100 lines) + * @todo #863:30min Continue removing nulls from the code base, there are still + * some places that use it and can be replaced with better code constructs. */ @EqualsAndHashCode @SuppressWarnings("PMD.TooManyMethods") diff --git a/src/main/java/org/takes/facets/auth/social/PsGoogle.java b/src/main/java/org/takes/facets/auth/social/PsGoogle.java index eb509c84a..c06e6c31a 100644 --- a/src/main/java/org/takes/facets/auth/social/PsGoogle.java +++ b/src/main/java/org/takes/facets/auth/social/PsGoogle.java @@ -224,11 +224,13 @@ private String token(final String code) throws IOException { */ private static Identity parse(final JsonObject json) { final Map props = new HashMap<>(json.size()); - final JsonObject image = json.getJsonObject("image"); - if (image == null) { - props.put(PsGoogle.PICTURE, "#"); + final Opt image = new Opt.Single<>( + json.getJsonObject("image") + ); + if (image.has()) { + props.put(PsGoogle.PICTURE, image.get().getString("url", "#")); } else { - props.put(PsGoogle.PICTURE, image.getString("url", "#")); + props.put(PsGoogle.PICTURE, "#"); } props.put( PsGoogle.NAME, json.getString(PsGoogle.DISPLAY_NAME, "unknown") diff --git a/src/main/java/org/takes/facets/cookies/RqCookies.java b/src/main/java/org/takes/facets/cookies/RqCookies.java index d3a1e94f4..7f490f3b3 100644 --- a/src/main/java/org/takes/facets/cookies/RqCookies.java +++ b/src/main/java/org/takes/facets/cookies/RqCookies.java @@ -77,11 +77,12 @@ public Base(final Request req) { public Iterable cookie(final CharSequence key) throws IOException { final Map map = this.map(); - final String value = map.get( - new EnglishLowerCase(key.toString()).string() + final String value = map.getOrDefault( + new EnglishLowerCase(key.toString()).string(), + "" ); final Iterable iter; - if (value == null) { + if (value.isEmpty()) { iter = new VerboseIterable<>( Collections.emptyList(), new Sprintf( diff --git a/src/main/java/org/takes/facets/fork/FkHitRefresh.java b/src/main/java/org/takes/facets/fork/FkHitRefresh.java index 6cd1dd303..2cc122949 100644 --- a/src/main/java/org/takes/facets/fork/FkHitRefresh.java +++ b/src/main/java/org/takes/facets/fork/FkHitRefresh.java @@ -46,8 +46,6 @@ * * @since 0.9 * @see TkFork - * @todo #863:30min Continue removing nulls from the code base, there are still - * some places that use it and can be replaced with better code constructs. */ @EqualsAndHashCode public final class FkHitRefresh implements Fork { @@ -86,14 +84,11 @@ public FkHitRefresh(final File file, final List cmd, final Take tke) { this( file, - new Runnable() { - @Override - public void run() { - try { - new ProcessBuilder().command(cmd).start(); - } catch (final IOException ex) { - throw new IllegalStateException(ex); - } + () -> { + try { + new ProcessBuilder().command(cmd).start(); + } catch (final IOException ex) { + throw new IllegalStateException(ex); } }, tke @@ -234,10 +229,6 @@ private boolean expired() throws IOException { /** * Directory contents updated? * @return TRUE if contents were updated - * @todo #802:30min Continue removing nulls from the codebase, - * which still exist in the code. The way it is violates - * the key principles, defined in the README.md file and should be - * deleted. */ private boolean directoryUpdated() { final long recent;