Fix racy HTTP tests by waiting for requests to finish
commitf2d5187ea1843c4ce3824874c145e1f40e4cff57
authorShawn O. Pearce <spearce@spearce.org>
Mon, 25 Jan 2010 22:51:56 +0000 (25 14:51 -0800)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 25 Jan 2010 22:51:56 +0000 (25 14:51 -0800)
tree019b8773cea2458648340fb9d757431a227b8748
parent6595ab10078690ed448b018383d4ecb538ff2a61
Fix racy HTTP tests by waiting for requests to finish

Ensure the background Jetty threads have been able to write the
request log record before the JUnit thread tries to read the set
of requests back.  This wait is necessary because the JUnit thread
may be able to continue as soon as Jetty has finished writing
the response onto the socket, and hasn't necessarily finished the
post-response logging activity.

By using a semaphore with a fixed number of resources, and using
one resource per request, but all of them when we want to read the
log, we implement a simple lock that requires there be no active
requests when we want to get the log from the JUnit thread.

Change-Id: I499e1c96418557185d0e19ba8befe892f26ce7e4
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/AppServer.java
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/TestRequestLog.java