Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit50aeda0

Browse files
committed
File part is missing from transferred bytes sum,closeAsyncHttpClient#1126
1 parent5b51e2e commit50aeda0

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

‎src/main/java/com/ning/http/client/multipart/FilePart.java‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,21 @@ public long write(WritableByteChannel target, byte[] boundary) throws IOExceptio
108108
RandomAccessFileraf =newRandomAccessFile(file,"r");
109109
FileChannelfc =raf.getChannel();
110110

111-
longl =file.length();
112-
intfileLength =0;
113-
longnWrite =0;
111+
longactualFileLength =file.length();
112+
longtransferredFileBytes =0;
114113
// FIXME why sync?
115114
try {
116115
synchronized (fc) {
117-
while (fileLength !=l) {
116+
while (transferredFileBytes !=actualFileLength) {
117+
longwritten =0;
118+
118119
if (handler.isFailed()) {
119120
LOGGER.debug("Stalled error");
120121
thrownewFileUploadStalledException();
121122
}
122123
try {
123-
nWrite =fc.transferTo(fileLength,l,target);
124-
125-
if (nWrite ==0) {
124+
written =fc.transferTo(transferredFileBytes,actualFileLength,target);
125+
if (written ==0) {
126126
LOGGER.info("Waiting for writing...");
127127
try {
128128
fc.wait(50);
@@ -148,14 +148,15 @@ public long write(WritableByteChannel target, byte[] boundary) throws IOExceptio
148148
throwex;
149149
}
150150
}
151-
fileLength +=nWrite;
151+
transferredFileBytes +=written;
152152
}
153153
}
154154
}finally {
155155
handler.completed();
156156
raf.close();
157157
}
158158

159+
length +=transferredFileBytes;
159160
length +=MultipartUtils.writeBytesToChannel(target,generateFileEnd());
160161

161162
returnlength;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public byte[] getBoundary() {
7777
publiclongtransferTo(longposition,WritableByteChanneltarget)throwsIOException {
7878

7979
if (transfertDone) {
80-
return -1;
80+
thrownewUnsupportedOperationException("Transfer is already done");
8181
}
8282

8383
longoverallLength =0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp