[
https://jira.jboss.org/jira/browse/SHRINKWRAP-137?page=com.atlassian.jira...
]
Andrew Lee Rubinger commented on SHRINKWRAP-137:
------------------------------------------------
Some logging shows the cause.
Index: src/main/java/org/jboss/shrinkwrap/impl/base/exporter/JdkZipExporterDelegate.java
===================================================================
---
src/main/java/org/jboss/shrinkwrap/impl/base/exporter/JdkZipExporterDelegate.java (revision
4050)
+++
src/main/java/org/jboss/shrinkwrap/impl/base/exporter/JdkZipExporterDelegate.java (working
copy)
@@ -162,6 +162,7 @@
try
{
+ log.info("TRYING TO CLOSE");
zipOutputStream.close();
}
catch (final IOException ioe)
@@ -210,6 +211,7 @@
* The job is now waiting on us to signal that we've set up the streams;
* let it continue
*/
+ log.info("COUNTING DOWN");
latch.countDown();
}
@@ -261,6 +263,7 @@
* Wait until all streams have been set up for encoding, or
* do nothing if everything's set up already
*/
+ log.info("AWAITING ON LATCH");
latch.await();
// Write the Asset under the same Path name in the Zip
Can result in unlucky timing:
Feb 22, 2010 8:28:34 PM org.jboss.shrinkwrap.impl.base.exporter.JdkZipExporterDelegate$1
call
INFO: TRYING TO CLOSE
Feb 22, 2010 8:28:34 PM org.jboss.shrinkwrap.impl.base.exporter.JdkZipExporterDelegate
export
INFO: COUNTING DOWN
In this case we've gotten an exception during export before the streams have been set
up. Then, because no entries have been written, we attempt to manually write one before
closing the ZIP outstream. But since the stream hasn't fully been initialized and
piped, we deadlock. Optionally blocking corrects this:
Index: src/main/java/org/jboss/shrinkwrap/impl/base/exporter/JdkZipExporterDelegate.java
===================================================================
---
src/main/java/org/jboss/shrinkwrap/impl/base/exporter/JdkZipExporterDelegate.java (revision
4050)
+++
src/main/java/org/jboss/shrinkwrap/impl/base/exporter/JdkZipExporterDelegate.java (working
copy)
@@ -152,6 +152,12 @@
//TODO Find a better solution :)
if (pathsExported.isEmpty())
{
+ // Ensure the streams are set up before we do any work on them;
+ // it's possible that we encountered an exception before
+ // everything has been initialized by the main Thread
+ // SHRINKWRAP-137
+ latch.await();
+
zipOutputStream.putNextEntry(new ZipEntry("dummy.txt"));
}
Race Condition leads to Deadlock in Zip Export
----------------------------------------------
Key: SHRINKWRAP-137
URL:
https://jira.jboss.org/jira/browse/SHRINKWRAP-137
Project: ShrinkWrap
Issue Type: Bug
Components: impl-base
Reporter: Andrew Lee Rubinger
Assignee: Andrew Lee Rubinger
Priority: Blocker
Fix For: 1.0.0-alpha-6
Running the ZipExporterTestCase a few times usually lets me reproduce this. Thread
dump:
Full thread dump Java HotSpot(TM) 64-Bit Server VM (14.0-b16 mixed mode):
"pool-1-thread-2" prio=10 tid=0x00007fbb68004800 nid=0x7e6a waiting on
condition [0x00007fbba210c000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00007fbbd1082528> (a
java.util.concurrent.SynchronousQueue$TransferStack)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)
at
java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:424)
at
java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:323)
at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:874)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:945)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
"pool-1-thread-1" prio=10 tid=0x00007fbbe81f0000 nid=0x7e69 waiting on
condition [0x00007fbba220d000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00007fbbd1082528> (a
java.util.concurrent.SynchronousQueue$TransferStack)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)
at
java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:424)
at
java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:323)
at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:874)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:945)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
"Low Memory Detector" daemon prio=10 tid=0x00007fbbe8112800 nid=0x7e67 runnable
[0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"CompilerThread1" daemon prio=10 tid=0x00007fbbe8110000 nid=0x7e66 waiting on
condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"CompilerThread0" daemon prio=10 tid=0x00007fbbe810d800 nid=0x7e65 waiting on
condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"Signal Dispatcher" daemon prio=10 tid=0x00007fbbe810b800 nid=0x7e64 waiting on
condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"Finalizer" daemon prio=10 tid=0x00007fbbe80ee800 nid=0x7e63 in Object.wait()
[0x00007fbba2833000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00007fbbd0ab11e0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
- locked <0x00007fbbd0ab11e0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
"Reference Handler" daemon prio=10 tid=0x00007fbbe80ec800 nid=0x7e62 in
Object.wait() [0x00007fbba2934000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00007fbbd0ab1048> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:485)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
- locked <0x00007fbbd0ab1048> (a java.lang.ref.Reference$Lock)
"main" prio=10 tid=0x00007fbbe8007000 nid=0x7e5d in Object.wait()
[0x00007fbbecdcf000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00007fbbd1352280> (a
org.jboss.shrinkwrap.impl.base.exporter.FutureCompletionInputStream)
at java.io.PipedInputStream.read(PipedInputStream.java:310)
- locked <0x00007fbbd1352280> (a
org.jboss.shrinkwrap.impl.base.exporter.FutureCompletionInputStream)
at
org.jboss.shrinkwrap.impl.base.exporter.FutureCompletionInputStream.read(FutureCompletionInputStream.java:82)
- locked <0x00007fbbd1352280> (a
org.jboss.shrinkwrap.impl.base.exporter.FutureCompletionInputStream)
at java.io.PipedInputStream.read(PipedInputStream.java:361)
- locked <0x00007fbbd1352280> (a
org.jboss.shrinkwrap.impl.base.exporter.FutureCompletionInputStream)
at
org.jboss.shrinkwrap.impl.base.exporter.FutureCompletionInputStream.read(FutureCompletionInputStream.java:94)
- locked <0x00007fbbd1352280> (a
org.jboss.shrinkwrap.impl.base.exporter.FutureCompletionInputStream)
at java.io.InputStream.read(InputStream.java:85)
at org.jboss.shrinkwrap.impl.base.io.IOUtil.copy(IOUtil.java:141)
at org.jboss.shrinkwrap.impl.base.io.IOUtil.copyWithClose(IOUtil.java:161)
at
org.jboss.shrinkwrap.impl.base.exporter.ZipExporterTestCase.testExportThrowsArchiveExceptionOnAssetWriteFailure(ZipExporterTestCase.java:294)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImp
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira