diff --git a/gson/src/main/java/com/google/gson/internal/Excluder.java b/gson/src/main/java/com/google/gson/internal/Excluder.java index 3744a306c1..14ecd60fbe 100644 --- a/gson/src/main/java/com/google/gson/internal/Excluder.java +++ b/gson/src/main/java/com/google/gson/internal/Excluder.java @@ -147,7 +147,10 @@ private TypeAdapter delegate() { // A race might lead to `delegate` being assigned by multiple threads but the last // assignment will stick TypeAdapter d = delegate; - return d != null ? d : (delegate = gson.getDelegateAdapter(Excluder.this, type)); + if (d == null) { + d = delegate = gson.getDelegateAdapter(Excluder.this, type); + } + return d; } }; }