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:
@@ -234,7 +234,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
||||
Term id = QueryBuilder.idTerm(cd);
|
||||
Document doc = toDocument(cd);
|
||||
try {
|
||||
if (cd.getChange().getStatus().isOpen()) {
|
||||
if (cd.change().getStatus().isOpen()) {
|
||||
Futures.allAsList(
|
||||
closedIndex.delete(id),
|
||||
openIndex.insert(doc)).get();
|
||||
@@ -243,9 +243,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
||||
openIndex.delete(id),
|
||||
closedIndex.insert(doc)).get();
|
||||
}
|
||||
} catch (ExecutionException e) {
|
||||
throw new IOException(e);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (OrmException | ExecutionException | InterruptedException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
@@ -256,7 +254,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
||||
Term id = QueryBuilder.idTerm(cd);
|
||||
Document doc = toDocument(cd);
|
||||
try {
|
||||
if (cd.getChange().getStatus().isOpen()) {
|
||||
if (cd.change().getStatus().isOpen()) {
|
||||
Futures.allAsList(
|
||||
closedIndex.delete(id),
|
||||
openIndex.replace(id, doc)).get();
|
||||
@@ -265,9 +263,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
||||
openIndex.delete(id),
|
||||
closedIndex.replace(id, doc)).get();
|
||||
}
|
||||
} catch (ExecutionException e) {
|
||||
throw new IOException(e);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (OrmException | ExecutionException | InterruptedException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
@@ -280,9 +276,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
||||
Futures.allAsList(
|
||||
openIndex.delete(id),
|
||||
closedIndex.delete(id)).get();
|
||||
} catch (ExecutionException e) {
|
||||
throw new IOException(e);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user