Navigation Menu

Skip to content

Commit

Permalink
Don't make a copy of the buffer, as it may shrink down to one elemnent.
Browse files Browse the repository at this point in the history
Also, use a bufferedoutputstream.
  • Loading branch information
jghoman committed Jul 28, 2012
1 parent 36bd7f1 commit 40a3d99
Showing 1 changed file with 5 additions and 4 deletions.
Expand Up @@ -16,6 +16,7 @@

package voldemort.store.readonly.fetcher;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
Expand Down Expand Up @@ -200,16 +201,16 @@ private void copyFileWithCheckSum(FileSystem fs,
OutputStream output = null;
try {
input = fs.open(source);
output = new FileOutputStream(dest);
output = new BufferedOutputStream(new FileOutputStream(dest));
byte[] buffer = new byte[bufferSize];
while(true) {
int read = input.read(buffer);
if(read < 0) {
break;
} else if(read < bufferSize) {
buffer = ByteUtils.copy(buffer, 0, read);
} else {
output.write(buffer, 0, read);
}
output.write(buffer);

if(fileCheckSumGenerator != null)
fileCheckSumGenerator.update(buffer);
if(throttler != null)
Expand Down

0 comments on commit 40a3d99

Please sign in to comment.