Skip to content

Commit 9619304

Browse files
author
Ross Mellgren
committed
fix AsyncHttpClient#173 by returning -1 on EOF, not 0
1 parent dd798e0 commit 9619304

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main/java/com/ning/http/multipart/MultipartBody.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public long read(ByteBuffer buffer) throws IOException {
8080
int maxLength = buffer.capacity();
8181

8282
if (startPart == parts.size() && endWritten) {
83-
return overallLength;
83+
return -1;
8484
}
8585

8686
boolean full = false;
@@ -437,9 +437,9 @@ private ByteArrayOutputStream generateFileStart(FilePart filePart)
437437
private long handleFilePart(WritableByteChannel target, FilePart filePart) throws IOException {
438438
FilePartStallHandler handler = new FilePartStallHandler(
439439
filePart.getStalledTime(), filePart);
440-
440+
441441
handler.start();
442-
442+
443443
if (FilePartSource.class.isAssignableFrom(filePart.getSource().getClass())) {
444444
int length = 0;
445445

@@ -464,7 +464,7 @@ private long handleFilePart(WritableByteChannel target, FilePart filePart) throw
464464
}
465465
try {
466466
nWrite = fc.transferTo(fileLength, l, target);
467-
467+
468468
if (nWrite == 0) {
469469
logger.info("Waiting for writing...");
470470
try {
@@ -496,7 +496,7 @@ private long handleFilePart(WritableByteChannel target, FilePart filePart) throw
496496
}
497497
}
498498
handler.completed();
499-
499+
500500
fc.close();
501501

502502
length += handleFileEnd(target, filePart);
@@ -556,7 +556,7 @@ private long handleMultiPart(WritableByteChannel target, Part currentPart) throw
556556
return handleStringPart(target, (StringPart) currentPart);
557557
} else if (currentPart.getClass().equals(FilePart.class)) {
558558
FilePart filePart = (FilePart) currentPart;
559-
559+
560560
return handleFilePart(target, filePart);
561561
}
562562
return 0;

0 commit comments

Comments
 (0)