Skip to content

Commit

Permalink
yegor256#575 implement close and skip method on CapinputStream
Browse files Browse the repository at this point in the history
  • Loading branch information
original-brownbear committed Mar 1, 2016
1 parent b2ee751 commit 3b35a7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/takes/rq/CapInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,14 @@ public int read(final byte[] buf, final int off,
}
return readed;
}

@Override
public long skip(final long num) throws IOException {
return this.origin.skip(num);
}

@Override
public void close() throws IOException {
this.origin.close();
}
}
20 changes: 6 additions & 14 deletions src/main/java/org/takes/rq/RqMultipart.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,12 @@ final class Base extends RqWrap implements RqMultipart {
public Base(final Request req) throws IOException {
super(req);
final InputStream stream = new RqLengthAware(req).body();
try {
this.body = Channels.newChannel(stream);
try {
this.buffer = ByteBuffer.allocate(
// @checkstyle MagicNumberCheck (1 line)
Math.min(8192, stream.available())
);
this.map = this.requests(req);
} finally {
this.body.close();
}
} finally {
stream.close();
}
this.body = Channels.newChannel(stream);
this.buffer = ByteBuffer.allocate(
// @checkstyle MagicNumberCheck (1 line)
Math.min(8192, stream.available())
);
this.map = this.requests(req);
}
@Override
public Iterable<Request> part(final CharSequence name) {
Expand Down

0 comments on commit 3b35a7f

Please sign in to comment.