You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2016/09/26 15:16:23 UTC
svn commit: r1762342 -
/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceManagement.java
Author: cwiklik
Date: Mon Sep 26 15:16:23 2016
New Revision: 1762342
URL: http://svn.apache.org/viewvc?rev=1762342&view=rev
Log:
UIMA-5119 Modified to not re-throw Exceptions from stopAndQuiesce() and terminate
Modified:
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceManagement.java
Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceManagement.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceManagement.java?rev=1762342&r1=1762341&r2=1762342&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceManagement.java (original)
+++ uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceManagement.java Mon Sep 26 15:16:23 2016
@@ -25,6 +25,7 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
+import java.net.SocketException;
import java.util.HashMap;
import java.util.StringTokenizer;
@@ -77,30 +78,37 @@ public class UimacppServiceManagement im
}
synchronized public String quiesceAndStop() throws IOException {
-
- if (socket != null) {
+ StringBuffer sb = new StringBuffer();
+
+ if (socket != null && !socket.isClosed() ) {
// System.out.println("UimacppServiceManagement::quiesceAndStop()
// Sending QUIESCEANDSTOP");
-
- writer.write("QUIESCEANDSTOP");
- writer.flush();
-
- BufferedReader in = new BufferedReader(new InputStreamReader(socket
- .getInputStream()));
-
- StringBuffer sb = new StringBuffer();
- int c = in.read();
- while (c >= 0) {
- sb.append((char) c);
- c = in.read();
- if (c == '\n') {
- break;
+ try {
+ writer.write("QUIESCEANDSTOP");
+ writer.flush();
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(socket
+ .getInputStream()));
+
+ int c = in.read();
+ while (c >= 0) {
+ sb.append((char) c);
+ c = in.read();
+ if (c == '\n') {
+ break;
+ }
+ }
+ System.out.println("UimacppServiceManagement service reports QuiesceAndStop " + sb.toString());
+ return sb.toString();
+
+ } catch( SocketException e) {
+ System.out.println("UimacppServiceManagement.quiesceAndStop() - Socket is closed - unable to communicate with the process which may have terminated");
+ return "";
}
- }
- System.out.println("UimacppServiceManagement service reports QuiesceAndStop " + sb.toString());
- return sb.toString();
} else {
- throw new IOException("Error: no socket connection.");
+ // throw new IOException("Error: no socket connection.");
+ //System.out.println("UimacppServiceManagement.quiesceAndStop() - Socket already closed");
+ return "";
}
}
@@ -365,27 +373,33 @@ public class UimacppServiceManagement im
}
synchronized public void shutdown() throws IOException {
- if (this.socket != null) {
+ if (this.socket != null && !this.socket.isClosed()) {
// System.out.println("UimacppServiceManagement sending shutdown message");
- writer.write("SHUTDOWN");
- writer.flush();
- // System.out.println("UimacppServiceManagement sent shutdown message");
- BufferedReader in = new BufferedReader(new InputStreamReader(socket
- .getInputStream()));
-
- StringBuffer sb = new StringBuffer();
- int c = in.read();
- while (c >= 0) {
- sb.append((char) c);
- c = in.read();
- if (c == '\n') {
- break;
- }
- }
- System.out.println("UimacppServiceManagement service reports shutdown " + sb.toString());
- return;
+
+ try {
+ writer.write("SHUTDOWN");
+ writer.flush();
+ // System.out.println("UimacppServiceManagement sent shutdown message");
+ BufferedReader in = new BufferedReader(new InputStreamReader(socket
+ .getInputStream()));
+
+ StringBuffer sb = new StringBuffer();
+ int c = in.read();
+ while (c >= 0) {
+ sb.append((char) c);
+ c = in.read();
+ if (c == '\n') {
+ break;
+ }
+ }
+ System.out.println("UimacppServiceManagement service reports shutdown " + sb.toString());
+ return;
+
+ } catch( SocketException e) {
+ System.out.println("UimacppServiceManagement.shutdown() - Socket is closed - unable to communicate with the process which may have terminated");
+ }
} else {
- System.err.println("Error no connection");
+ //System.err.println("Error no connection");
}
}