Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McDuff2008-11-02 20:44:31 -0500
committerSimon McDuff2008-11-02 20:44:31 -0500
commitde129c29c1aaebc80f4914522586874158354909 (patch)
treef7a783ac5924b6614d6ddde17f188b2233d54b8a
parentae3b7dec3b6909d34aa086fcfcc5525175b7e066 (diff)
downloadcdo-de129c29c1aaebc80f4914522586874158354909.tar.gz
cdo-de129c29c1aaebc80f4914522586874158354909.tar.xz
cdo-de129c29c1aaebc80f4914522586874158354909.zip
[253010] [Query] Query should use the new exception handling
https://bugs.eclipse.org/bugs/show_bug.cgi?id=253010
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocolConstants.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java52
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java30
3 files changed, 24 insertions, 73 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocolConstants.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocolConstants.java
index 04aec714a1..a5dc508822 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocolConstants.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocolConstants.java
@@ -130,21 +130,6 @@ public interface CDOProtocolConstants
/**
* @since 2.0
*/
- public static final byte QUERY_MORE_OBJECT = 1;
-
- /**
- * @since 2.0
- */
- public static final byte QUERY_DONE = 2;
-
- /**
- * @since 2.0
- */
- public static final byte QUERY_EXCEPTION = 3;
-
- /**
- * @since 2.0
- */
public static final String QUERY_LANGUAGE_RESOURCES = "resources";
/**
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java
index 6c7e126345..bddd8f7ec0 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java
@@ -52,46 +52,32 @@ public class QueryIndication extends CDOReadIndication
@Override
protected void responding(CDODataOutput out) throws IOException
{
- try
- {
- int numberOfResults = 0;
-
- // Return queryID immediately.
- out.writeInt(queryResult.getQueryID());
- flush();
+ int numberOfResults = 0;
- while (queryResult.hasNext())
- {
- Object object = queryResult.next();
+ // Return queryID immediately.
+ out.writeInt(queryResult.getQueryID());
+ flush();
- // Object to return
- numberOfResults++;
- out.writeByte(CDOProtocolConstants.QUERY_MORE_OBJECT);
- out.writeCDORevisionOrPrimitive(object);
- if (queryResult.peek() == null)
- {
- flush();
- }
- }
+ while (queryResult.hasNext())
+ {
+ Object object = queryResult.next();
- if (TRACER.isEnabled())
+ // Object to return
+ numberOfResults++;
+ out.writeBoolean(true);
+ out.writeCDORevisionOrPrimitive(object);
+ if (queryResult.peek() == null)
{
- TRACER.trace("Query had " + numberOfResults + " objects return");
+ flush();
}
-
- // Query is done successfully
- out.writeByte(CDOProtocolConstants.QUERY_DONE);
}
- catch (Exception exception)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace(exception);
- }
- // Exception occured during the query
- out.writeByte(CDOProtocolConstants.QUERY_EXCEPTION);
- out.writeString(getMessage(exception));
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Query had " + numberOfResults + " objects return");
}
+
+ // Query is done successfully
+ out.writeBoolean(false);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java
index bbd85a05c9..542bd18d8b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java
@@ -20,7 +20,6 @@ import org.eclipse.emf.cdo.internal.common.query.CDOQueryInfoImpl;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.query.CDOAbstractQueryIteratorImpl;
-import org.eclipse.net4j.util.io.IORuntimeException;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.io.IOException;
@@ -65,31 +64,12 @@ public class QueryRequest extends CDOClientRequest<Object>
try
{
int numberOfObjectsReceived = 0;
- while (true)
+ while (in.readBoolean())
{
- byte state = in.readByte();
- if (state == CDOProtocolConstants.QUERY_MORE_OBJECT)
- {
- // result
- Object element = in.readCDORevisionOrPrimitive();
- resultQueue.add(element);
- numberOfObjectsReceived++;
- }
- else if (state == CDOProtocolConstants.QUERY_DONE)
- {
- // End of result
- break;
- }
- else if (state == CDOProtocolConstants.QUERY_EXCEPTION)
- {
- // Exception on the server
- String exceptionString = in.readString();
- throw new IORuntimeException(exceptionString);
- }
- else
- {
- throw new IORuntimeException("Illegal state: " + state);
- }
+ // result
+ Object element = in.readCDORevisionOrPrimitive();
+ resultQueue.add(element);
+ numberOfObjectsReceived++;
}
if (PROTOCOL_TRACER.isEnabled())

Back to the top