Skip to content

Commit 127dba7

Browse files
authored
cleanup: Miscellaneous minor cleanup from code inspections (#57)
1 parent 75aea59 commit 127dba7

24 files changed

Lines changed: 66 additions & 71 deletions

build-env/install-etcd.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ INSTALL_DIR="${1:-$HOME/etcd}"
1111
echo "Downloading etcd server ${ETCD_VERSION}"
1212
cd /tmp
1313
wget -nv https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz
14-
mkdir -p ${INSTALL_DIR}
15-
tar xzf etcd-${ETCD_VERSION}-linux-amd64.tar.gz -C ${INSTALL_DIR} --strip-components=1
14+
mkdir -p "${INSTALL_DIR}"
15+
tar xzf etcd-${ETCD_VERSION}-linux-amd64.tar.gz -C "${INSTALL_DIR}" --strip-components=1
1616
rm -rf etcd*.gz

cd/deploy.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
echo TRAVIS_JDK_VERSION="$TRAVIS_JDK_VERSION"
44
if [ "$TRAVIS_BRANCH" = 'main' ] && [ "$TRAVIS_PULL_REQUEST" == 'false' ] && [ "$TRAVIS_JDK_VERSION" == 'openjdk8' ]; then
5-
echo "deploying release to central repository"
5+
echo "deploying release to central repository"
66

7-
# prepare key for signing
8-
openssl aes-256-cbc -K $encrypted_d363c995e9f6_key -iv $encrypted_d363c995e9f6_iv -in cd/signingkey.asc.enc -out cd/signingkey.asc -d
7+
# prepare key for signing
8+
openssl aes-256-cbc -K "$encrypted_d363c995e9f6_key" -iv "$encrypted_d363c995e9f6_iv" -in cd/signingkey.asc.enc -out cd/signingkey.asc -d
99
gpg --fast-import cd/signingkey.asc
1010
shred --remove cd/signingkey.asc
1111

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<licenses>
2929
<license>
3030
<name>The Apache License, Version 2.0</name>
31-
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
31+
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
3232
</license>
3333
</licenses>
3434

src/main/java/com/ibm/etcd/client/EtcdClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ static final class SharedScheduledExecutorService extends ForwardingExecutorServ
798798
implements ScheduledExecutorService {
799799
private final ScheduledExecutorService delegate;
800800

801-
public SharedScheduledExecutorService(ScheduledExecutorService delegate) {
801+
SharedScheduledExecutorService(ScheduledExecutorService delegate) {
802802
this.delegate = delegate;
803803
}
804804
@Override

src/main/java/com/ibm/etcd/client/FluentRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,18 @@ public FR deadline(Deadline deadline) {
7474
return (FR) this;
7575
}
7676
@Override
77-
final public FR backoffRetry() {
77+
public final FR backoffRetry() {
7878
this.retryStrategy = RetryStrategy.BACKOFF;
7979
return (FR) this;
8080
}
8181
@Override
82-
final public FR backoffRetry(Condition precondition) {
82+
public final FR backoffRetry(Condition precondition) {
8383
this.retryStrategy = RetryStrategy.BACKOFF;
8484
this.precondition = precondition;
8585
return (FR) this;
8686
}
8787
@Override
88-
final public ReqT asRequest() {
88+
public final ReqT asRequest() {
8989
return (ReqT) builder.build();
9090
}
9191
@Override

src/main/java/com/ibm/etcd/client/GrpcClient.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public <ReqT,R> ListenableFuture<R> call(MethodDescriptor<ReqT,R> method,
220220
}
221221

222222
//TODO probably move this
223-
public static interface RetryDecision<ReqT> {
223+
public interface RetryDecision<ReqT> {
224224
boolean retry(Throwable t, ReqT request);
225225
}
226226

@@ -385,12 +385,12 @@ public <ReqT,RespT> StreamObserver<ReqT> callStream(MethodDescriptor<ReqT,RespT>
385385
return new ResilientBiDiStream<>(method, respStream, responseExecutor).start();
386386
}
387387

388-
public static interface ResilientResponseObserver<ReqT,RespT> extends StreamObserver<RespT> {
388+
public interface ResilientResponseObserver<ReqT,RespT> extends StreamObserver<RespT> {
389389
/**
390390
* Called once initially, and once after each {@link #onReplaced(StreamObserver)},
391391
* to indicate the corresponding (sub) stream is successfully established
392392
*/
393-
public void onEstablished();
393+
void onEstablished();
394394

395395
/**
396396
* Indicates the underlying stream failed and will be re-established. There is
@@ -403,7 +403,7 @@ public static interface ResilientResponseObserver<ReqT,RespT> extends StreamObse
403403
*
404404
* @param newStreamRequestObserver
405405
*/
406-
public void onReplaced(StreamObserver<ReqT> newStreamRequestObserver);
406+
void onReplaced(StreamObserver<ReqT> newStreamRequestObserver);
407407
}
408408

409409

@@ -438,7 +438,7 @@ final class ResilientBiDiStream<ReqT,RespT> {
438438
* @param respStream
439439
* @param responseExecutor
440440
*/
441-
public ResilientBiDiStream(MethodDescriptor<ReqT,RespT> method,
441+
ResilientBiDiStream(MethodDescriptor<ReqT,RespT> method,
442442
ResilientResponseObserver<ReqT,RespT> respStream,
443443
Executor responseExecutor) {
444444
this.method = method;
@@ -680,7 +680,7 @@ public void onError(Throwable t) {
680680
// delay stream retry using backoff/jitter strategy
681681
ses.schedule(ResilientBiDiStream.this::refreshBackingStream,
682682
// skip attempt in rate-limited case (errCount <=1)
683-
delayAfterFailureMs(errCount <= 2 ? 2 : errCount), MILLISECONDS);
683+
delayAfterFailureMs(Math.max(errCount, 2)), MILLISECONDS);
684684
}
685685
} else {
686686
sentCallOptions = null;

src/main/java/com/ibm/etcd/client/KeyUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* Helper methods for manipulating ByteString keys
2323
*/
24-
public class KeyUtils {
24+
public final class KeyUtils {
2525

2626
private KeyUtils() {} // static only
2727

src/main/java/com/ibm/etcd/client/KvStoreClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424

2525
public interface KvStoreClient extends Closeable {
2626

27-
public KvClient getKvClient();
27+
KvClient getKvClient();
2828

29-
public LeaseClient getLeaseClient();
29+
LeaseClient getLeaseClient();
3030

31-
public LockClient getLockClient();
31+
LockClient getLockClient();
3232

3333
/**
3434
* Returns a singular {@link PersistentLease} bound
@@ -39,6 +39,6 @@ public interface KvStoreClient extends Closeable {
3939
*
4040
* @return the session lease
4141
*/
42-
public PersistentLease getSessionLease();
42+
PersistentLease getSessionLease();
4343

4444
}

src/main/java/com/ibm/etcd/client/config/EtcdClusterConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ public int hashCode() {
355355
private static final Gson gson = new Gson();
356356

357357
private static JsonConfig deserializeJson(InputStream in) {
358-
return gson.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), JsonConfig.class);
358+
return gson.fromJson(new InputStreamReader(in, UTF_8), JsonConfig.class);
359359
}
360360

361361
static class JsonConfig {

src/main/java/com/ibm/etcd/client/kv/EtcdKvClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public FluentRangeRequest get(ByteString key) {
8787
}
8888

8989
//TODO reinstate txn idempotence determination
90-
private static Predicate<TxnRequest> IDEMPOTENT_TXN = txn ->
90+
private static final Predicate<TxnRequest> IDEMPOTENT_TXN = txn ->
9191
Iterables.all(Iterables.concat(txn.getSuccessList(),txn.getFailureList()), op ->
9292
op.getRequestCase() == RequestCase.REQUEST_RANGE);
9393

@@ -320,7 +320,7 @@ final class EtcdTxnRequest extends AbstractFluentRequest<FluentTxnRequest,TxnReq
320320
FluentTxnSuccOps TXN_OPS = null; // lazy instantiate
321321
boolean idempotent = true; // set to false when any non-idempotent ops are added
322322

323-
public EtcdTxnRequest() {
323+
EtcdTxnRequest() {
324324
super(EtcdKvClient.this.client, TxnRequest.newBuilder());
325325
}
326326
@Override

0 commit comments

Comments
 (0)