BatchUpdate#newChangeContext: Add sanity check on unwrapped change

If the unwrapped change is null, this causes NPE later in the call
stack.

Check if the change is null, and if so log it and throw an exception.

Also modify the method's throws declaration to explicitly list the
exceptions that are thrown.

Change-Id: I994b360daf74ef3a2edf7e6f1660aabe7005a122
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/BatchUpdate.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/BatchUpdate.java
index 370d9a6..c686403 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/git/BatchUpdate.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/BatchUpdate.java
@@ -988,10 +988,14 @@
     }
 
     private ChangeContext newChangeContext(ReviewDb db, Repository repo,
-        RevWalk rw, Change.Id id) throws Exception {
+        RevWalk rw, Change.Id id) throws OrmException, NoSuchChangeException {
       Change c = newChanges.get(id);
       if (c == null) {
         c = ReviewDbUtil.unwrapDb(db).changes().get(id);
+        if (c == null) {
+          logDebug("Failed to get change {} from unwrapped db", id);
+          throw new NoSuchChangeException(id);
+        }
       }
       // Pass in preloaded change to controlFor, to avoid:
       //  - reading from a db that does not belong to this update