Skip to content

Commit f997f20

Browse files
committed
General code cleanup.
1 parent 651e8d3 commit f997f20

22 files changed

+42
-49
lines changed

ds3-sdk/src/main/java/com/spectralogic/ds3client/ConnectionDetailsImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static ConnectionDetails newForNode(final JobNode node, final ConnectionD
107107

108108
private static String buildAuthority(final JobNode node, final ConnectionDetails connectionDetails) {
109109
return node.getEndPoint() + ":" + Integer.toString(
110-
(connectionDetails.isHttps() ? node.getHttpsPort() : node.getHttpPort()));
110+
connectionDetails.isHttps() ? node.getHttpsPort() : node.getHttpPort());
111111
}
112112

113113
private final String endpoint;

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/interfaces/AbstractResponse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public AbstractResponse(final WebResponse response) throws IOException {
5858
this.processResponse();
5959
}
6060

61-
private static ChecksumType.Type determineChecksumType(final Headers headers) throws ResponseProcessingException {
61+
private static ChecksumType.Type determineChecksumType(final Headers headers) {
6262
for (final ChecksumType.Type type : ChecksumType.Type.values()) {
6363
if (getFirstHeaderValue(headers, "content-" + type.toString().replace("_", "").toLowerCase()) != null) {
6464
return type;
@@ -114,8 +114,8 @@ public void checkStatusCode(final int ... expectedStatuses) throws IOException {
114114
}
115115

116116
private boolean checkForManagementPortException() {
117-
return ((this.getStatusCode() == FailedRequestUsingMgmtPortException.MGMT_PORT_STATUS_CODE)
118-
&& (getFirstHeaderValue(getResponse().getHeaders(), FailedRequestUsingMgmtPortException.MGMT_PORT_HEADER) != null));
117+
return this.getStatusCode() == FailedRequestUsingMgmtPortException.MGMT_PORT_STATUS_CODE
118+
&& getFirstHeaderValue(getResponse().getHeaders(), FailedRequestUsingMgmtPortException.MGMT_PORT_HEADER) != null;
119119
}
120120

121121
public int getStatusCode() {

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/Ds3ClientHelpers.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,7 @@ public abstract Iterable<Contents> listObjects(final String bucket, final String
290290
* response.isTruncated() is true. To return the additional keys, see nextMarker.
291291
* @throws IOException
292292
*/
293-
public abstract Iterable<Contents> listObjects(final String bucket, final String keyPrefix, final String nextMarker, final int maxKeys)
294-
throws IOException;
293+
public abstract Iterable<Contents> listObjects(final String bucket, final String keyPrefix, final String nextMarker, final int maxKeys);
295294

296295
/**
297296
* Returns information about objects in the bucket in alphabetical order, starting with key after the next_marker in order,
@@ -312,7 +311,7 @@ public abstract Iterable<Contents> listObjects(final String bucket, final String
312311
* @param retries Specifies how many times the helper function will attempt to retry a request for failing. Default - 5
313312
* @throws IOException
314313
*/
315-
public abstract Iterable<Contents> listObjects(final String bucket, final String keyPrefix, final String nextMarker, final int maxKeys, final int retries) throws IOException;
314+
public abstract Iterable<Contents> listObjects(final String bucket, final String keyPrefix, final String nextMarker, final int maxKeys, final int retries);
316315

317316
/**
318317
* Returns an object list with which you can call {@code startWriteJobImpl} based on the files in a {@code directory}.
@@ -351,11 +350,7 @@ public boolean apply(@Nullable final Contents input) {
351350
fluentIterable = fluentIterable.filter(new com.google.common.base.Predicate<Contents>() {
352351
@Override
353352
public boolean apply(@Nullable final Contents input) {
354-
if (filter != null) {
355-
return filter.test(input);
356-
} else {
357-
return true; // do not filter anything if filter is null
358-
}
353+
return filter == null || filter.test(input); // do not filter anything if filter is null
359354
}
360355
});
361356
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/Ds3ClientHelpersImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.google.common.collect.ImmutableMultimap;
2222
import com.google.common.collect.Lists;
2323
import com.spectralogic.ds3client.Ds3Client;
24-
import com.spectralogic.ds3client.helpers.events.ConcurrentEventRunner;
2524
import com.spectralogic.ds3client.helpers.events.EventRunner;
2625
import com.spectralogic.ds3client.helpers.events.SameThreadEventRunner;
2726
import com.spectralogic.ds3client.helpers.pagination.GetBucketLoaderFactory;
@@ -267,13 +266,13 @@ public Iterable<Contents> listObjects(final String bucket, final String keyPrefi
267266
}
268267

269268
@Override
270-
public Iterable<Contents> listObjects(final String bucket, final String keyPrefix, final String nextMarker, final int maxKeys) throws IOException {
269+
public Iterable<Contents> listObjects(final String bucket, final String keyPrefix, final String nextMarker, final int maxKeys) {
271270

272271
return new LazyIterable<>(new GetBucketLoaderFactory(client, bucket, keyPrefix, nextMarker, maxKeys, DEFAULT_LIST_OBJECTS_RETRIES));
273272
}
274273

275274
@Override
276-
public Iterable<Contents> listObjects(final String bucket, final String keyPrefix, final String nextMarker, final int maxKeys, final int retries) throws IOException {
275+
public Iterable<Contents> listObjects(final String bucket, final String keyPrefix, final String nextMarker, final int maxKeys, final int retries) {
277276

278277
return new LazyIterable<>(new GetBucketLoaderFactory(client, bucket, keyPrefix, nextMarker, maxKeys, retries));
279278
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/JobPartTrackerFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import java.util.Collection;
2727
import java.util.HashMap;
2828

29-
class JobPartTrackerFactory {
29+
final class JobPartTrackerFactory {
3030
public static JobPartTracker buildPartTracker(final Iterable<BulkObject> objects, final EventRunner eventRunner) {
3131
final ArrayListMultimap<String, ObjectPart> multimap = ArrayListMultimap.create();
3232
for (final BulkObject bulkObject : Preconditions.checkNotNull(objects)) {

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/ObjectPartComparator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public int compare(final ObjectPart o1, final ObjectPart o2) {
3434
}
3535

3636
private static long signum(final long value) {
37-
return value < 0 ? -1 : (value == 0 ? 0 : 1);
37+
return value < 0 ? -1 : value == 0 ? 0 : 1;
3838
}
3939

4040
private static int intOf(final long value) {

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/ReadJobImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public ReadJobImpl(
6262

6363
this.chunks = this.masterObjectList.getObjects();
6464
this.partTracker = JobPartTrackerFactory
65-
.buildPartTracker(Iterables.concat(getAllBlobApiBeans(chunks)), eventRunner);
65+
.buildPartTracker(getAllBlobApiBeans(chunks), eventRunner);
6666
this.blobToRanges = PartialObjectHelpers.mapRangesToBlob(masterObjectList.getObjects(), objectRanges);
6767
this.metadataListeners = Sets.newIdentityHashSet();
6868
this.checksumListeners = Sets.newIdentityHashSet();
@@ -74,7 +74,7 @@ public ReadJobImpl(
7474
}
7575

7676
protected static ImmutableList<BulkObject> getAllBlobApiBeans(final List<Objects> jobWithChunksApiBeans) {
77-
ImmutableList.Builder<BulkObject> builder = ImmutableList.builder();
77+
final ImmutableList.Builder<BulkObject> builder = ImmutableList.builder();
7878
for (final Objects objects : jobWithChunksApiBeans) {
7979
builder.addAll(objects.getObjects());
8080
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/WriteJobImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import com.google.common.collect.ImmutableMap;
1919
import com.google.common.collect.ImmutableMultimap;
20-
import com.google.common.collect.Iterables;
2120
import com.google.common.collect.Sets;
2221
import com.spectralogic.ds3client.Ds3Client;
2322
import com.spectralogic.ds3client.commands.PutObjectRequest;
@@ -76,7 +75,7 @@ public WriteJobImpl(
7675
this.masterObjectList.getJobId().toString(), this.masterObjectList.getObjects().size());
7776
this.filteredChunks = filterChunks(this.masterObjectList.getObjects());
7877
this.partTracker = JobPartTrackerFactory
79-
.buildPartTracker(Iterables.concat(ReadJobImpl.getAllBlobApiBeans(filteredChunks)), eventRunner);
78+
.buildPartTracker(ReadJobImpl.getAllBlobApiBeans(filteredChunks), eventRunner);
8079
}
8180
this.retryAfter = this.retryAfterLeft = retryAfter;
8281
this.retryDelay = retryDelay;
@@ -165,7 +164,7 @@ public void transfer(final ObjectChannelBuilder channelBuilder)
165164
LOG.debug("Starting job transfer");
166165
if (this.masterObjectList == null || this.masterObjectList.getObjects() == null) {
167166
LOG.info("There is nothing to transfer for job"
168-
+ ((this.getJobId() == null) ? "" : " " + this.getJobId().toString()));
167+
+ (this.getJobId() == null ? "" : " " + this.getJobId().toString()));
169168
return;
170169
}
171170

ds3-sdk/src/main/java/com/spectralogic/ds3client/networking/NetUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import java.net.URL;
2929
import java.util.*;
3030

31-
public class NetUtils {
31+
public final class NetUtils {
3232

3333
private NetUtils() {
3434
throw new IllegalStateException("This component should never be initialized.");

ds3-sdk/src/main/java/com/spectralogic/ds3client/networking/NetworkClientImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public CloseableHttpResponse execute() throws IOException {
252252
}
253253
}
254254

255-
private HttpRequest buildHttpRequest() throws IOException {
255+
private HttpRequest buildHttpRequest() {
256256
final String verb = this.ds3Request.getVerb().toString();
257257
final String path = this.buildPath();
258258
if (this.content != null) {
@@ -277,7 +277,7 @@ private String buildPath() {
277277
return path;
278278
}
279279

280-
private void addHeaders(final HttpRequest httpRequest) throws IOException {
280+
private void addHeaders(final HttpRequest httpRequest) {
281281
// Add common headers.
282282
final String date = DateFormatter.dateToRfc882();
283283
httpRequest.addHeader(HOST, NetUtils.buildHostField(NetworkClientImpl.this.connectionDetails));

0 commit comments

Comments
 (0)