Eliminate potential NPEs with ChangeData.getChange()
Callers were supposed to be calling hasChange() to determine whether getChange() would return null, but none were. Remove this error-prone pair of methods and just use change(), which includes lazy loading. There are a few places where we need to catch an additional OrmException but these are easy enough to fix. Change-Id: I23335e362715f59e2c093ffec88427739ff0cffc
This commit is contained in:
@@ -148,14 +148,14 @@ class SolrChangeIndex implements ChangeIndex, LifecycleListener {
|
||||
String id = cd.getId().toString();
|
||||
SolrInputDocument doc = toDocument(cd);
|
||||
try {
|
||||
if (cd.getChange().getStatus().isOpen()) {
|
||||
if (cd.change().getStatus().isOpen()) {
|
||||
closedIndex.deleteById(id);
|
||||
openIndex.add(doc);
|
||||
} else {
|
||||
openIndex.deleteById(id);
|
||||
closedIndex.add(doc);
|
||||
}
|
||||
} catch (SolrServerException e) {
|
||||
} catch (OrmException | SolrServerException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
commit(openIndex);
|
||||
@@ -167,14 +167,14 @@ class SolrChangeIndex implements ChangeIndex, LifecycleListener {
|
||||
String id = cd.getId().toString();
|
||||
SolrInputDocument doc = toDocument(cd);
|
||||
try {
|
||||
if (cd.getChange().getStatus().isOpen()) {
|
||||
if (cd.change().getStatus().isOpen()) {
|
||||
closedIndex.deleteById(id);
|
||||
openIndex.add(doc);
|
||||
} else {
|
||||
openIndex.deleteById(id);
|
||||
closedIndex.add(doc);
|
||||
}
|
||||
} catch (SolrServerException e) {
|
||||
} catch (OrmException | SolrServerException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
commit(openIndex);
|
||||
@@ -185,14 +185,14 @@ class SolrChangeIndex implements ChangeIndex, LifecycleListener {
|
||||
public void delete(ChangeData cd) throws IOException {
|
||||
String id = cd.getId().toString();
|
||||
try {
|
||||
if (cd.getChange().getStatus().isOpen()) {
|
||||
if (cd.change().getStatus().isOpen()) {
|
||||
openIndex.deleteById(id);
|
||||
commit(openIndex);
|
||||
} else {
|
||||
closedIndex.deleteById(id);
|
||||
commit(closedIndex);
|
||||
}
|
||||
} catch (SolrServerException e) {
|
||||
} catch (OrmException | SolrServerException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user