Skip to content

Commit 217f66e

Browse files
committed
fix OutputToInput
1 parent 8d710be commit 217f66e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

net.lecousin.core/src/main/java/net/lecousin/framework/io/out2in/OutputToInput.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public int readSync(long pos, ByteBuffer buffer) throws IOException {
153153
if (waitForData.hasError() && !eof)
154154
throw new OutputToInputTransferException(waitForData.getError());
155155
synchronized (waitForData) {
156-
if (pos >= writePos && waitForData.isDone())
156+
if (pos >= writePos && waitForData.isSuccessful())
157157
waitForData.reset();
158158
}
159159
waitForData.block(0);
@@ -210,7 +210,7 @@ public AsyncSupplier<Integer, IOException> readAsync(long pos, ByteBuffer buffer
210210
}
211211
AsyncSupplier<Integer, IOException> result = new AsyncSupplier<>();
212212
synchronized (waitForData) {
213-
if (pos >= writePos && waitForData.isDone())
213+
if (pos >= writePos && waitForData.isSuccessful())
214214
waitForData.reset();
215215
}
216216
waitForData.thenStart(operation(
@@ -282,7 +282,7 @@ public long skipSync(long n) throws IOException {
282282
if (waitForData.hasError() && !eof)
283283
throw new OutputToInputTransferException(waitForData.getError());
284284
synchronized (waitForData) {
285-
if (readPos + n > writePos && waitForData.isDone())
285+
if (readPos + n > writePos && waitForData.isSuccessful())
286286
waitForData.reset();
287287
}
288288
waitForData.block(0);
@@ -311,9 +311,10 @@ public AsyncSupplier<Long, IOException> skipAsync(long n, Consumer<Pair<Long,IOE
311311
if (ondone != null) ondone.accept(new Pair<>(Long.valueOf(m), null));
312312
return new AsyncSupplier<>(Long.valueOf(m), null);
313313
}
314+
if (waitForData.hasError()) return IOUtil.error(waitForData.getError(), ondone);
314315
AsyncSupplier<Long, IOException> result = new AsyncSupplier<>();
315316
synchronized (waitForData) {
316-
if (readPos + n > writePos && waitForData.isDone())
317+
if (readPos + n > writePos && waitForData.isSuccessful())
317318
waitForData.reset();
318319
}
319320
waitForData.thenStart(operation(taskSyncToAsync("OutputToInput.skipAsync", result, ondone, () -> Long.valueOf(skipSync(n)))), true);
@@ -338,7 +339,7 @@ public long seekSync(SeekType type, long move) throws IOException {
338339
default: //case FROM_END:
339340
while (!eof && !waitForData.hasError()) {
340341
synchronized (waitForData) {
341-
if (!eof && waitForData.isDone())
342+
if (!eof && waitForData.isSuccessful())
342343
waitForData.reset();
343344
}
344345
waitForData.block(0);
@@ -383,7 +384,7 @@ public AsyncSupplier<Long, IOException> seekAsync(SeekType type, long move, Cons
383384
}
384385
AsyncSupplier<Long, IOException> result = new AsyncSupplier<>();
385386
synchronized (waitForData) {
386-
if (!eof && waitForData.isDone())
387+
if (!eof && waitForData.isSuccessful())
387388
waitForData.reset();
388389
}
389390
waitForData.thenStart(operation(Task.cpu("OutputToInput.seekAsync", io.getPriority(), t -> {

0 commit comments

Comments
 (0)