From a1cee65c7242f69f7e35978d98cea391095d7225 Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Fri, 12 Jun 2015 17:59:37 +0100 Subject: [PATCH] Bump to JGit 4.0.0 JGit 4.0.0 fixes a memory leak but introduces a non-compatible change for closing the RevWalk: before it was release() but now is close() --- .classpath | 8 ++-- build.moxie | 2 +- gitblit.iml | 40 ++++++++++++++----- .../com/syntevo/bugtraq/BugtraqConfig.java | 2 +- .../com/gitblit/git/PatchsetReceivePack.java | 4 +- .../com/gitblit/service/LuceneService.java | 2 +- .../java/com/gitblit/servlet/RawServlet.java | 2 +- .../gitblit/tickets/BranchTicketService.java | 14 +++---- .../com/gitblit/utils/CompressionUtils.java | 4 +- .../java/com/gitblit/utils/JGitUtils.java | 24 +++++------ .../java/com/gitblit/utils/RefLogUtils.java | 8 ++-- .../wicket/pages/NewRepositoryPage.java | 4 +- .../gitblit/wicket/panels/HistoryPanel.java | 2 +- 13 files changed, 70 insertions(+), 46 deletions(-) diff --git a/.classpath b/.classpath index fb8181c0..84ff6988 100644 --- a/.classpath +++ b/.classpath @@ -41,14 +41,14 @@ - - + + - + @@ -89,6 +89,8 @@ + + diff --git a/build.moxie b/build.moxie index 6863968c..19730c57 100644 --- a/build.moxie +++ b/build.moxie @@ -106,7 +106,7 @@ properties: { slf4j.version : 1.7.10 wicket.version : 1.4.21 lucene.version : 4.10.0 - jgit.version : 3.7.0.201502260915-r + jgit.version : 4.0.0.201506090130-r groovy.version : 2.4.1 bouncycastle.version : 1.51 selenium.version : 2.28.0 diff --git a/gitblit.iml b/gitblit.iml index d35be382..de234358 100644 --- a/gitblit.iml +++ b/gitblit.iml @@ -408,24 +408,24 @@ - + - + - + - + - + - + @@ -485,13 +485,13 @@ - + - + - + @@ -933,6 +933,28 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/bugtraq/com/syntevo/bugtraq/BugtraqConfig.java b/src/main/bugtraq/com/syntevo/bugtraq/BugtraqConfig.java index 7776e6fe..60b4ecc0 100644 --- a/src/main/bugtraq/com/syntevo/bugtraq/BugtraqConfig.java +++ b/src/main/bugtraq/com/syntevo/bugtraq/BugtraqConfig.java @@ -214,7 +214,7 @@ public final class BugtraqConfig { } finally { rw.dispose(); - tw.release(); + tw.close(); } if (content == null) { diff --git a/src/main/java/com/gitblit/git/PatchsetReceivePack.java b/src/main/java/com/gitblit/git/PatchsetReceivePack.java index 54ffb7ba..ef0b409b 100644 --- a/src/main/java/com/gitblit/git/PatchsetReceivePack.java +++ b/src/main/java/com/gitblit/git/PatchsetReceivePack.java @@ -667,7 +667,7 @@ public class PatchsetReceivePack extends GitblitReceivePack { // identified the missing object earlier before we got control. LOGGER.error("failed to get commit count", e); } finally { - walk.release(); + walk.close(); } sendError(""); @@ -1078,7 +1078,7 @@ public class PatchsetReceivePack extends GitblitReceivePack { LOGGER.error("failed to get commit count", e); return 0; } finally { - walk.release(); + walk.close(); } return count; } diff --git a/src/main/java/com/gitblit/service/LuceneService.java b/src/main/java/com/gitblit/service/LuceneService.java index 798edb0a..285ea8d7 100644 --- a/src/main/java/com/gitblit/service/LuceneService.java +++ b/src/main/java/com/gitblit/service/LuceneService.java @@ -615,7 +615,7 @@ public class LuceneService implements Runnable { } // finished - reader.release(); + reader.close(); // commit all changes and reset the searcher config.setInt(CONF_INDEX, null, CONF_VERSION, INDEX_VERSION); diff --git a/src/main/java/com/gitblit/servlet/RawServlet.java b/src/main/java/com/gitblit/servlet/RawServlet.java index 09f9f8a3..1d2724bc 100644 --- a/src/main/java/com/gitblit/servlet/RawServlet.java +++ b/src/main/java/com/gitblit/servlet/RawServlet.java @@ -468,7 +468,7 @@ public class RawServlet extends HttpServlet { served = true; } } finally { - tw.release(); + tw.close(); rw.dispose(); } diff --git a/src/main/java/com/gitblit/tickets/BranchTicketService.java b/src/main/java/com/gitblit/tickets/BranchTicketService.java index 42189bfd..83966939 100644 --- a/src/main/java/com/gitblit/tickets/BranchTicketService.java +++ b/src/main/java/com/gitblit/tickets/BranchTicketService.java @@ -297,7 +297,7 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi log.error("failed to read " + file, e); } finally { if (rw != null) { - rw.release(); + rw.close(); } } return null; @@ -353,7 +353,7 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi } catch (IOException e) { log.error("", e); } finally { - inserter.release(); + inserter.close(); } } @@ -712,7 +712,7 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi } finally { // release the treewalk if (treeWalk != null) { - treeWalk.release(); + treeWalk.close(); } } } finally { @@ -811,7 +811,7 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi // finish the index builder.finish(); } finally { - inserter.release(); + inserter.close(); } return newIndex; } @@ -855,7 +855,7 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi } } finally { if (tw != null) { - tw.release(); + tw.close(); } } return list; @@ -913,10 +913,10 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi rc)); } } finally { - revWalk.release(); + revWalk.close(); } } finally { - odi.release(); + odi.close(); } return success; } diff --git a/src/main/java/com/gitblit/utils/CompressionUtils.java b/src/main/java/com/gitblit/utils/CompressionUtils.java index d4bfbb34..b06edd22 100644 --- a/src/main/java/com/gitblit/utils/CompressionUtils.java +++ b/src/main/java/com/gitblit/utils/CompressionUtils.java @@ -132,7 +132,7 @@ public class CompressionUtils { } catch (IOException e) { error(e, repository, "{0} failed to zip files from commit {1}", commit.getName()); } finally { - tw.release(); + tw.close(); rw.dispose(); } return success; @@ -291,7 +291,7 @@ public class CompressionUtils { } catch (IOException e) { error(e, repository, "{0} failed to {1} stream files from commit {2}", algorithm, commit.getName()); } finally { - tw.release(); + tw.close(); rw.dispose(); } return success; diff --git a/src/main/java/com/gitblit/utils/JGitUtils.java b/src/main/java/com/gitblit/utils/JGitUtils.java index 69084ca1..356a796c 100644 --- a/src/main/java/com/gitblit/utils/JGitUtils.java +++ b/src/main/java/com/gitblit/utils/JGitUtils.java @@ -774,7 +774,7 @@ public class JGitUtils { } } finally { rw.dispose(); - tw.release(); + tw.close(); } return content; } @@ -885,7 +885,7 @@ public class JGitUtils { } catch (IOException e) { error(e, repository, "{0} failed to get files for commit {1}", commit.getName()); } finally { - tw.release(); + tw.close(); } Collections.sort(list); return list; @@ -942,7 +942,7 @@ public class JGitUtils { } catch (IOException e) { error(e, repository, "{0} failed to get files for commit {1}", commit.getName()); } finally { - tw.release(); + tw.close(); } Collections.sort(list); return list; @@ -994,7 +994,7 @@ public class JGitUtils { .getRawMode(0), tw.getObjectId(0).getName(), commit.getId().getName(), ChangeType.ADD)); } - tw.release(); + tw.close(); } else { RevCommit parent = rw.parseCommit(commit.getParent(0).getId()); DiffStatFormatter df = new DiffStatFormatter(commit.getName()); @@ -1049,7 +1049,7 @@ public class JGitUtils { RevCommit start = rw.parseCommit(startRange); RevCommit end = rw.parseCommit(endRange); list.addAll(getFilesInRange(repository, start, end)); - rw.release(); + rw.close(); } catch (Throwable t) { error(t, repository, "{0} failed to determine files in range {1}..{2}!", startCommit, endCommit); } @@ -1147,7 +1147,7 @@ public class JGitUtils { } catch (IOException e) { error(e, repository, "{0} failed to get documents for commit {1}", commit.getName()); } finally { - tw.release(); + tw.close(); } Collections.sort(list); return list; @@ -2044,7 +2044,7 @@ public class JGitUtils { error(t, repository, "{0} can't find {1} in commit {2}", path, commit.name()); } finally { rw.dispose(); - tw.release(); + tw.close(); } return commitId; } @@ -2218,10 +2218,10 @@ public class JGitUtils { success = false; } } finally { - revWalk.release(); + revWalk.close(); } } finally { - odi.release(); + odi.close(); } } catch (Throwable t) { error(t, repository, "Failed to create orphan branch {1} in repository {0}", branchName); @@ -2412,7 +2412,7 @@ public class JGitUtils { LOGGER.error("Failed to determine canMerge", e); } finally { if (revWalk != null) { - revWalk.release(); + revWalk.close(); } } return MergeStatus.NOT_MERGEABLE; @@ -2498,14 +2498,14 @@ public class JGitUtils { // return the merge commit id return new MergeResult(MergeStatus.MERGED, mergeCommitId.getName()); } finally { - odi.release(); + odi.close(); } } } catch (IOException e) { LOGGER.error("Failed to merge", e); } finally { if (revWalk != null) { - revWalk.release(); + revWalk.close(); } } return new MergeResult(MergeStatus.FAILED, null); diff --git a/src/main/java/com/gitblit/utils/RefLogUtils.java b/src/main/java/com/gitblit/utils/RefLogUtils.java index f08c99e7..355c1208 100644 --- a/src/main/java/com/gitblit/utils/RefLogUtils.java +++ b/src/main/java/com/gitblit/utils/RefLogUtils.java @@ -294,10 +294,10 @@ public class RefLogUtils { rc)); } } finally { - revWalk.release(); + revWalk.close(); } } finally { - odi.release(); + odi.close(); } } catch (Throwable t) { error(t, repository, "Failed to commit reflog entry to {0}"); @@ -395,12 +395,12 @@ public class RefLogUtils { } // release the treewalk - treeWalk.release(); + treeWalk.close(); // finish temporary in-core index used for this commit dcBuilder.finish(); } finally { - inserter.release(); + inserter.close(); } return inCoreIndex; } diff --git a/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java index b6c23591..d2589e6f 100644 --- a/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java @@ -359,14 +359,14 @@ public class NewRepositoryPage extends RootSubPage { } } } finally { - revWalk.release(); + revWalk.close(); } } catch (UnsupportedEncodingException e) { logger().error(null, e); } catch (IOException e) { logger().error(null, e); } finally { - odi.release(); + odi.close(); db.close(); } return success; diff --git a/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java b/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java index e1706a09..5233f7c9 100644 --- a/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java @@ -116,7 +116,7 @@ public class HistoryPanel extends BasePanel { } } catch (Exception e) { } finally { - tw.release(); + tw.close(); } } } -- 2.39.5