From 6340c76d8b50a48c3700f874bad3e6ece7349802 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Fri, 14 Aug 2015 14:03:57 +0200 Subject: [PATCH] Fix InterruptTimer leak in BasePackConnection When setting timeout on push, BasePackConnection creates a timer, which will be terminated when push finishes. But, when using SmartHttpPushConnection, it dropped the first timer created in the constructor and then created another timer in doPush. If new threads are created faster than the gc collects then this may stop the service if it's hitting the max process limit. Hence don't create a new timer if it already exists. Bug: 474947 Change-Id: I6746ffe4584ad919369afd5bdbba66fe736be314 Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/transport/BasePackConnection.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java index 7f9cec734..aa36aeb1b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java @@ -143,7 +143,9 @@ abstract class BasePackConnection extends BaseConnection { final int timeout = transport.getTimeout(); if (timeout > 0) { final Thread caller = Thread.currentThread(); - myTimer = new InterruptTimer(caller.getName() + "-Timer"); //$NON-NLS-1$ + if (myTimer == null) { + myTimer = new InterruptTimer(caller.getName() + "-Timer"); //$NON-NLS-1$ + } timeoutIn = new TimeoutInputStream(myIn, myTimer); timeoutOut = new TimeoutOutputStream(myOut, myTimer); timeoutIn.setTimeout(timeout * 1000);