Do not log RepositoryNotFoundException if non-existing project is accessed
Trying to retrieve a non-existing project from the project cache causes a warning in the error log which prints the full stacktrace of the corresponding RepositoryNotFoundException. This is bad because every try to clone a non-existing project or providing a non-existing project as project argument to any SSH command triggers this warning in the error log. This is not a server error but just a bad request from a user, which shouldn't be logged. In any case the project cache still returns null for non-existing projects. All callers handle the null case, those that require the project to be found throw a NoSuchProjectException so that in this case there is still an exception that can be logged. Change-Id: Ie606b1af6756036d41387c8a9fe3b29f4c6345b3 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -28,6 +28,7 @@ import com.google.inject.Singleton;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.name.Named;
|
||||
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -116,7 +117,9 @@ public class ProjectCacheImpl implements ProjectCache {
|
||||
}
|
||||
return state;
|
||||
} catch (ExecutionException e) {
|
||||
log.warn(String.format("Cannot read project %s", projectName.get()), e);
|
||||
if (!(e.getCause() instanceof RepositoryNotFoundException)) {
|
||||
log.warn(String.format("Cannot read project %s", projectName.get()), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user