• R/O
  • SSH
  • HTTPS

exewrap: Commit


Commit MetaInfo

Revision33 (tree)
Time2017-02-01 21:14:59
Authorhirukawa_ryo

Log Message

* 1.1.5 Pack200圧縮処理で無限ループに陥って復帰しなくなることがあるバグを修正しました。

Change Summary

Incremental Difference

--- exewrap/trunk/exewrap/src/java/exewrap/tool/PackOutputStream.java (revision 32)
+++ exewrap/trunk/exewrap/src/java/exewrap/tool/PackOutputStream.java (revision 33)
@@ -6,6 +6,7 @@
66 import java.io.PipedOutputStream;
77 import java.lang.reflect.InvocationTargetException;
88 import java.lang.reflect.Method;
9+import java.util.concurrent.CountDownLatch;
910 import java.util.jar.JarInputStream;
1011 import java.util.jar.Pack200;
1112
@@ -17,7 +18,8 @@
1718 private PipedInputStream pipeIn;
1819 private IOException exception;
1920 private volatile boolean isPackCompleted = false;
20- private volatile boolean isOutputStreamClosed = false;
21+ private CountDownLatch initLatch = new CountDownLatch(1);
22+ private CountDownLatch doneLatch = new CountDownLatch(1);
2123
2224 public PackOutputStream(OutputStream out) {
2325 this.out = out;
@@ -26,9 +28,7 @@
2628 public void run() {
2729 try {
2830 pipeIn = new PipedInputStream(this.pipeOut, PIPE_SIZE);
29- synchronized(this) {
30- notifyAll();
31- }
31+ initLatch.countDown();
3232 JarInputStream jarIn = new JarInputStream(pipeIn);
3333 Pack200.newPacker().pack(jarIn, this.out);
3434 isPackCompleted = true;
@@ -39,22 +39,18 @@
3939 if(this.exception == null) {
4040 this.exception = e;
4141 }
42+ } finally {
43+ doneLatch.countDown();
4244 }
43- synchronized (this) {
44- this.isOutputStreamClosed = true;
45- synchronized(this.pipeOut) {
46- notifyAll();
47- }
48- }
4945 }
5046
5147 private void init() throws IOException {
5248 this.pipeOut = new PipedOutputStream();
5349
54- synchronized(this) {
55- new Thread(this).start();
56- try { wait(); } catch (InterruptedException e) {}
57- }
50+ new Thread(this).start();
51+ try {
52+ initLatch.await();
53+ } catch (InterruptedException e) {}
5854 }
5955
6056 @Override
@@ -123,16 +119,11 @@
123119 if(this.pipeOut == null) {
124120 init();
125121 }
126- while(pipeIn.available() > 0) {
127- Thread.yield();
128- }
129122 this.pipeOut.close();
130-
131- synchronized(this) {
132- if(!isOutputStreamClosed) {
133- try { wait(); } catch (InterruptedException e) {}
134- }
135- }
123+
124+ try {
125+ doneLatch.await();
126+ } catch (InterruptedException e1) {}
136127 }
137128
138129 private static boolean finish(OutputStream out) {
--- exewrap/trunk/exewrap/src/exewrap.c (revision 32)
+++ exewrap/trunk/exewrap/src/exewrap.c (revision 33)
@@ -85,7 +85,7 @@
8585
8686 is_trace_version = strstr(exe_file, "trace") != NULL;
8787
88- printf("exewrap 1.1.4 for %s (%d-bit) %s\r\n"
88+ printf("exewrap 1.1.5 for %s (%d-bit) %s\r\n"
8989 "Native executable java application wrapper.\r\n"
9090 "Copyright (C) 2005-2017 HIRUKAWA Ryo. All rights reserved.\r\n"
9191 "\r\n"
Show on old repository browser