From 74beaa33289bffecbdad163c2860f60222dd3220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Osadnik?= Date: Wed, 15 Jan 2020 12:15:55 -0500 Subject: [PATCH] Handle issue in eq and neq when any of params is null (#552) Fixes regression made by 59bd121 Closes #551 We have observed that while evaluating neq or eq, the second param might be null. After #498 it started causing NullPointerException so I made a special check for that. Additionally, I allowed the first param to be nullable as well. --- .../java/com/swmansion/reanimated/nodes/OperatorNode.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java b/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java index fd66199a0cc..b9f154de08f 100644 --- a/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java +++ b/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java @@ -189,6 +189,9 @@ public boolean eval(Double x, Double y) { private static final Operator EQ = new CompOperator() { @Override public boolean eval(Double x, Double y) { + if (x == null || y == null) { + return x == y; + } return x.doubleValue() == y.doubleValue(); } }; @@ -213,6 +216,9 @@ public boolean eval(Double x, Double y) { private static final Operator NEQ = new CompOperator() { @Override public boolean eval(Double x, Double y) { + if (x == null || y == null) { + return x == y; + } return x.doubleValue() != y.doubleValue(); } };