]> source.dussan.org Git - gitblit.git/commit
Issue #1011: do not serialize JGit commit objects
authorTom <tw201207@gmail.com>
Wed, 26 Oct 2016 20:49:56 +0000 (22:49 +0200)
committerFlorian Zschocke <2362065+flaix@users.noreply.github.com>
Wed, 3 Nov 2021 19:37:06 +0000 (20:37 +0100)
commit560f2e3ab0f78429fe22dc23ae25de6a7500cf02
tree9890982332b540c86009c04a13c9729ba1f56cdb
parentedd1e6759ce72e36776ebb2dcd5c6529a5bf079a
Issue #1011: do not serialize JGit commit objects

JGit commit objects are a recursive data structure; they have links to
their parent commits. Serializing a JGit commit will try to recursively
serialize all reachable ancestors as faras they have been loaded. If
that ancestor chain is too long, a StackOverflowError is thrown during
Wicket's page serialization if a page has a reference to sucha JGit
commit.

Fixed by making sure that pages o not contain references to JGit
commits. Use the (existing) wrapper object RepositoryCommit instead.

* RepositoryCommit has a transient reference to the JGit commit and
  reads the commit from the repository upon de-serialization.
* RefModel is a similar case (JGit tags/branches may also have links
  to the commits they point to). Solved a bit differently by making it
  a pure data object by transferring the interesting data from the JGit
  object in the constructor.
* Change DataViews instantiated with RevCommit to use RepositoryCommit
  instead.
* Change inner anonymous DataViews to ensure they do not have a
  synthesized field referencing the "allRefs" map. Such a synthesized
  field would also get serialized, and then serialize JGit commits
  again.

Finally, remove non-transient logger instances in Wicket classes. Those
might lead to NotSerializableException.

These StackOverflowErrors have been reported in several places since
2014:

* https://groups.google.com/forum/#!topic/gitblit/GH1d8WSlR6Q
* https://bugs.chromium.org/p/gerrit/issues/detail?id=3316
* https://groups.google.com/d/msg/repo-discuss/Kcl0JIGNiGk/0DjH4mO8hA8J
* https://groups.google.com/d/msg/repo-discuss/0_P6A3fjTec/2kcpVPIUAQAJ
* https://github.com/gitblit/gitblit/issues/1011
* https://github.com/tomaswolf/gerrit-gitblit-plugin/issues/21
13 files changed:
src/main/java/com/gitblit/models/RefModel.java
src/main/java/com/gitblit/models/RepositoryCommit.java
src/main/java/com/gitblit/wicket/SessionlessForm.java
src/main/java/com/gitblit/wicket/pages/BlamePage.java
src/main/java/com/gitblit/wicket/pages/EditFilePage.java
src/main/java/com/gitblit/wicket/pages/MetricsPage.java
src/main/java/com/gitblit/wicket/pages/RawPage.java
src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
src/main/java/com/gitblit/wicket/pages/SummaryPage.java
src/main/java/com/gitblit/wicket/pages/TicketPage.java
src/main/java/com/gitblit/wicket/panels/HistoryPanel.java
src/main/java/com/gitblit/wicket/panels/LogPanel.java
src/main/java/com/gitblit/wicket/panels/SearchPanel.java