diff --git a/main/src/com/google/refine/model/recon/StandardReconConfig.java b/main/src/com/google/refine/model/recon/StandardReconConfig.java index bb31aa6e0..b2d709a86 100644 --- a/main/src/com/google/refine/model/recon/StandardReconConfig.java +++ b/main/src/com/google/refine/model/recon/StandardReconConfig.java @@ -566,8 +566,8 @@ public class StandardReconConfig extends ReconConfig { * @param text * the cell value to compare the reconciliation data to */ - public void computeFeatures(Recon recon, String text) { - if (!recon.candidates.isEmpty()) { + public void computeFeatures(Recon recon, String text) { + if (recon.candidates != null && !recon.candidates.isEmpty()) { ReconCandidate candidate = recon.candidates.get(0); recon.setFeature(Recon.Feature_nameMatch, text.equalsIgnoreCase(candidate.name)); @@ -587,7 +587,7 @@ public class StandardReconConfig extends ReconConfig { } else { recon.features = new Object[Recon.Feature_max]; } - } + } static protected double wordDistance(String s1, String s2) { Set words1 = breakWords(s1); 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 dfe2a1f59..c9098b5f8 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 @@ -27,6 +27,7 @@ package com.google.refine.tests.model.recon; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; @@ -333,4 +334,15 @@ public class StandardReconConfigTests extends RefineTest { assertEquals(recon.candidates.get(0).score, 0.3); assertEquals(recon.candidates.get(0).id, "18951129"); } + + /** + * computing the features on an empty recon should not fail + */ + @Test + public void testComputeFeatures() { + StandardReconConfigStub stub = new StandardReconConfigStub(); + Recon recon = stub.createNewRecon(2384738L); + stub.computeFeatures(recon, "my string"); + assertNotNull(recon.features); + } }