Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not tolerate exceptions while storing the serialized network #946

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/main/java/com/conveyal/r5/transit/TransportNetworkCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private TransportNetworkConfig loadNetworkConfig (String networkId) {
* If we did not find a cached network, build one from the input files. Should throw an exception rather than
* returning null if for any reason it can't finish building one.
*/
private @Nonnull TransportNetwork buildNetwork (String networkId) {
private @Nonnull TransportNetwork buildNetwork(String networkId) throws IOException {
TransportNetwork network;
TransportNetworkConfig networkConfig = loadNetworkConfig(networkId);
if (networkConfig == null) {
Expand Down Expand Up @@ -225,14 +225,10 @@ private TransportNetworkConfig loadNetworkConfig (String networkId) {
network.rebuildLinkedGridPointSet(buildGridsForModes);

// Cache the serialized network on the local filesystem and mirror it to any remote storage.
try {
File cacheLocation = FileUtils.createScratchFile();
KryoNetworkSerializer.write(network, cacheLocation);
fileStorage.moveIntoStorage(getR5NetworkFileStorageKey(networkId), cacheLocation);
} catch (Exception e) {
// Tolerate exceptions here as we do have a network to return, we just failed to cache it.
LOG.error("Error saving cached network, returning the object anyway.", e);
}
File cacheLocation = FileUtils.createScratchFile();
KryoNetworkSerializer.write(network, cacheLocation);
fileStorage.moveIntoStorage(getR5NetworkFileStorageKey(networkId), cacheLocation);

return network;
}

Expand Down
Loading