diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-09-18 10:32:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-18 10:32:36 +0200 |
commit | 056c5b8ba2bed5287b18ed58dd8e2bc72c4505e5 (patch) | |
tree | 0605841ad5968195d3ee4af52854b4ecbea2121e /document | |
parent | eb05c7a5b60ccf448b59038d7416c67f6aa68958 (diff) |
Revert "Avoid NPE on non-exiting field"
Diffstat (limited to 'document')
-rw-r--r-- | document/src/main/java/com/yahoo/document/DocumentUpdate.java | 6 | ||||
-rw-r--r-- | document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java | 4 |
2 files changed, 3 insertions, 7 deletions
diff --git a/document/src/main/java/com/yahoo/document/DocumentUpdate.java b/document/src/main/java/com/yahoo/document/DocumentUpdate.java index 028215c0d6c..301d6af0f54 100644 --- a/document/src/main/java/com/yahoo/document/DocumentUpdate.java +++ b/document/src/main/java/com/yahoo/document/DocumentUpdate.java @@ -278,8 +278,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP * @return the update for the field, or null if that field has no update in this */ public FieldUpdate getFieldUpdate(String fieldName) { - Field field = documentType.getField(fieldName); - return field != null ? getFieldUpdate(field) : null; + return getFieldUpdate(documentType.getField(fieldName)); } private FieldUpdate getFieldUpdateById(Integer fieldId) { return id2FieldUpdateMap.get(fieldId); @@ -397,8 +396,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP } public FieldUpdate removeFieldUpdate(String fieldName) { - Field field = documentType.getField(fieldName); - return field != null ? removeFieldUpdate(field) : null; + return removeFieldUpdate(documentType.getField(fieldName)); } /** diff --git a/document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java b/document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java index a9f77cb5eb0..53f68ca182c 100644 --- a/document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java +++ b/document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java @@ -442,7 +442,7 @@ public class DocumentUpdateTestCase { } @Test - public void testGetAndRemoveByName() { + public void testgetAndRemoveByName() { DocumentType docType = new DocumentType("my_type"); Field my_int = new Field("my_int", DataType.INT); Field your_int = new Field("your_int", DataType.INT); @@ -451,8 +451,6 @@ public class DocumentUpdateTestCase { DocumentUpdate update = new DocumentUpdate(docType, new DocumentId("doc:this:is:a:test")); update.addFieldUpdate(FieldUpdate.createAssign(my_int, new IntegerFieldValue(2))); - assertNull(update.getFieldUpdate("none-existing-field")); - assertNull(update.removeFieldUpdate("none-existing-field")); assertNull(update.getFieldUpdate("your_int")); assertEquals(new IntegerFieldValue(2), update.getFieldUpdate("my_int").getValueUpdate(0).getValue()); assertNull(update.removeFieldUpdate("your_int")); |