project leak

This commit is contained in:
Alexey Kudravtsev
2010-07-06 14:31:51 +04:00
parent f0976f502c
commit 6a8b8d3c1f
2 changed files with 23 additions and 10 deletions
@@ -233,7 +233,7 @@ public class OSProcessHandler extends ProcessHandler {
private boolean skipLF = false;
private boolean myIsClosed = false;
volatile private boolean myIsProcessTerminated = false;
private volatile boolean myIsProcessTerminated = false;
private final Semaphore mySemaphore = new Semaphore();
private final BlockingQueue<String> myNotificationQueue = new LinkedBlockingQueue<String>();
@@ -349,12 +349,15 @@ public class OSProcessHandler extends ProcessHandler {
@Override
public void run() {
while (true) {
final ReadProcessRequest request = takeRequest();
ReadProcessRequest request = takeRequest();
if (request == null) return;
processRequest(request);
if (!request.isClosed()) addRequest(request);
//noinspection UnusedAssignment
request = null; //leak?
try {
Thread.sleep(1L);
}
@@ -68,13 +68,7 @@ public abstract class GitTextHandler extends GitHandler {
* {@inheritDoc}
*/
protected void startHandlingStreams() {
myHandler = new OSProcessHandler(myProcess, myCommandLine.getCommandLineString()) {
@Override
public Charset getCharset() {
Charset charset = GitTextHandler.this.getCharset();
return charset == null ? super.getCharset() : charset;
}
};
myHandler = new MyOSProcessHandler(myProcess, myCommandLine.getCommandLineString(), getCharset());
myHandler.addProcessListener(new ProcessListener() {
public void startNotified(final ProcessEvent event) {
// do nothing
@@ -130,7 +124,23 @@ public abstract class GitTextHandler extends GitHandler {
* {@inheritDoc}
*/
protected void waitForProcess() {
myHandler.waitFor();
OSProcessHandler handler = myHandler;
myHandler = null;
handler.waitFor();
}
private static class MyOSProcessHandler extends OSProcessHandler {
private final Charset myCharset;
public MyOSProcessHandler(Process process, String commandLine, Charset charset) {
super(process, commandLine);
myCharset = charset;
}
@Override
public Charset getCharset() {
Charset charset = myCharset;
return charset == null ? super.getCharset() : charset;
}
}
}