Skip to content

Commit

Permalink
GEODE-6588: Mass cleanup of static analyzer warnings. (apache#7221)
Browse files Browse the repository at this point in the history
  • Loading branch information
jake-at-work authored Jan 19, 2022
1 parent 8f7193c commit 41eb499
Show file tree
Hide file tree
Showing 3,760 changed files with 58,365 additions and 62,043 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class PasswordDialog {
label(text: prompt)
input = passwordField()
button(defaultButton: true, text: 'OK', actionPerformed: {
password = input.password.toString(); // Set pass variable to value of input field
dispose(); // Close dialog
password = input.password.toString() // Set pass variable to value of input field
dispose() // Close dialog
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
*
*/

package org.apache.geode.gradle;
package org.apache.geode.gradle

public class TestPropertiesWriter {
public static void writeTestProperties(File parent, String name) {
Properties props = new Properties();
props.setProperty('log-level', 'config');
File propsFile = new File(testResultsDir(parent, name), 'gemfire.properties');
BufferedWriter writer = propsFile.newWriter();
props.store(writer, 'Autogenerated Gemfire properties');
class TestPropertiesWriter {
static void writeTestProperties(File parent, String name) {
Properties props = new Properties()
props.setProperty('log-level', 'config')
File propsFile = new File(testResultsDir(parent, name), 'gemfire.properties')
BufferedWriter writer = propsFile.newWriter()
props.store(writer, 'Autogenerated Gemfire properties')
}

public static File testResultsDir(File parent, String name) {
static File testResultsDir(File parent, String name) {
return new File(parent, name)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import me.champeau.gradle.japicmp.report.stdrules.AbstractRecordingSeenMembers
class GeodeApiRegressionRule extends AbstractRecordingSeenMembers {
private final Map<String, String> acceptedRegressions

public GeodeApiRegressionRule() {
GeodeApiRegressionRule() {
def jsonSlurper = new JsonSlurper()
acceptedRegressions = jsonSlurper.parse(getClass().getResource('/japicmp_exceptions.json').openStream()) as Map
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import me.champeau.gradle.japicmp.report.stdrules.AbstractRecordingSeenMembers
class GeodeSpiRegressionRule extends AbstractRecordingSeenMembers {
private final Map<String, String> acceptedRegressions

public GeodeSpiRegressionRule() {
GeodeSpiRegressionRule() {
def jsonSlurper = new JsonSlurper()
acceptedRegressions = jsonSlurper.parse(getClass().getResource('/japicmp_exceptions.json').openStream()) as Map
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.geode.gradle.japicmp;
package org.apache.geode.gradle.japicmp

import me.champeau.gradle.japicmp.report.Violation
import me.champeau.gradle.japicmp.report.stdrules.AbstractRecordingSeenMembers
Expand All @@ -28,7 +28,7 @@ import japicmp.model.JApiCompatibility

class ParentIsExperimental extends AbstractRecordingSeenMembers {
@Override
public Violation maybeAddViolation(final JApiCompatibility member) {
Violation maybeAddViolation(final JApiCompatibility member) {
boolean isExperimental = true
if (!member.isBinaryCompatible() || !member.isSourceCompatible()) {
if (member instanceof JApiMethod || member instanceof JApiConstructor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void updateGradleWorkerClasspathFile(List<String> command, int argIndex,
Path originalClasspathFile = Paths.get(matcher.group().substring(1));
Path newClasspathFile = directory.resolve("gradle-worker-classpath.txt");
copy(originalClasspathFile, newClasspathFile);
String newClasspathFileArg = "@" + newClasspathFile.toString();
String newClasspathFileArg = "@" + newClasspathFile;
command.set(argIndex, newClasspathFileArg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,27 +107,19 @@ public void execute(final JvmTestExecutionSpec testExecutionSpec,
final List<String>
testWorkerImplementationModules =
testFramework.getTestWorkerImplementationModules();
final Factory<TestClassProcessor> forkingProcessorFactory = new Factory<TestClassProcessor>() {
@Override
public TestClassProcessor create() {
TestClassProcessor forkingTestClassProcessor =
new ForkingTestClassProcessor(currentWorkerLease, workerFactory, testInstanceFactory,
testExecutionSpec.getJavaForkOptions(), classpath, modulePath,
testWorkerImplementationModules, testFramework.getWorkerConfigurationAction(),
moduleRegistry, documentationRegistry);
// Wrap the forking processor to make it distinguish different executions of a test class
return new ExecutionTrackingTestClassProcessor(forkingTestClassProcessor, iterationCount);
}
final Factory<TestClassProcessor> forkingProcessorFactory = () -> {
TestClassProcessor forkingTestClassProcessor =
new ForkingTestClassProcessor(currentWorkerLease, workerFactory, testInstanceFactory,
testExecutionSpec.getJavaForkOptions(), classpath, modulePath,
testWorkerImplementationModules, testFramework.getWorkerConfigurationAction(),
moduleRegistry, documentationRegistry);
// Wrap the forking processor to make it distinguish different executions of a test class
return new ExecutionTrackingTestClassProcessor(forkingTestClassProcessor, iterationCount);
};
final Factory<TestClassProcessor>
reforkingProcessorFactory =
new Factory<TestClassProcessor>() {
@Override
public TestClassProcessor create() {
return new RestartEveryNTestClassProcessor(forkingProcessorFactory,
testExecutionSpec.getForkEvery());
}
};
() -> new RestartEveryNTestClassProcessor(forkingProcessorFactory,
testExecutionSpec.getForkEvery());
// Create the chain of test class processors, omitting the
// RunPreviousFailedFirstTestClassProcessor that Gradle's DefaultTestExecuter creates.
processor =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class SimpleFileManager extends ForwardingJavaFileManager<StandardJavaFileManager> {

private List<SimpleClassFile> compiled = new ArrayList<>();
private final List<SimpleClassFile> compiled = new ArrayList<>();

public SimpleFileManager(StandardJavaFileManager fileManager) {
super(fileManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import javax.tools.SimpleJavaFileObject;

public class SimpleSourceFile extends SimpleJavaFileObject {
private String content;
private final String content;

public SimpleSourceFile(String qualifiedClassName, String testSource) {
super(URI.create(String.format("file://%s%s", qualifiedClassName.replaceAll("\\.", "/"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class TestAnnotationProcessor {
+ "public class Test {\n"
+ "}\n";

private TestCompiler compiler = new TestCompiler();
private final TestCompiler compiler = new TestCompiler();

@Test
public void checkValidAnnotations() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public void stop() {
*/
@Override
public Region<String, HttpSession> getOperatingRegion() {
return this.operatingRegion;
return operatingRegion;
}

void createStatistics() {
this.statistics = new DeltaSessionStatistics(getCache().getDistributedSystem(),
statistics = new DeltaSessionStatistics(getCache().getDistributedSystem(),
(String) properties.get(CacheProperty.STATISTICS_NAME));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ClientServerSessionCache extends AbstractSessionCache {

private static final Logger LOG = LoggerFactory.getLogger(PeerToPeerSessionCache.class.getName());

private ClientCache cache;
private final ClientCache cache;

protected static final String DEFAULT_REGION_ATTRIBUTES_ID =
RegionShortcut.PARTITION_REDUNDANT.toString();
Expand Down Expand Up @@ -101,7 +101,7 @@ public boolean isClientServer() {
// Private methods

private void bootstrapServers() {
Execution execution = FunctionService.onServers(this.cache);
Execution execution = FunctionService.onServers(cache);
ResultCollector collector = execution.execute(new BootstrappingFunction());
// Get the result. Nothing is being done with it.
try {
Expand All @@ -114,18 +114,18 @@ private void bootstrapServers() {

private void createOrRetrieveRegion() {
// Retrieve the local session region
this.sessionRegion = this.cache.getRegion((String) properties.get(CacheProperty.REGION_NAME));
sessionRegion = cache.getRegion((String) properties.get(CacheProperty.REGION_NAME));

// If necessary, create the regions on the server and client
if (this.sessionRegion == null) {
if (sessionRegion == null) {
// Create the PR on the servers
createSessionRegionOnServers();

// Create the region on the client
this.sessionRegion = createLocalSessionRegion();
LOG.debug("Created session region: " + this.sessionRegion);
sessionRegion = createLocalSessionRegion();
LOG.debug("Created session region: " + sessionRegion);
} else {
LOG.debug("Retrieved session region: " + this.sessionRegion);
LOG.debug("Retrieved session region: " + sessionRegion);

// Register interest in case users provide their own client cache region
if (sessionRegion.getAttributes().getDataPolicy() != DataPolicy.EMPTY) {
Expand All @@ -139,19 +139,18 @@ private void createSessionRegionOnServers() {
RegionConfiguration configuration = createRegionConfiguration();

// Send it to the server tier
Execution execution = FunctionService.onServer(this.cache).setArguments(configuration);
Execution execution = FunctionService.onServer(cache).setArguments(configuration);
ResultCollector collector = execution.execute(CreateRegionFunction.ID);

// Verify the region was successfully created on the servers
List<RegionStatus> results = (List<RegionStatus>) collector.getResult();
for (RegionStatus status : results) {
if (status == RegionStatus.INVALID) {
StringBuilder builder = new StringBuilder();
builder.append(
"An exception occurred on the server while attempting to create or validate region named ");
builder.append(properties.get(CacheProperty.REGION_NAME));
builder.append(". See the server log for additional details.");
throw new IllegalStateException(builder.toString());
final String builder =
"An exception occurred on the server while attempting to create or validate region named "
+ properties.get(CacheProperty.REGION_NAME)
+ ". See the server log for additional details.";
throw new IllegalStateException(builder);
}
}
}
Expand All @@ -163,14 +162,14 @@ private Region<String, HttpSession> createLocalSessionRegion() {
String regionName = (String) properties.get(CacheProperty.REGION_NAME);
if (enableLocalCache) {
// Create the region factory with caching and heap LRU enabled
factory = this.cache
factory = cache
.<String, HttpSession>createClientRegionFactory(
ClientRegionShortcut.CACHING_PROXY_HEAP_LRU)
.setCustomEntryIdleTimeout(new SessionCustomExpiry());
LOG.info("Created new local client session region: {}", regionName);
} else {
// Create the region factory without caching enabled
factory = this.cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
factory = cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
LOG.info("Created new local client (uncached) session region: {} without any session expiry",
regionName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class PeerToPeerSessionCache extends AbstractSessionCache {

private static final Logger LOG = LoggerFactory.getLogger(PeerToPeerSessionCache.class.getName());

private Cache cache;
private final Cache cache;

private static final String DEFAULT_REGION_ATTRIBUTES_ID = RegionShortcut.REPLICATE.toString();

Expand Down Expand Up @@ -80,7 +80,7 @@ public void initialize() {
* the operating region; otherwise, use the session region directly as the operating region.
*/
boolean enableLocalCache = (Boolean) properties.get(CacheProperty.ENABLE_LOCAL_CACHE);
operatingRegion = enableLocalCache ? createOrRetrieveLocalRegion() : this.sessionRegion;
operatingRegion = enableLocalCache ? createOrRetrieveLocalRegion() : sessionRegion;

// Create or retrieve the statistics
createStatistics();
Expand Down Expand Up @@ -118,7 +118,7 @@ private void createOrRetrieveRegion() {
// Attempt to retrieve the region
// If it already exists, validate it
// If it doesn't already exist, create it
Region region = this.cache.getRegion((String) properties.get(CacheProperty.REGION_NAME));
Region region = cache.getRegion((String) properties.get(CacheProperty.REGION_NAME));
if (region == null) {
// Create the region
region = RegionHelper.createRegion(cache, configuration);
Expand All @@ -130,7 +130,7 @@ private void createOrRetrieveRegion() {
}

// Set the session region
this.sessionRegion = region;
sessionRegion = region;
}

/**
Expand All @@ -139,17 +139,17 @@ private void createOrRetrieveRegion() {
*/
private Region<String, HttpSession> createOrRetrieveLocalRegion() {
// Attempt to retrieve the fronting region
String frontingRegionName = this.sessionRegion.getName() + "_local";
Region<String, HttpSession> frontingRegion = this.cache.getRegion(frontingRegionName);
String frontingRegionName = sessionRegion.getName() + "_local";
Region<String, HttpSession> frontingRegion = cache.getRegion(frontingRegionName);

if (frontingRegion == null) {
// Create the region factory
RegionFactory<String, HttpSession> factory =
this.cache.createRegionFactory(RegionShortcut.LOCAL_HEAP_LRU);
cache.createRegionFactory(RegionShortcut.LOCAL_HEAP_LRU);

// Add the cache loader and writer
factory.setCacheLoader(new LocalSessionCacheLoader(this.sessionRegion));
factory.setCacheWriter(new LocalSessionCacheWriter(this.sessionRegion));
factory.setCacheLoader(new LocalSessionCacheLoader(sessionRegion));
factory.setCacheWriter(new LocalSessionCacheWriter(sessionRegion));

// Create the region
frontingRegion = factory.create(frontingRegionName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class GemfireHttpSession implements HttpSession, DataSerializable, Delta
* This is set during serialization and then reset by the SessionManager when it is retrieved from
* the attributes.
*/
private AtomicBoolean serialized = new AtomicBoolean(false);
private final AtomicBoolean serialized = new AtomicBoolean(false);

// Register ourselves for de-serialization
static {
Expand Down Expand Up @@ -399,9 +399,7 @@ public boolean isValid() {

if (getMaxInactiveInterval() >= 0) {
long now = System.currentTimeMillis();
if (now - attributes.getLastAccessedTime() >= getMaxInactiveInterval() * 1000) {
return false;
}
return now - attributes.getLastAccessedTime() < getMaxInactiveInterval() * 1000;
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public class GemfireSessionManager implements SessionManager {
/**
* Set up properties with default values
*/
private TypeAwareMap<CacheProperty, Object> properties =
private final TypeAwareMap<CacheProperty, Object> properties =
new TypeAwareMap<CacheProperty, Object>(CacheProperty.class) {
{
put(CacheProperty.REGION_NAME, RegionHelper.NAME + "_sessions");
Expand All @@ -140,7 +140,7 @@ public GemfireSessionManager() {
*/
@Override
public void start(Object conf, ClassLoader loader) {
this.referenceClassLoader = loader;
referenceClassLoader = loader;
FilterConfig config = (FilterConfig) conf;

startDistributedSystem(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public abstract class AbstractDeltaSessionAttributes extends AbstractSessionAttr
* This map holds the updates to attributes
*/
protected transient Map<String, DeltaEvent> deltas =
Collections.synchronizedMap(new HashMap<String, DeltaEvent>());
Collections.synchronizedMap(new HashMap<>());

@Override
public boolean hasDelta() {
Expand Down Expand Up @@ -70,7 +70,7 @@ public void toDelta(DataOutput out) throws IOException {
public void fromDelta(DataInput in) throws IOException, InvalidDeltaException {
maxInactiveInterval = in.readInt();
lastAccessedTime = in.readLong();
Map<String, DeltaEvent> localDeltas = new HashMap<String, DeltaEvent>();
Map<String, DeltaEvent> localDeltas = new HashMap<>();
try {
int size = DataSerializer.readInteger(in);
for (int i = 0; i < size; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private void fromDataPre_GEODE_1_3_0_0(DataInput in) throws IOException, ClassNo

@Override
public void setJvmOwnerId(String jvmId) {
this.jvmOwnerId = jvmId;
jvmOwnerId = jvmId;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ public DeltaEvent() {}
*/
DeltaEvent(GemfireHttpSession session, String attribute) {
this.session = session;
this.name = attribute;
this.update = true;
name = attribute;
update = true;
}

DeltaEvent(boolean update, String attribute, Object value) {
this.update = update;
this.name = attribute;
name = attribute;
this.value = value;
blobifyValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class TypeAwareMap<K extends CacheProperty, Object> extends HashMap {
@SuppressWarnings("unused")
private Class<K> keyType;
private final Class<K> keyType;

public TypeAwareMap(Class<K> keyType) {
super();
Expand Down
Loading

0 comments on commit 41eb499

Please sign in to comment.