Skip to content

Commit

Permalink
Multiple code improvements - squid:RedundantThrowsDeclarationCheck, s…
Browse files Browse the repository at this point in the history
…quid:S1226, squid:S1213, squid:S1488, squid:S1125, squid:S1126
  • Loading branch information
George Kankava committed Jun 16, 2016
1 parent 9a7a609 commit d7e7171
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 29 deletions.
6 changes: 1 addition & 5 deletions src/main/java/io/minio/BucketRegionCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ public void remove(String bucketName) {
* Returns true if given bucket name is in the map else false.
*/
public boolean exists(String bucketName) {
if (this.regionMap.get(bucketName) == null) {
return false;
} else {
return true;
}
return this.regionMap.get(bucketName) != null;
}
}
23 changes: 10 additions & 13 deletions src/main/java/io/minio/Digest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
* Various global static functions used.
*/
class Digest {
/**
* Private constructor
*/
private Digest() {}


/**
* Returns SHA-256 hash of given string.
*/
Expand Down Expand Up @@ -95,7 +101,7 @@ public static String md5Hash(byte[] data, int length) throws NoSuchAlgorithmExce
* @param len Length of Input stream.
*/
public static String md5Hash(Object inputStream, int len)
throws IllegalArgumentException, NoSuchAlgorithmException, IOException, InsufficientDataException {
throws NoSuchAlgorithmException, IOException, InsufficientDataException {
RandomAccessFile file = null;
BufferedInputStream stream = null;
if (inputStream instanceof RandomAccessFile) {
Expand Down Expand Up @@ -139,9 +145,7 @@ public static String[] sha256md5Hashes(byte[] data) throws NoSuchAlgorithmExcept
* Returns SHA-256 and MD5 hashes for given byte array and it's length.
*/
public static String[] sha256md5Hashes(byte[] data, int length) throws NoSuchAlgorithmException {
String[] hashes = { sha256Hash(data, length), md5Hash(data, length) };

return hashes;
return new String[] { sha256Hash(data, length), md5Hash(data, length) };
}


Expand All @@ -152,7 +156,7 @@ public static String[] sha256md5Hashes(byte[] data, int length) throws NoSuchAlg
* @param len Length of Input stream.
*/
public static String[] sha256md5Hashes(Object inputStream, int len)
throws IllegalArgumentException, NoSuchAlgorithmException, IOException, InsufficientDataException {
throws NoSuchAlgorithmException, IOException, InsufficientDataException {
RandomAccessFile file = null;
BufferedInputStream stream = null;
if (inputStream instanceof RandomAccessFile) {
Expand All @@ -174,10 +178,8 @@ public static String[] sha256md5Hashes(Object inputStream, int len)
stream.reset();
}

String[] hashes = { BaseEncoding.base16().encode(sha256Digest.digest()).toLowerCase(),
return new String[] { BaseEncoding.base16().encode(sha256Digest.digest()).toLowerCase(),
BaseEncoding.base64().encode(md5Digest.digest()) };

return hashes;
}


Expand Down Expand Up @@ -242,9 +244,4 @@ private static long readBytes(int len,
} while (totalBytesRead < length);
return pos;
}

/**
* Private constructor
*/
private Digest() {}
}
20 changes: 9 additions & 11 deletions src/main/java/io/minio/MinioClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public MinioClient(String endpoint) throws InvalidEndpointException, InvalidPort
* @see #MinioClient(String endpoint, String accessKey, String secretKey, boolean secure)
* @see #MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean secure)
*/
public MinioClient(URL url) throws NullPointerException, InvalidEndpointException, InvalidPortException {
public MinioClient(URL url) throws InvalidEndpointException, InvalidPortException {
this(url.toString(), 0, null, null);
}

Expand All @@ -197,7 +197,7 @@ public MinioClient(URL url) throws NullPointerException, InvalidEndpointExceptio
* @see #MinioClient(String endpoint, String accessKey, String secretKey, boolean secure)
* @see #MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean secure)
*/
public MinioClient(HttpUrl url) throws NullPointerException, InvalidEndpointException, InvalidPortException {
public MinioClient(HttpUrl url) throws InvalidEndpointException, InvalidPortException {
this(url.toString(), 0, null, null);
}

Expand Down Expand Up @@ -253,7 +253,7 @@ public MinioClient(String endpoint, String accessKey, String secretKey)
* @see #MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean secure)
*/
public MinioClient(URL url, String accessKey, String secretKey)
throws NullPointerException, InvalidEndpointException, InvalidPortException {
throws InvalidEndpointException, InvalidPortException {
this(url.toString(), 0, accessKey, secretKey);
}

Expand All @@ -276,7 +276,7 @@ public MinioClient(URL url, String accessKey, String secretKey)
* @see #MinioClient(String endpoint, int port, String accessKey, String secretKey, boolean secure)
*/
public MinioClient(HttpUrl url, String accessKey, String secretKey)
throws NullPointerException, InvalidEndpointException, InvalidPortException {
throws InvalidEndpointException, InvalidPortException {
this(url.toString(), 0, accessKey, secretKey);
}

Expand Down Expand Up @@ -848,7 +848,7 @@ private void updateRegionCache(String bucketName)
InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException,
InternalException {
if (bucketName != null && S3_AMAZONAWS_COM.equals(this.baseUrl.host()) && this.accessKey != null
&& this.secretKey != null && BucketRegionCache.INSTANCE.exists(bucketName) == false) {
&& this.secretKey != null && !BucketRegionCache.INSTANCE.exists(bucketName)) {
Map<String,String> queryParamMap = new HashMap<>();
queryParamMap.put("location", null);

Expand Down Expand Up @@ -895,7 +895,7 @@ private void updateRegionCache(String bucketName)
*/
private String getText(XmlPullParser xpp, String location) throws XmlPullParserException {
if (xpp.getEventType() == xpp.TEXT) {
location = xpp.getText();
return xpp.getText();
}
return location;
}
Expand Down Expand Up @@ -2541,7 +2541,7 @@ public void removeIncompleteUpload(String bucketName, String objectName)
* @param n Length of bytes to skip.
*/
private void skipStream(Object inputStream, long n)
throws IllegalArgumentException, IOException, InsufficientDataException {
throws IOException, InsufficientDataException {
RandomAccessFile file = null;
BufferedInputStream stream = null;
if (inputStream instanceof RandomAccessFile) {
Expand Down Expand Up @@ -2591,9 +2591,7 @@ private static int[] calculateMultipartSize(long size)
lastPartSize = partSize;
}

int[] rv = { (int) partSize, (int) partCount, (int) lastPartSize };

return rv;
return new int[] { (int) partSize, (int) partCount, (int) lastPartSize };
}


Expand All @@ -2604,7 +2602,7 @@ private static int[] calculateMultipartSize(long size)
*
* @see #traceOff
*/
public void traceOn(OutputStream traceStream) throws NullPointerException {
public void traceOn(OutputStream traceStream) {
if (traceStream == null) {
throw new NullPointerException();
} else {
Expand Down

0 comments on commit d7e7171

Please sign in to comment.