From 09ac4230e990ae8b51469c794293f94824abd927 Mon Sep 17 00:00:00 2001 From: Yoann Fleury Date: Mon, 3 Jul 2017 11:29:55 +0200 Subject: [PATCH] Avoid NullPointerException on opType equals Put the equals on String to avoid NullPointerException and to get the PatchException message that explains a little better the issue. --- .../sync/json/JsonPatchPatchConverter.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-sync-core/src/main/java/org/springframework/sync/json/JsonPatchPatchConverter.java b/spring-sync-core/src/main/java/org/springframework/sync/json/JsonPatchPatchConverter.java index bea30bd..580ada0 100644 --- a/spring-sync-core/src/main/java/org/springframework/sync/json/JsonPatchPatchConverter.java +++ b/spring-sync-core/src/main/java/org/springframework/sync/json/JsonPatchPatchConverter.java @@ -66,17 +66,17 @@ public Patch convert(JsonNode jsonNode) { Object value = valueFromJsonNode(path, valueNode); String from = opNode.has("from") ? opNode.get("from").textValue() : null; - if (opType.equals("test")) { + if ("test".equals(opType)) { ops.add(new TestOperation(path, value)); - } else if (opType.equals("replace")) { + } else if ("replace".equals(opType)) { ops.add(new ReplaceOperation(path, value)); - } else if (opType.equals("remove")) { + } else if ("remove".equals(opType)) { ops.add(new RemoveOperation(path)); - } else if (opType.equals("add")) { + } else if ("add".equals(opType)) { ops.add(new AddOperation(path, value)); - } else if (opType.equals("copy")) { + } else if ("copy".equals(opType)) { ops.add(new CopyOperation(path, from)); - } else if (opType.equals("move")) { + } else if ("move".equals(opType)) { ops.add(new MoveOperation(path, from)); } else { throw new PatchException("Unrecognized operation type: " + opType);