Check BLOB content size before trying to render it

Make sure that the content returned by JGit is below the
maximum size allowed for formatting/rendering with Soy.

The method loader.getCachedBytes(MAX_FILE_SIZE) would
return an in-memory content larger than MAX_FILE_SIZE if
the the BLOB is smaller than streamFileThreshold.

Parsing 100s megabytes of in-memory content using a
prettyfier regex and trying to render it in HTML would
result in a massive allocation of strings in the JVM heap.
The overload of memory allocation may eventually result in
triggering continuous 'stop-the-world' GC cycles, blocking
the process for several minutes.

Bug: https://github.com/google/gitiles/issues/192
Change-Id: I6ab5f367e731d67d4a5816a0beae5551106bb72b
2 files changed
tree: 424e22813b736c2899227b9fa3518ad826972325
  1. .bazelrc
  2. .bazelversion
  3. .gitignore
  4. .mailmap
  5. .settings/
  6. BUILD
  7. COPYING
  8. Documentation/
  9. README.md
  10. WORKSPACE
  11. fake_pom_deploy.xml
  12. java/com/google/gitiles/
  13. javatests/com/google/gitiles/
  14. lib/
  15. navbar.md
  16. resources/
  17. tools/
  18. version.bzl
README.md

Gitiles - A simple JGit repository browser

Gitiles is a simple repository browser for Git repositories, built on JGit. Its guiding principle is simplicity: it has no formal access controls, no write access, no fancy Javascript, etc.

Gitiles automatically renders *.md Markdown files into HTML for simplified documentation. Refer to the Markdown documentation for details.

Configuration

Gitiles is configurable in a git-style configuration file named gitiles.config. Refer to the configuration documentation for details.

Bugs

Use the issue tracker at github to file bugs.

Contributing to Gitiles

Please refer to the Developer Guide.