Project

General

Profile

« Previous | Next » 

Revision 53142

avoid NPE in ExactMatch in case of missing values

View differences:

ExactMatch.java
6 6
import eu.dnetlib.pace.distance.eval.ConditionEval;
7 7
import eu.dnetlib.pace.model.Field;
8 8
import eu.dnetlib.pace.model.FieldDef;
9
import org.apache.commons.lang.StringUtils;
9 10

  
10 11
/**
11 12
 * The Class ExactMatch.
......
24 25
		final String fa = getValue(a);
25 26
		final String fb = getValue(b);
26 27

  
27
		return new ConditionEval(cond, a, b, fa.equals(fb) ? 1 : -1);
28
		int res;
29

  
30
		if (StringUtils.isBlank(fa) && StringUtils.isBlank(fb)) {
31
			res = 0;
32
		} else {
33
			res = fa.equals(fb) ? 1 : -1;
34
		}
35

  
36
		return new ConditionEval(cond, a, b, res);
28 37
	}
29 38

  
30 39
	protected String getValue(final Field f) {

Also available in: Unified diff