ExternalIdReader#all: Ignore all invalid and corrupt external IDs

When loading all external IDs and there are some invalid external IDs
we want to return all valid external IDs, and not fail. So far we
ignored only external IDs for which the configuration was invalid, but
parsing an external ID could also fail with other exceptions. We didn't
see any case of this yet, but to be on the safe side we should handle
them anyway. If such exceptions are not caught, a single corrupt
external ID could cause ExternalIdReader#all to never return
successfully. As a result the ExternalIdCache would never be populated
and we would attempt reloading all external IDs on each operation (which
would again fail).

Change-Id: I16e75ae8a4366759ee2bc40778f666b565633776
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2017-04-07 08:54:40 +02:00
parent 7d69efa72c
commit 0254c9ccc9

View File

@@ -156,7 +156,7 @@ public class ExternalIdReader {
rw.getObjectReader().open(note.getData(), OBJ_BLOB).getCachedBytes(MAX_NOTE_SZ);
try {
extIds.add(ExternalId.parse(note.getName(), raw));
} catch (ConfigInvalidException e) {
} catch (Exception e) {
log.error(String.format("Ignoring invalid external ID note %s", note.getName()), e);
}
}