Changeset: e2fd07352866 for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java/rev/e2fd07352866
Modified Files:
src/main/java/org/monetdb/merovingian/Control.java
Branch: default
Log Message:
Fix Control protocol handling
(contributed by Wouter Alink)
diffs (66 lines):
diff --git a/src/main/java/org/monetdb/merovingian/Control.java
b/src/main/java/org/monetdb/merovingian/Control.java
--- a/src/main/java/org/monetdb/merovingian/Control.java
+++ b/src/main/java/org/monetdb/merovingian/Control.java
@@ -183,7 +183,7 @@ public class Control {
throw new MerovingianException("server
closed the connection");
}
- if (!response.equals(RESPONSE_OK)) {
+ if (!response.substring(1).equals(RESPONSE_OK))
{
throw new
MerovingianException(response);
}
@@ -197,7 +197,7 @@ public class Control {
if (response == null) {
throw new MerovingianException("server
closed the connection");
}
- if (!response.equals(RESPONSE_OK)) {
+ if (!response.substring(1).equals(RESPONSE_OK))
{
throw new
MerovingianException(response);
}
@@ -220,23 +220,32 @@ public class Control {
ArrayList<String> l = new ArrayList<String>();
String tmpLine = min.readLine();
LineType linetype = min.getLineType();
- if (linetype == LineType.ERROR)
+ switch (linetype) {
+ case ERROR:
throw new MerovingianException(tmpLine.substring(6));
- if (linetype != LineType.RESULT)
+ case RESULT:
+ if (!tmpLine.substring(1).equals(RESPONSE_OK))
+ throw new MerovingianException(tmpLine);
+ break;
+ default:
throw new MerovingianException("unexpected line: " +
tmpLine);
- if (!tmpLine.substring(1).equals(RESPONSE_OK))
- throw new MerovingianException(tmpLine.substring(1));
- tmpLine = min.readLine();
- linetype = min.getLineType();
- while (linetype != LineType.PROMPT) {
- if (linetype != LineType.RESULT)
- throw new MerovingianException("unexpected
line: " +
- tmpLine);
+ }
- l.add(tmpLine.substring(1));
-
+ boolean hasPrompt = false;
+ while (!hasPrompt) {
tmpLine = min.readLine();
linetype = min.getLineType();
+
+ switch (linetype) {
+ case PROMPT:
+ hasPrompt = true;
+ break;
+ case RESULT:
+ l.add(tmpLine.substring(1));
+ break;
+ default:
+ throw new MerovingianException("unexpected
line: " + tmpLine);
+ }
}
ms.close();
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list