Skip to content

Commit 8aec44d

Browse files
author
ehennum
committed
better diagnostic messages for invalid state #1258
1 parent c40dc76 commit 8aec44d

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

marklogic-client-api/src/main/java/com/marklogic/client/dataservices/impl/IOEndpointImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ boolean checkQueue(BlockingQueue<I> queue, int batchSize) {
311311
case INTERRUPTED:
312312
case COMPLETED:
313313
throw new IllegalStateException(
314-
"cannot accept more input as current phase is " + getPhase().name()
315-
);
314+
"can only accept input when initializing or running and not when input is "+
315+
getPhase().name().toLowerCase());
316316
default:
317317
throw new MarkLogicInternalException(
318318
"unexpected state for " + callContext.getEndpoint().getEndpointPath() + " during loop: " + getPhase().name());

marklogic-client-api/src/main/java/com/marklogic/client/dataservices/impl/OutputEndpointImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ public void awaitCompletion() {
151151
if (getOutputListener() == null)
152152
throw new IllegalStateException("Output consumer is null");
153153

154-
if(getPhase() != WorkPhase.INITIALIZING) {
154+
if (getPhase() != WorkPhase.INITIALIZING) {
155155
throw new IllegalStateException(
156-
"Cannot process output since current phase is " + getPhase().name());
156+
"Can only await completion when starting output and not while output is "+
157+
getPhase().name().toLowerCase());
157158
}
158159

159160
setPhase(WorkPhase.RUNNING);

marklogic-client-api/src/test/java/com/marklogic/client/test/dataservices/BulkInputCallerTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ public void bulkInputEndpointInterruptTest() throws Exception {
125125
loader.interrupt();
126126

127127
expectedException.expect(IllegalStateException.class);
128-
expectedException.expect(new ThrowableMessageMatcher(new StringContains("cannot accept more input as current phase is INTERRUPTING")));
128+
expectedException.expect(new ThrowableMessageMatcher(new StringContains(
129+
"can only accept input when initializing or running and not when input is interrupting"
130+
)));
129131
input2.forEach(loader::accept);
130132
}
131133

0 commit comments

Comments
 (0)