diff options
author | Edwin Kempin <edwin.kempin@sap.com> | 2012-06-13 03:54:28 -0700 |
---|---|---|
committer | gerrit code review <noreply-gerritcodereview@google.com> | 2012-06-13 03:54:29 -0700 |
commit | ccdeace3abac9064935b910bae8d73feb41c8f70 (patch) | |
tree | a9ba05d4830ed7a6a21d9f4e4fde5b4ebf86f6d8 | |
parent | 5dd198d652efcc918f7f152b8062b0fd4ebd0162 (diff) | |
parent | b4ecc4016829d56544025d58bd3fbe50d3c7ee22 (diff) |
Merge "Display proper error if file diff fails because content is too large" into stable-2.4
-rw-r--r-- | gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptFactory.java | 6 | ||||
-rw-r--r-- | gerrit-server/src/main/java/com/google/gerrit/server/git/LargeObjectException.java | 33 |
2 files changed, 38 insertions, 1 deletions
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptFactory.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptFactory.java index 66b32785b9..d61e6e755f 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptFactory.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptFactory.java @@ -31,6 +31,7 @@ import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.account.AccountInfoCacheFactory; import com.google.gerrit.server.git.GitRepositoryManager; +import com.google.gerrit.server.git.LargeObjectException; import com.google.gerrit.server.patch.PatchList; import com.google.gerrit.server.patch.PatchListCache; import com.google.gerrit.server.patch.PatchListEntry; @@ -120,7 +121,8 @@ class PatchScriptFactory extends Handler<PatchScript> { } @Override - public PatchScript call() throws OrmException, NoSuchChangeException { + public PatchScript call() throws OrmException, NoSuchChangeException, + LargeObjectException { validatePatchSetId(psa); validatePatchSetId(psb); @@ -156,6 +158,8 @@ class PatchScriptFactory extends Handler<PatchScript> { } catch (IOException e) { log.error("File content unavailable", e); throw new NoSuchChangeException(changeId, e); + } catch (org.eclipse.jgit.errors.LargeObjectException err) { + throw new LargeObjectException("File content is too large", err); } } finally { git.close(); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/LargeObjectException.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/LargeObjectException.java new file mode 100644 index 0000000000..d08b87683e --- /dev/null +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/LargeObjectException.java @@ -0,0 +1,33 @@ +// Copyright (C) 2012 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.git; + +/** + * Wrapper for {@link org.eclipse.jgit.errors.LargeObjectException}. Since + * org.eclipse.jgit.errors.LargeObjectException is a {@link RuntimeException} + * the GerritJsonServlet would treat it as internal failure and as result the + * web ui would just show 'Internal Server Error'. Wrapping + * org.eclipse.jgit.errors.LargeObjectException into a normal {@link Exception} + * allows to display a proper error message. + */ +public class LargeObjectException extends Exception { + + private static final long serialVersionUID = 1L; + + public LargeObjectException(final String message, + final org.eclipse.jgit.errors.LargeObjectException cause) { + super(message, cause); + } +} |