Skip to content

Commit a68e9a0

Browse files
committed
Fix indentation
1 parent 78f9a3c commit a68e9a0

File tree

1 file changed

+51
-52
lines changed

1 file changed

+51
-52
lines changed

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

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,11 @@ private ByteArrayOutputStream generateFileStart(FilePart filePart)
435435
}
436436

437437
private long handleFilePart(WritableByteChannel target, FilePart filePart) throws IOException {
438-
FilePartStallHandler handler = new FilePartStallHandler(
439-
filePart.getStalledTime(), filePart);
440-
441-
handler.start();
442-
438+
FilePartStallHandler handler = new FilePartStallHandler(
439+
filePart.getStalledTime(), filePart);
440+
441+
handler.start();
442+
443443
if (FilePartSource.class.isAssignableFrom(filePart.getSource().getClass())) {
444444
int length = 0;
445445

@@ -458,23 +458,22 @@ private long handleFilePart(WritableByteChannel target, FilePart filePart) throw
458458
long nWrite = 0;
459459
synchronized (fc) {
460460
while (fileLength != l) {
461-
if(handler.isFailed()) {
462-
logger.debug("Stalled error");
461+
if (handler.isFailed()) {
462+
logger.debug("Stalled error");
463463
throw new FileUploadStalledException();
464-
}
464+
}
465465
try {
466466
nWrite = fc.transferTo(fileLength, l, target);
467-
467+
468468
if (nWrite == 0) {
469469
logger.info("Waiting for writing...");
470470
try {
471471
fc.wait(50);
472472
} catch (InterruptedException e) {
473473
logger.trace(e.getMessage(), e);
474474
}
475-
}
476-
else {
477-
handler.writeHappened();
475+
} else {
476+
handler.writeHappened();
478477
}
479478
} catch (IOException ex) {
480479
String message = ex.getMessage();
@@ -496,7 +495,7 @@ private long handleFilePart(WritableByteChannel target, FilePart filePart) throw
496495
}
497496
}
498497
handler.completed();
499-
498+
500499
fc.close();
501500

502501
length += handleFileEnd(target, filePart);
@@ -556,7 +555,7 @@ private long handleMultiPart(WritableByteChannel target, Part currentPart) throw
556555
return handleStringPart(target, (StringPart) currentPart);
557556
} else if (currentPart.getClass().equals(FilePart.class)) {
558557
FilePart filePart = (FilePart) currentPart;
559-
558+
560559
return handleFilePart(target, filePart);
561560
}
562561
return 0;
@@ -571,45 +570,45 @@ private long writeToTarget(WritableByteChannel target, ByteArrayOutputStream byt
571570
ByteBuffer message = ByteBuffer.wrap(byteWriter.toByteArray());
572571

573572
if (target instanceof SocketChannel) {
574-
final Selector selector = Selector.open();
575-
try {
576-
final SocketChannel channel = (SocketChannel) target;
577-
channel.register(selector, SelectionKey.OP_WRITE);
578-
579-
while(written < byteWriter.size() && selector.select() != 0) {
580-
final Set<SelectionKey> selectedKeys = selector.selectedKeys();
581-
582-
for (SelectionKey key : selectedKeys) {
583-
if (key.isWritable()) {
584-
written += target.write(message);
585-
}
586-
}
587-
}
588-
589-
if (written < byteWriter.size()) {
590-
throw new IOException("Unable to write on channel " + target);
591-
}
592-
} finally {
593-
selector.close();
594-
}
573+
final Selector selector = Selector.open();
574+
try {
575+
final SocketChannel channel = (SocketChannel) target;
576+
channel.register(selector, SelectionKey.OP_WRITE);
577+
578+
while (written < byteWriter.size() && selector.select() != 0) {
579+
final Set<SelectionKey> selectedKeys = selector.selectedKeys();
580+
581+
for (SelectionKey key : selectedKeys) {
582+
if (key.isWritable()) {
583+
written += target.write(message);
584+
}
585+
}
586+
}
587+
588+
if (written < byteWriter.size()) {
589+
throw new IOException("Unable to write on channel " + target);
590+
}
591+
} finally {
592+
selector.close();
593+
}
595594
} else {
596-
while ((target.isOpen()) && (written < byteWriter.size())) {
597-
long nWrite = target.write(message);
598-
written += nWrite;
599-
if (nWrite == 0 && maxSpin++ < 10) {
600-
logger.info("Waiting for writing...");
601-
try {
602-
byteWriter.wait(1000);
603-
} catch (InterruptedException e) {
604-
logger.trace(e.getMessage(), e);
605-
}
606-
} else {
607-
if (maxSpin >= 10) {
608-
throw new IOException("Unable to write on channel " + target);
609-
}
610-
maxSpin = 0;
611-
}
612-
}
595+
while ((target.isOpen()) && (written < byteWriter.size())) {
596+
long nWrite = target.write(message);
597+
written += nWrite;
598+
if (nWrite == 0 && maxSpin++ < 10) {
599+
logger.info("Waiting for writing...");
600+
try {
601+
byteWriter.wait(1000);
602+
} catch (InterruptedException e) {
603+
logger.trace(e.getMessage(), e);
604+
}
605+
} else {
606+
if (maxSpin >= 10) {
607+
throw new IOException("Unable to write on channel " + target);
608+
}
609+
maxSpin = 0;
610+
}
611+
}
613612
}
614613
}
615614
return written;

0 commit comments

Comments
 (0)