From 33ff7be18ae0482cdb695c171faf365c266a8373 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Wed, 3 Jul 2019 09:49:19 +0200 Subject: [PATCH] Fix NPE in StandardReconConfig. Closes #2076. --- .../refine/model/recon/StandardReconConfig.java | 2 +- .../tests/model/recon/StandardReconConfigTests.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/main/src/com/google/refine/model/recon/StandardReconConfig.java b/main/src/com/google/refine/model/recon/StandardReconConfig.java index b2d709a86..a0803d496 100644 --- a/main/src/com/google/refine/model/recon/StandardReconConfig.java +++ b/main/src/com/google/refine/model/recon/StandardReconConfig.java @@ -567,7 +567,7 @@ public class StandardReconConfig extends ReconConfig { * the cell value to compare the reconciliation data to */ public void computeFeatures(Recon recon, String text) { - if (recon.candidates != null && !recon.candidates.isEmpty()) { + if (recon.candidates != null && !recon.candidates.isEmpty() && text != null) { ReconCandidate candidate = recon.candidates.get(0); recon.setFeature(Recon.Feature_nameMatch, text.equalsIgnoreCase(candidate.name)); diff --git a/main/tests/server/src/com/google/refine/tests/model/recon/StandardReconConfigTests.java b/main/tests/server/src/com/google/refine/tests/model/recon/StandardReconConfigTests.java index c9098b5f8..7d8862ec2 100644 --- a/main/tests/server/src/com/google/refine/tests/model/recon/StandardReconConfigTests.java +++ b/main/tests/server/src/com/google/refine/tests/model/recon/StandardReconConfigTests.java @@ -345,4 +345,15 @@ public class StandardReconConfigTests extends RefineTest { stub.computeFeatures(recon, "my string"); assertNotNull(recon.features); } + + /** + * Should not happen, but added for extra safety + */ + @Test + public void testComputeFeaturesNullText() { + StandardReconConfigStub stub = new StandardReconConfigStub(); + Recon recon = stub.createNewRecon(2384738L); + stub.computeFeatures(recon, null); + assertNotNull(recon.features); + } }