mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 12994: fix IndexOutOfBoundsException problem in VMDK upload
This commit is contained in:
parent
bcd58e3ae3
commit
c89f6e2936
@ -335,15 +335,14 @@ public class VmwareContext {
|
|||||||
try {
|
try {
|
||||||
bos = new BufferedOutputStream(conn.getOutputStream());
|
bos = new BufferedOutputStream(conn.getOutputStream());
|
||||||
is = new BufferedInputStream(new FileInputStream(localFileName));
|
is = new BufferedInputStream(new FileInputStream(localFileName));
|
||||||
int bytesAvailable = is.available();
|
int bufferSize = _CHUNKSIZE;
|
||||||
int bufferSize = Math.min(bytesAvailable, _CHUNKSIZE);
|
|
||||||
byte[] buffer = new byte[bufferSize];
|
byte[] buffer = new byte[bufferSize];
|
||||||
while (true) {
|
while (true) {
|
||||||
int bytesRead = is.read(buffer, 0, bufferSize);
|
int bytesRead = is.read(buffer, 0, bufferSize);
|
||||||
if (bytesRead == -1) {
|
if (bytesRead == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bos.write(buffer, 0, bufferSize);
|
bos.write(buffer, 0, bytesRead);
|
||||||
totalBytesUpdated += bytesRead;
|
totalBytesUpdated += bytesRead;
|
||||||
bos.flush();
|
bos.flush();
|
||||||
if(progressUpdater != null)
|
if(progressUpdater != null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user