Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] More reliable StreamCopyThread flush() method

Hello JGit devs!

I've just spent 2 days debugging hanging fetch via SSH from GitHub.
The hanging thread has a stacktrace like this:

  java.lang.Thread.State: WAITING
      at java.lang.Object.wait(
      at org.eclipse.jgit.util.IO.readFully(
      at org.eclipse.jgit.transport.PacketLineIn.readLength(
      at org.eclipse.jgit.transport.PacketLineIn.readString(
      at org.eclipse.jgit.transport.PacketLineIn.readACK(
      at org.eclipse.jgit.transport.BasePackFetchConnection.negotiate(
      at org.eclipse.jgit.transport.BasePackFetchConnection.doFetch(
      at org.eclipse.jgit.transport.BasePackFetchConnection.fetch(
      at org.eclipse.jgit.transport.BasePackFetchConnection.fetch(
      at org.eclipse.jgit.transport.FetchProcess.fetchObjects(
      at org.eclipse.jgit.transport.FetchProcess.executeImp(
      at org.eclipse.jgit.transport.FetchProcess.execute(
      at org.eclipse.jgit.transport.Transport.fetch(

It was waiting for response from GitHub, but never get one, so it
failed with timeout exception. The reason it didn't get reply is that
not all the data was sent to GitHub.

That happens because flush method in StreamCopyThread doesn't work
reliably with Jsch (a fine piece of engineering). An actual write to
the network happens in com.jcraft.jsch.Session write() method which
catches InterruptedException in several places and doesn't restore
thread's interrupted status. So if someone called
StreamCopyThread.flush() when it was calling dst.write() chances are
the flush will be lost and some data wouldn't be sent.

Please take a look at the possible fix Please let me know if there is a
better way to fix the problem.


Back to the top