Fixed two coverity reported issues

Dereference after null check
Dm: Dubious method used

This closes #219
This commit is contained in:
Rajani Karuturi 2015-05-01 14:39:59 +05:30
parent 3100fc1554
commit bd71fcb650
2 changed files with 4 additions and 6 deletions

View File

@ -325,10 +325,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
// set the post url, this is used in the monitoring thread to determine the SSVM
VolumeDataStoreVO volumeStore = _volumeStoreDao.findByVolume(vol.getId());
if (volumeStore != null) {
volumeStore.setExtractUrl(url);
_volumeStoreDao.persist(volumeStore);
}
assert (volumeStore != null) : "sincle volume is registered, volumestore cannot be null at this stage";
volumeStore.setExtractUrl(url);
_volumeStoreDao.persist(volumeStore);
response.setId(UUID.fromString(vol.getUuid()));

View File

@ -19,7 +19,6 @@
package com.cloud.utils;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
@ -63,7 +62,7 @@ public class EncryptionUtil {
final Mac mac = Mac.getInstance("HmacSHA1");
final SecretKeySpec keySpec = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA1");
mac.init(keySpec);
mac.update(data.getBytes(Charset.defaultCharset()));
mac.update(data.getBytes("UTF-8"));
final byte[] encryptedBytes = mac.doFinal();
return Base64.encodeBase64String(encryptedBytes);
} catch (NoSuchAlgorithmException | InvalidKeyException | UnsupportedEncodingException e) {