Originally created by: akarc... (code.google.com)@gmail.com
Seems that size and limit are distinct terms, and mixed here. I once try to pipe with three arguments(ie, with out the limit), but i think of that a 100MB post in garbage can be nicely stoped, without further flood into the application code. However, that introduce a new startup argument "limit".
Query.java Line: 160
<if (Deploy.pipe(input, out, size, size) > 0)
>if (Deploy.pipe(input, out, size, limit) > 0)
By the way, Deploy.java, method pipe(,,,,), i move the line "total += read;" a few lines up, before the limit check.
And wondering if byte[] data, can be promoted to as class level private static buffer, performance better?
public static int pipe(InputStream in, OutputStream out, int length,
int limit) throws IOException {
byte[] data = new byte[length];
int total = 0, read = in.read(data);
while (read > -1) {
total += read;
if (limit > 0 && total > limit) {
throw new IOException("Max allowed bytes read. (" + limit + ")");
}
out.write(data, 0, read);
read = in.read(data);
}
return total;
}
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: marc.la... (code.google.com)@gmail.com
I will fix the parameters in next release, they need to be redone anyways. As for static byte array it's not possible since multiple threads are using this method at the same time. Also I don't think there would be any performance advantage. NIO2 might introduce a way to pipe a file buffer directly to a network buffer and then rupy file transfers will fly!