Browse Source

Merge "Fix TransportException when reading bundle"

stable-4.3
Shawn Pearce 9 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
08aac5904e
  1. 27
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java

27
org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java

@ -161,16 +161,23 @@ class BundleFetchConnection extends BaseFetchConnection {
} }
private String readLine(final byte[] hdrbuf) throws IOException { private String readLine(final byte[] hdrbuf) throws IOException {
bin.mark(hdrbuf.length); StringBuilder line = new StringBuilder();
final int cnt = bin.read(hdrbuf); boolean done = false;
int lf = 0; while (!done) {
while (lf < cnt && hdrbuf[lf] != '\n') bin.mark(hdrbuf.length);
lf++; final int cnt = bin.read(hdrbuf);
bin.reset(); int lf = 0;
IO.skipFully(bin, lf); while (lf < cnt && hdrbuf[lf] != '\n')
if (lf < cnt && hdrbuf[lf] == '\n') lf++;
IO.skipFully(bin, 1); bin.reset();
return RawParseUtils.decode(Constants.CHARSET, hdrbuf, 0, lf); IO.skipFully(bin, lf);
if (lf < cnt && hdrbuf[lf] == '\n') {
IO.skipFully(bin, 1);
done = true;
}
line.append(RawParseUtils.decode(Constants.CHARSET, hdrbuf, 0, lf));
}
return line.toString();
} }
public boolean didFetchTestConnectivity() { public boolean didFetchTestConnectivity() {

Loading…
Cancel
Save