Bug 389610 - StreamCopyTheads do not terminate when remote repository is not found
Summary: StreamCopyTheads do not terminate when remote repository is not found
Status: NEW
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 2.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-14 10:12 EDT by Dmitry Neverov CLA
Modified: 2012-09-14 10:14 EDT (History)
0 users

See Also:


Attachments
A possible fix (887 bytes, application/octet-stream)
2012-09-14 10:14 EDT, Dmitry Neverov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Neverov CLA 2012-09-14 10:12:17 EDT
This can be reproduced by the following test:


@Test
public void testFectchOrphanedThreads() throws Exception {
  int timeoutSeconds = 5;
  Repository db = createWorkRepository();
  SshTransport t = (SshTransport) Transport.open(db, "<ssh url, where connection is successful, but repository is not found>");
  t.setTimeout(timeoutSeconds);
  try {
    FetchConnection fc = t.openFetch();
  } catch (Exception e) {
    //it's OK
    t.close();
  }

  try {
    Thread.sleep(timeoutSeconds * 1000);
  } catch (InterruptedException e) {
    // ignore
  }

  boolean copyThreadTerminated = true;
  for (Thread thread : Thread.getAllStackTraces().keySet()) {
    if (thread.getName().endsWith("-StreamCopy"))
      copyThreadTerminated = false;
  }
  assertTrue("Copy thread wasn't terminated", copyThreadTerminated);
}

A possible fix is attached.
Comment 1 Dmitry Neverov CLA 2012-09-14 10:14:19 EDT
Created attachment 221089 [details]
A possible fix