mirror of https://github.com/apache/jclouds.git
Fix a few Coverity defects
This commit is contained in:
parent
83d10e8194
commit
46759f8bda
|
@ -281,7 +281,7 @@ public class Capacity implements Comparable<Capacity> {
|
|||
public int compareTo(Capacity other) {
|
||||
int comparison = this.zoneId.compareTo(other.zoneId);
|
||||
if (comparison == 0) comparison = this.podId.compareTo(other.podId);
|
||||
if (comparison == 0) Integer.valueOf(this.type.code).compareTo(other.type.code);
|
||||
if (comparison == 0) comparison = Integer.valueOf(this.type.code).compareTo(other.type.code);
|
||||
return comparison;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ import com.google.common.collect.Iterables;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.common.net.HttpHeaders;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
@ -758,7 +759,13 @@ public class RegionScopedSwiftBlobStore implements BlobStore {
|
|||
SwiftObject object = api.getObjectApi(regionId, containerName)
|
||||
.get(objectName, org.jclouds.http.options.GetOptions.Builder.range(begin, end));
|
||||
// Download first, this is the part that usually fails
|
||||
byte[] targetArray = ByteStreams.toByteArray(object.getPayload().openStream());
|
||||
byte[] targetArray;
|
||||
InputStream is = object.getPayload().openStream();
|
||||
try {
|
||||
targetArray = ByteStreams.toByteArray(is);
|
||||
} finally {
|
||||
Closeables.closeQuietly(is);
|
||||
}
|
||||
// Map file region
|
||||
MappedByteBuffer out = raf.getChannel().map(FileChannel.MapMode.READ_WRITE, begin, end - begin + 1);
|
||||
out.put(targetArray);
|
||||
|
@ -898,7 +905,13 @@ public class RegionScopedSwiftBlobStore implements BlobStore {
|
|||
long time = System.nanoTime();
|
||||
SwiftObject object = api.getObjectApi(regionId, containerName)
|
||||
.get(objectName, org.jclouds.http.options.GetOptions.Builder.range(begin, end));
|
||||
byte[] downloadedBlock = ByteStreams.toByteArray(object.getPayload().openStream());
|
||||
byte[] downloadedBlock;
|
||||
InputStream is = object.getPayload().openStream();
|
||||
try {
|
||||
downloadedBlock = ByteStreams.toByteArray(is);
|
||||
} finally {
|
||||
Closeables.closeQuietly(is);
|
||||
}
|
||||
return downloadedBlock;
|
||||
} catch (IOException e) {
|
||||
logger.debug(e.toString());
|
||||
|
|
|
@ -24,6 +24,7 @@ import static org.jclouds.util.Maps2.transformKeys;
|
|||
import static org.jclouds.util.Predicates2.startsWith;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
@ -107,7 +108,7 @@ public class ReadAnnotationsAndProperties implements InvocationConfig {
|
|||
});
|
||||
return transformKeys(longsByName, new Function<String, String>() {
|
||||
public String apply(String input) {
|
||||
return input.replaceFirst(PROPERTY_TIMEOUTS_PREFIX, "");
|
||||
return input.replaceFirst(Pattern.quote(PROPERTY_TIMEOUTS_PREFIX), "");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ public class JschSshClient implements SshClient {
|
|||
try {
|
||||
sftp.put(is, path);
|
||||
} finally {
|
||||
Closeables2.closeQuietly(contents);
|
||||
Closeables2.closeQuietly(is);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ParseToResumableUpload implements Function<HttpResponse, ResumableU
|
|||
}
|
||||
}
|
||||
|
||||
return ResumableUpload.create(response.getStatusCode(), uploadId, contentLength, upperLimit, lowerLimit);
|
||||
return ResumableUpload.create(response.getStatusCode(), uploadId, contentLength, lowerLimit, upperLimit);
|
||||
}
|
||||
|
||||
// Return the Id of the Upload
|
||||
|
|
|
@ -137,7 +137,7 @@ public class ResponseStatusFromPayloadHttpCommandExecutorService extends JavaUrl
|
|||
char[] chars = new char[size];
|
||||
byte[] bytes = new byte[size];
|
||||
|
||||
is.read(bytes, 0, size);
|
||||
ByteStreams.readFully(is, bytes);
|
||||
for (int i = 0; i < size;)
|
||||
chars[i] = (char) (bytes[i++] & 0xff);
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ public class SoftLayerComputeServiceAdapter implements
|
|||
} else {
|
||||
VirtualGuestBlockDeviceTemplateGroup blockDeviceTemplateGroup = VirtualGuestBlockDeviceTemplateGroup
|
||||
.builder().globalIdentifier(imageId).build();
|
||||
virtualGuestBuilder.blockDeviceTemplateGroup(blockDeviceTemplateGroup).build();
|
||||
virtualGuestBuilder.blockDeviceTemplateGroup(blockDeviceTemplateGroup);
|
||||
}
|
||||
// set multi-disks
|
||||
if (!templateOptions.getBlockDevices().isEmpty()) {
|
||||
|
|
Loading…
Reference in New Issue