Author: degenaro
Date: Thu Nov 12 13:53:40 2015
New Revision: 1714046

URL: http://svn.apache.org/viewvc?rev=1714046&view=rev
Log:
UIMA-4690 fix Crypto

Added:
    
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/RuntimeStreamsConsumer.java
   (with props)
Modified:
    
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/crypto/Crypto.java

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/RuntimeStreamsConsumer.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/RuntimeStreamsConsumer.java?rev=1714046&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/RuntimeStreamsConsumer.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/RuntimeStreamsConsumer.java
 Thu Nov 12 13:53:40 2015
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.uima.ducc.common;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+
+public class RuntimeStreamsConsumer extends Thread {
+       InputStream is;
+       PrintStream os;
+
+       public RuntimeStreamsConsumer(InputStream is, PrintStream os) {
+               this.is = is;
+               this.os = os;
+       }
+
+       public void run() {
+               try {
+                       int c;
+                       while ((c = is.read()) != -1)
+                               os.print((char) c);
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+}

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/RuntimeStreamsConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/RuntimeStreamsConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/crypto/Crypto.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/crypto/Crypto.java?rev=1714046&r1=1714045&r2=1714046&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/crypto/Crypto.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/crypto/Crypto.java
 Thu Nov 12 13:53:40 2015
@@ -43,6 +43,7 @@ import java.security.spec.RSAPublicKeySp
 
 import javax.crypto.Cipher;
 
+import org.apache.uima.ducc.common.RuntimeStreamsConsumer;
 import org.apache.uima.ducc.common.utils.AlienFile;
 
 public class Crypto implements ICrypto {
@@ -182,7 +183,13 @@ public class Crypto implements ICrypto {
                try {
                        Process process;
                        process = Runtime.getRuntime().exec(cmd);
+                       RuntimeStreamsConsumer errConsumer = new 
RuntimeStreamsConsumer(process.getErrorStream(), System.err);
+                       RuntimeStreamsConsumer outConsumer = new 
RuntimeStreamsConsumer(process.getErrorStream(), System.out);
+                       errConsumer.start();
+                       outConsumer.start();
                        process.waitFor();
+                       errConsumer.join();
+                       outConsumer.join();
                }
                catch(Exception e) {
                        throw new CryptoException(e);


Reply via email to