Don't log a stacktrace when reading a LargeObjectTombstone

We already logged a PatchListNotAvailableException when first seeing
a LargeObjectException so there is no need to log a stacktrace again.

Change-Id: I1f3a63ef108e2a585ffa31ff9c92189e30ed92a3
This commit is contained in:
Patrick Hiesel
2017-10-02 12:12:17 +01:00
parent 7963d72c76
commit 44cd9c2070
14 changed files with 66 additions and 1 deletions

View File

@@ -42,6 +42,7 @@ import com.google.gerrit.server.patch.PatchList;
import com.google.gerrit.server.patch.PatchListCache; import com.google.gerrit.server.patch.PatchListCache;
import com.google.gerrit.server.patch.PatchListKey; import com.google.gerrit.server.patch.PatchListKey;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
@@ -240,6 +241,8 @@ public class Files implements ChildCollection<RevisionResource, FileResource> {
try { try {
return copy(res.files(), res.patchSetId(), resource, userId); return copy(res.files(), res.patchSetId(), resource, userId);
} catch (PatchListObjectTooLargeException e) {
log.warn("Cannot copy patch review flags: " + e.getMessage());
} catch (IOException | PatchListNotAvailableException e) { } catch (IOException | PatchListNotAvailableException e) {
log.warn("Cannot copy patch review flags", e); log.warn("Cannot copy patch review flags", e);
} }

View File

@@ -56,6 +56,7 @@ import com.google.gerrit.server.patch.PatchList;
import com.google.gerrit.server.patch.PatchListCache; import com.google.gerrit.server.patch.PatchListCache;
import com.google.gerrit.server.patch.PatchListEntry; import com.google.gerrit.server.patch.PatchListEntry;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.query.change.InternalChangeQuery;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
@@ -425,6 +426,8 @@ public class EventFactory {
p.insertions = patch.getInsertions(); p.insertions = patch.getInsertions();
patchSetAttribute.files.add(p); patchSetAttribute.files.add(p);
} }
} catch (PatchListObjectTooLargeException e) {
log.warn("Cannot get patch list: " + e.getMessage());
} catch (PatchListNotAvailableException e) { } catch (PatchListNotAvailableException e) {
log.warn("Cannot get patch list", e); log.warn("Cannot get patch list", e);
} }
@@ -498,6 +501,8 @@ public class EventFactory {
p.kind = changeKindCache.getChangeKind(db, change, patchSet); p.kind = changeKindCache.getChangeKind(db, change, patchSet);
} catch (IOException | OrmException e) { } catch (IOException | OrmException e) {
log.error("Cannot load patch set data for " + patchSet.getId(), e); log.error("Cannot load patch set data for " + patchSet.getId(), e);
} catch (PatchListObjectTooLargeException e) {
log.warn(String.format("Cannot get size information for %s: %s", pId, e.getMessage()));
} catch (PatchListNotAvailableException e) { } catch (PatchListNotAvailableException e) {
log.error(String.format("Cannot get size information for %s.", pId), e); log.error(String.format("Cannot get size information for %s.", pId), e);
} }

View File

@@ -25,6 +25,7 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.GpgException; import com.google.gerrit.server.GpgException;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.io.IOException; import java.io.IOException;
@@ -70,6 +71,8 @@ public class ChangeAbandoned {
util.logEventListenerError(this, l, e); util.logEventListenerError(this, l, e);
} }
} }
} catch (PatchListObjectTooLargeException e) {
log.warn("Couldn't fire event: " + e.getMessage());
} catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) { } catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) {
log.error("Couldn't fire event", e); log.error("Couldn't fire event", e);
} }

View File

@@ -25,6 +25,7 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.GpgException; import com.google.gerrit.server.GpgException;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.io.IOException; import java.io.IOException;
@@ -64,6 +65,8 @@ public class ChangeMerged {
util.logEventListenerError(this, l, e); util.logEventListenerError(this, l, e);
} }
} }
} catch (PatchListObjectTooLargeException e) {
log.warn("Couldn't fire event: " + e.getMessage());
} catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) { } catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) {
log.error("Couldn't fire event", e); log.error("Couldn't fire event", e);
} }

View File

@@ -25,6 +25,7 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.GpgException; import com.google.gerrit.server.GpgException;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.io.IOException; import java.io.IOException;
@@ -63,6 +64,8 @@ public class ChangeRestored {
util.logEventListenerError(this, l, e); util.logEventListenerError(this, l, e);
} }
} }
} catch (PatchListObjectTooLargeException e) {
log.warn("Couldn't fire event: " + e.getMessage());
} catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) { } catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) {
log.error("Couldn't fire event", e); log.error("Couldn't fire event", e);
} }

View File

@@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.GpgException; import com.google.gerrit.server.GpgException;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.io.IOException; import java.io.IOException;
@@ -74,6 +75,8 @@ public class CommentAdded {
util.logEventListenerError(this, l, e); util.logEventListenerError(this, l, e);
} }
} }
} catch (PatchListObjectTooLargeException e) {
log.warn("Couldn't fire event: " + e.getMessage());
} catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) { } catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) {
log.error("Couldn't fire event", e); log.error("Couldn't fire event", e);
} }

View File

@@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.GpgException; import com.google.gerrit.server.GpgException;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.io.IOException; import java.io.IOException;
@@ -67,6 +68,8 @@ public class ReviewerAdded {
util.logEventListenerError(this, l, e); util.logEventListenerError(this, l, e);
} }
} }
} catch (PatchListObjectTooLargeException e) {
log.warn("Couldn't fire event: " + e.getMessage());
} catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) { } catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) {
log.error("Couldn't fire event", e); log.error("Couldn't fire event", e);
} }

View File

@@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.GpgException; import com.google.gerrit.server.GpgException;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.io.IOException; import java.io.IOException;
@@ -78,6 +79,8 @@ public class ReviewerDeleted {
util.logEventListenerError(this, listener, e); util.logEventListenerError(this, listener, e);
} }
} }
} catch (PatchListObjectTooLargeException e) {
log.warn("Couldn't fire event: " + e.getMessage());
} catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) { } catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) {
log.error("Couldn't fire event", e); log.error("Couldn't fire event", e);
} }

View File

@@ -25,6 +25,7 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.GpgException; import com.google.gerrit.server.GpgException;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.io.IOException; import java.io.IOException;
@@ -64,6 +65,8 @@ public class RevisionCreated {
util.logEventListenerError(this, l, e); util.logEventListenerError(this, l, e);
} }
} }
} catch (PatchListObjectTooLargeException e) {
log.warn("Couldn't fire event: " + e.getMessage());
} catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) { } catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) {
log.error("Couldn't fire event", e); log.error("Couldn't fire event", e);
} }

View File

@@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.GpgException; import com.google.gerrit.server.GpgException;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.io.IOException; import java.io.IOException;
@@ -78,6 +79,8 @@ public class VoteDeleted {
util.logEventListenerError(this, l, e); util.logEventListenerError(this, l, e);
} }
} }
} catch (PatchListObjectTooLargeException e) {
log.warn("Couldn't fire event: " + e.getMessage());
} catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) { } catch (PatchListNotAvailableException | GpgException | IOException | OrmException e) {
log.error("Couldn't fire event", e); log.error("Couldn't fire event", e);
} }

View File

@@ -37,6 +37,7 @@ import com.google.gerrit.server.notedb.ReviewerStateInternal;
import com.google.gerrit.server.patch.PatchList; import com.google.gerrit.server.patch.PatchList;
import com.google.gerrit.server.patch.PatchListEntry; import com.google.gerrit.server.patch.PatchListEntry;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException; import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
import com.google.gerrit.server.permissions.ChangePermission; import com.google.gerrit.server.permissions.ChangePermission;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
@@ -539,6 +540,9 @@ public abstract class ChangeEmail extends NotificationEmail {
// Currently these always have a null oldId in the PatchList. // Currently these always have a null oldId in the PatchList.
return "[Octopus merge; cannot be formatted as a diff.]\n"; return "[Octopus merge; cannot be formatted as a diff.]\n";
} }
} catch (PatchListObjectTooLargeException e) {
log.warn("Cannot format patch " + e.getMessage());
return "";
} catch (PatchListNotAvailableException e) { } catch (PatchListNotAvailableException e) {
log.error("Cannot format patch", e); log.error("Cannot format patch", e);
return ""; return "";

View File

@@ -35,6 +35,7 @@ import com.google.gerrit.server.mail.receive.Protocol;
import com.google.gerrit.server.patch.PatchFile; import com.google.gerrit.server.patch.PatchFile;
import com.google.gerrit.server.patch.PatchList; import com.google.gerrit.server.patch.PatchList;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
import com.google.gerrit.server.util.LabelVote; import com.google.gerrit.server.util.LabelVote;
import com.google.gwtorm.client.KeyUtil; import com.google.gwtorm.client.KeyUtil;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
@@ -232,6 +233,8 @@ public class CommentSender extends ReplyToChangeSender {
if (repo != null) { if (repo != null) {
try { try {
patchList = getPatchList(); patchList = getPatchList();
} catch (PatchListObjectTooLargeException e) {
log.warn("Failed to get patch list: " + e.getMessage());
} catch (PatchListNotAvailableException e) { } catch (PatchListNotAvailableException e) {
log.error("Failed to get patch list", e); log.error("Failed to get patch list", e);
} }

View File

@@ -103,7 +103,7 @@ public class PatchListCacheImpl implements PatchListCache {
try { try {
PatchList pl = fileCache.get(key, fileLoaderFactory.create(key, project)); PatchList pl = fileCache.get(key, fileLoaderFactory.create(key, project));
if (pl instanceof LargeObjectTombstone) { if (pl instanceof LargeObjectTombstone) {
throw new PatchListNotAvailableException( throw new PatchListObjectTooLargeException(
"Error computing " + key + ". Previous attempt failed with LargeObjectException"); "Error computing " + key + ". Previous attempt failed with LargeObjectException");
} }
if (key.getAlgorithm() == PatchListKey.Algorithm.OPTIMIZED_DIFF) { if (key.getAlgorithm() == PatchListKey.Algorithm.OPTIMIZED_DIFF) {

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.patch;
/**
* Exception thrown when the PatchList could not be computed because previous attempts failed with
* {@code LargeObjectException}. This is not thrown on the first computation.
*/
public class PatchListObjectTooLargeException extends PatchListNotAvailableException {
public PatchListObjectTooLargeException(String message) {
super(message);
}
}