private Thread worker;
InternalLocalFetchConnection() throws TransportException {
super(TransportLocal.this);
final Repository dst;
try {
dst = new FileRepository(remoteGitDir);
} catch (IOException err) {
throw new TransportException(uri, JGitText.get().notAGitDirectory);
}
final PipedInputStream in_r;
final PipedOutputStream in_w;
final PipedInputStream out_r;
final PipedOutputStream out_w;
try {
in_r = new PipedInputStream();
in_w = new PipedOutputStream(in_r);
out_r = new PipedInputStream() {
// The client (BasePackFetchConnection) can write
// a huge burst before it reads again. We need to
// force the buffer to be big enough, otherwise it
// will deadlock both threads.
{
buffer = new byte[MIN_CLIENT_BUFFER];
}
};
out_w = new PipedOutputStream(out_r);
} catch (IOException err) {
dst.close();
throw new TransportException(uri, JGitText.get().cannotConnectPipes, err);
}
worker = new Thread("JGit-Upload-Pack") {
public void run() {
try {
final UploadPack rp = createUploadPack(dst);
rp.upload(out_r, in_w, null);
} catch (IOException err) {
// Client side of the pipes should report the problem.
err.printStackTrace();
} catch (RuntimeException err) {
// Clients side will notice we went away, and report.
err.printStackTrace();
} finally {
try {
out_r.close();
} catch (IOException e2) {
// Ignore close failure, we probably crashed above.
}
try {
in_w.close();
} catch (IOException e2) {
// Ignore close failure, we probably crashed above.
}
dst.close();
}
}
};
worker.start();