Skip to content

Commit

Permalink
GEODE-5984 Address LGTM recommendations
Browse files Browse the repository at this point in the history
Addressing minor issues in javadocs and code reported by LooksGoodToMe.

One change that I made wasn't reported by that tool: I removed
two static variables from AcceptorImpl that duplicated variables in
Handshake.

This closes apache#2780
  • Loading branch information
bschuchardt committed Nov 6, 2018
1 parent 0f517d3 commit a3b6486
Show file tree
Hide file tree
Showing 25 changed files with 81 additions and 395 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.Arrays;

import org.apache.geode.DataSerializer;
import org.apache.geode.cache.Cache;
Expand Down Expand Up @@ -65,6 +66,6 @@ public void toData(DataOutput out) throws IOException {
public String toString() {
return new StringBuilder().append("GatewayDeltaCreateEvent[").append("regionName=")
.append(this.regionName).append("; key=").append(this.key).append("; gatewayDelta=")
.append(this.gatewayDelta).append("]").toString();
.append(Arrays.toString(this.gatewayDelta)).append("]").toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ public void afterCreate(EntryEvent<String, GatewayDelta> event) {
getGatewayDeltaRegion().put(sessionId, new GatewayDeltaCreateEvent(regionName, sessionId,
EntryEventImpl.serialize(event.getNewValue())));
} else {
System.out.println(
"GatewayDeltaForwarderCacheListener event.getSerializedNewValue().getSerializedValue(): "
+ event.getSerializedNewValue().getSerializedValue());
getGatewayDeltaRegion().put(sessionId,
new GatewayDeltaCreateEvent(regionName, sessionId, scv.getSerializedValue()));
}
Expand All @@ -85,7 +82,6 @@ public void afterCreate(EntryEvent<String, GatewayDelta> event) {
}

public void afterUpdate(EntryEvent<String, GatewayDelta> event) {
// System.out.println("GatewayDeltaForwarderCacheListener.afterUpdate: " + event);
// If the event is from the local site, create an 'update' event and send it to the
// gateway delta region
if (event.getCallbackArgument() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ private void init() {
String SSL_KEYSTORE_TYPE = "JKS";
String SSL_KEYSTORE_PASSWORD = "password";

try {
FileInputStream fileInputStream = new FileInputStream(keyStorePath);
try (FileInputStream fileInputStream = new FileInputStream(keyStorePath)) {
KeyStore keyStore = KeyStore.getInstance(SSL_KEYSTORE_TYPE);
keyStore.load(fileInputStream, SSL_KEYSTORE_PASSWORD.toCharArray());
this.customKeyManagerFactory = KeyManagerFactory.getInstance(this.algorithm, "SunJSSE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ private void init() {
String trustStoreType = "JKS";
String trustStorePassword = "password";

try {
FileInputStream fileInputStream = new FileInputStream(trustStorePath);
try (FileInputStream fileInputStream = new FileInputStream(trustStorePath)) {
KeyStore trustStore = KeyStore.getInstance(trustStoreType);
trustStore.load(fileInputStream, trustStorePassword.toCharArray());
this.customTrustManagerFactory = TrustManagerFactory.getInstance(this.algorithm, "SunJSSE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,6 @@ public PartitionAttributesFactory<K, V> setRedundantCopies(int redundantCopies)
return this;
}

/**
* Sets the cache writer for the next <code>PartitionAttributes</code> created. <i>Currently
* unsupported for the early access release.</i>
*
* @param cacheWriter the cache writer or null if no cache writer
* @return this public PartitionAttributesFactory<K,V> setCacheWriter(CacheWriter cacheWriter) {
* this.partitionAttributes.setCacheWriter(cacheWriter); return this; }
*/

/**
* Sets the maximum amount of memory, in megabytes, to be used by the region in this process. If
* not set, a default of 90% of available heap is used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ protected SecurableCommunicationChannel[] checkLegacySSLWhenSSLEnabledComponents
default:
throw new IllegalArgumentException(
String.format("%s is not in the valid set of options %s",
value,
Arrays.toString(value),
StringUtils
.join(new String[] {SecurableCommunicationChannel.ALL.getConstant(),
SecurableCommunicationChannel.CLUSTER.getConstant(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void write(int b) {
return;
checkIfWritable();
ensureCapacity(1);
buffer.put((byte) b);
buffer.put((byte) (b & 0xff));
}

private void ensureCapacity(int amount) {
Expand Down Expand Up @@ -888,7 +888,7 @@ public void writeShort(int v) {
return;
checkIfWritable();
ensureCapacity(2);
buffer.putShort((short) v);
buffer.putShort((short) (v & 0xffff));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -855,14 +855,15 @@ static DataSerializer newInstance(Class c) {
init = c.getDeclaredConstructor(new Class[0]);

} catch (NoSuchMethodException ignored) {
String s = "Class %s does not have a zero-argument constructor.";
Object[] args = new Object[] {c.getName()};
if (c.getDeclaringClass() != null) {
s =
"Class %s does not have a zero-argument constructor. It is an inner class of %s. Should it be a static inner class?";
args = new Object[] {c.getName(), c.getDeclaringClass()};
}
throw new IllegalArgumentException(String.format(s, args));
String message = String.format(
"Class %s does not have a zero-argument constructor. It is an inner class of %s. Should it be a static inner class?",
c.getName(), c.getDeclaringClass());
throw new IllegalArgumentException(message);
}
String message = String.format("Class %s does not have a zero-argument constructor.",
c.getName());
throw new IllegalArgumentException(message);
}

DataSerializer s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,16 +609,16 @@ protected static Instantiator newInstance(Class instantiatorClass, Class instant
types = new Class[] {Class.class, byte.class};
init = instantiatorClass.getDeclaredConstructor(types);
} catch (NoSuchMethodException ex2) {
String msg =
"Class %s does not have a two-argument (Class, int) constructor.";
Object[] msgArgs = new Object[] {instantiatorClass.getName()};
if (instantiatorClass.getDeclaringClass() != null) {
msg =
"Class %s does not have a two-argument (Class, int) constructor. It is an inner class of %s. Should it be a static inner class?";
msgArgs =
new Object[] {instantiatorClass.getName(), instantiatorClass.getDeclaringClass()};
String msg = String.format(
"Class %s does not have a two-argument (Class, int) constructor. It is an inner class of %s. Should it be a static inner class?",
instantiatorClass.getName(), instantiatorClass.getDeclaringClass());
throw new IllegalArgumentException(msg);
}
throw new IllegalArgumentException(String.format(msg, msgArgs));
String msg = String.format(
"Class %s does not have a two-argument (Class, int) constructor.",
instantiatorClass.getName());
throw new IllegalArgumentException(msg);
}
}

Expand Down
Loading

0 comments on commit a3b6486

Please sign in to comment.