#133 - Made JsonPathLinkDiscoverer more robust.

JsonPathLinkDiscoverer now handles InvalidPathExceptions that might occur if the representation doesn't contain the link container element.
This commit is contained in:
Oliver Gierke
2013-12-29 18:59:35 +01:00
parent bc68707e73
commit 6673f1987f
3 changed files with 24 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import com.jayway.jsonpath.InvalidPathException;
import com.jayway.jsonpath.JsonPath;
/**
@@ -88,8 +89,12 @@ public class JsonPathLinkDiscoverer implements LinkDiscoverer {
@Override
public List<Link> findLinksWithRel(String rel, String representation) {
Object parseResult = getExpression(rel).read(representation);
return createLinksFrom(parseResult, rel);
try {
Object parseResult = getExpression(rel).read(representation);
return createLinksFrom(parseResult, rel);
} catch (InvalidPathException e) {
return Collections.emptyList();
}
}
/*