| Summary: | Race condition in StreamCopyThread | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Technology] JGit | Reporter: | Dmitry Neverov <dmitry.neverov> | ||||
| Component: | JGit | Assignee: | Project Inbox <jgit.core-inbox> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | sop | ||||
| Version: | unspecified | ||||||
| Target Milestone: | 0.8.0 | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 168696 [details]
patch to fix problem
Applied in b3247ba5244d95e0d2c850a3fa1f69668a5790f5 |
Build Identifier: We should not check flushCounter.get() > 0 in catch block, because of such scenario: StreamCopyThread |OtherThread -----------------------------------------+----------------------------------- |invoke flush() | flushCounter.incrementAndGet(); n = src.read(buf);//read smth | if (flushCounter.get() > 0) continue; | if (needFlush()) | dst.flush(); //now flushCounter is 0 | src.read(buf); //block on read | | interrupt(); //in catch: | if (flushCounter.get() > 0) //false | throw wakey; | //in finally: | src.close(); | dst.close(); | |//return from flush() and try to write smth to closed stream, |//get IOException("Pipe closed") Since we use StreamCopyThrea.interrupt() for signaling it should make flush(), let's always ignore InterruptedExceptions. Patch to fix it is attached. Reproducible: Always