You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've made a small patch which create two tread for reading the output and error streams of the script.
I've also changer the entryToBean method to use value.getString() instead of value.getValue() because it was incorrectly storing base64 encoded string in the entry, but maybe there is another problem elsewhere.
Index: src/main/java/org/lsc/plugins/connectors/executable/AbstractExecutableLdifService.java
===================================================================
--- src/main/java/org/lsc/plugins/connectors/executable/AbstractExecutableLdifService.java (révision 2011)
+++ src/main/java/org/lsc/plugins/connectors/executable/AbstractExecutableLdifService.java (copie de travail)
@@ -2,6 +2,7 @@
import java.io.IOException;
import java.io.OutputStream;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -133,6 +134,40 @@
//TODO: need to check for max time
LOGGER.debug("Waiting for command to stop ... ");
+ //Read stream with separate threads
+ class StreamGobbler extends Thread
+ {
+ InputStream is;
+ StringBuffer type;
+
+ StreamGobbler(InputStream is, StringBuffer type)
+ {
+ this.is = is;
+ this.type = type;
+ }
+
+ public void run()
+ {
+ try {
+ type.append(IOUtils.toString(is));
+ } catch (IOException e) {
+ // Failing to read the complete string causes null return
+ LOGGER.error("Fail to read complete data from script stream");
+ LOGGER.debug(e.toString(), e);
+ }
+ }
+ }
+
+ // any error message?
+ StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), messages);
+ // any output?
+ StreamGobbler outputGobbler = new StreamGobbler(p.getInputStream(), datas);
+
+ // starting threads.
+ errorGobbler.start();
+ outputGobbler.start();
+
+
p.waitFor();
} catch (IOException e) {
// Encountered an error while reading data from output
@@ -144,22 +179,6 @@
LOGGER.debug(e.toString(), e);
}
- try {
- datas.append(IOUtils.toString(p.getInputStream()));
- } catch (IOException e) {
- // Failing to read the complete string causes null return
- LOGGER.error("Fail to read complete data from script output stream: {}", runtime);
- LOGGER.debug(e.toString(), e);
- }
-
- try {
- messages.append(IOUtils.toString(p.getErrorStream()));
- } catch (IOException e) {
- // Failing to read the complete string causes null return
- LOGGER.error("Fail to read complete messages from script stderr stream: {}", runtime);
- LOGGER.debug(e.toString(), e);
- }
-
if (p.exitValue() != 0) {
// A non zero value causes null return
LOGGER.error("Non zero exit code for runtime: {}, exit code={}", runtime[0], p.exitValue());
@@ -252,7 +271,7 @@
String attributeId = attribute.getId().toLowerCase();
HashSet<Object> values = new HashSet<Object>();
for (Value<?> value: attribute) {
- values.add(value.getValue());
+ values.add(value.getString());
}
bean.setDataset(attributeId, values);
}
The text was updated successfully, but these errors were encountered:
From http://tools.lsc-project.org/issues/716
The text was updated successfully, but these errors were encountered: