Skip to content

Commit

Permalink
GEODE-3952: Improve and apply spotless.
Browse files Browse the repository at this point in the history
* Expand whitespace handling to strip end of lines and end of files
* Remove commented-out import statements.
* Enforce style guide import ordering
* Enforce style guide modifier ordering
  • Loading branch information
PurelyApplied authored Nov 6, 2017
1 parent a1b9725 commit 96684f3
Show file tree
Hide file tree
Showing 4,389 changed files with 25,706 additions and 25,670 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
46 changes: 44 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,58 @@ subprojects {

apply plugin: "com.diffplug.gradle.spotless"
spotless {
lineEndings = 'unix';
lineEndings = 'unix'
java {
target project.fileTree(project.projectDir) {
include '**/*.java'
exclude '**/generated-src/**'
}

custom 'Remove commented-out import statements', {
it.replaceAll(/\n\/\/ import .*?;.*/, '')
}

custom 'End files with a single blank line', {
it.replaceAll(/\s+$/, '\n')
}

// Removes end-of-line whitespace
trimTrailingWhitespace()

// Enforce style import order
importOrderFile "${project(':geode-core').projectDir}/../etc/eclipseOrganizeImports.importorder"

// The formatter is relative to geode-core and not the root project as the root project would change
// if Geode and submodules are included as part of a different gradle project.
eclipseFormatFile "${project(':geode-core').projectDir}/../etc/eclipse-java-google-style.xml"

// Enforce style modifier order
custom 'Modifier ordering', {
def modifierRanking = [
public : 1,
protected : 2,
private : 3,
abstract : 4,
default : 5,
static : 6,
final : 7,
transient : 8,
volatile : 9,
synchronized: 10,
native : 11,
strictfp : 12]
// Find any instance of multiple modifiers. Lead with a non-word character to avoid
// accidental matching against for instance, "an alternative default value"
it.replaceAll(/\W(?:public |protected |private |abstract |default |static |final |transient |volatile |synchronized |native |strictfp ){2,}/, {
// Do not replace the leading non-word character. Identify the modifiers
it.replaceAll(/(?:public |protected |private |abstract |default |static |final |transient |volatile |synchronized |native |strictfp ){2,}/, {
// Sort the modifiers according to the ranking above
it.split().sort({ modifierRanking[it] }).join(' ') + ' '
}
)
}
)
}
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@

package org.apache.geode.modules.session.internal.common;

import java.util.Map;

import javax.servlet.http.HttpSession;

import org.apache.geode.cache.Region;
import org.apache.geode.modules.session.catalina.internal.DeltaSessionStatistics;
import org.apache.geode.modules.session.internal.filter.util.TypeAwareMap;
import org.apache.geode.modules.util.RegionConfiguration;
import org.apache.geode.modules.util.SessionCustomExpiry;

import java.util.Map;
import javax.servlet.http.HttpSession;

public abstract class AbstractSessionCache implements SessionCache {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@

package org.apache.geode.modules.session.internal.common;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionShortcut;
Expand All @@ -30,13 +38,6 @@
import org.apache.geode.modules.util.RegionStatus;
import org.apache.geode.modules.util.SessionCustomExpiry;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Class which defines a client/server cache.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@

package org.apache.geode.modules.session.internal.common;

import java.util.Map;

import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.geode.cache.Cache;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
Expand All @@ -28,12 +35,6 @@
import org.apache.geode.modules.util.TouchPartitionedRegionEntriesFunction;
import org.apache.geode.modules.util.TouchReplicatedRegionEntriesFunction;

import java.util.Map;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Class which defines a peer-to-peer cache
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

package org.apache.geode.modules.session.internal.common;

import javax.servlet.http.HttpSession;

import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;

import javax.servlet.http.HttpSession;

/**
* Interface to basic cache operations.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@

package org.apache.geode.modules.session.internal.common;

import org.apache.geode.cache.Declarable;
import org.apache.geode.cache.EntryEvent;
import org.apache.geode.cache.Operation;
import org.apache.geode.cache.util.CacheListenerAdapter;

import java.util.Properties;

import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.geode.cache.Declarable;
import org.apache.geode.cache.EntryEvent;
import org.apache.geode.cache.Operation;
import org.apache.geode.cache.util.CacheListenerAdapter;

public class SessionExpirationCacheListener extends CacheListenerAdapter<String, HttpSession>
implements Declarable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

package org.apache.geode.modules.session.internal.filter;

import org.apache.geode.modules.session.internal.filter.attributes.AbstractSessionAttributes;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;

import org.apache.geode.modules.session.internal.filter.attributes.AbstractSessionAttributes;

/**
* Class which fakes an in-memory basic session manager for testing purposes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@

package org.apache.geode.modules.session.internal.filter;

import org.apache.geode.DataSerializable;
import org.apache.geode.DataSerializer;
import org.apache.geode.Delta;
import org.apache.geode.Instantiator;
import org.apache.geode.InvalidDeltaException;
import org.apache.geode.modules.session.internal.filter.attributes.AbstractSessionAttributes;
import org.apache.geode.modules.session.internal.filter.attributes.SessionAttributes;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
Expand All @@ -33,21 +25,30 @@
import java.util.Collections;
import java.util.Enumeration;
import java.util.concurrent.atomic.AtomicBoolean;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionContext;

import org.apache.geode.modules.util.ClassLoaderObjectInputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.geode.DataSerializable;
import org.apache.geode.DataSerializer;
import org.apache.geode.Delta;
import org.apache.geode.Instantiator;
import org.apache.geode.InvalidDeltaException;
import org.apache.geode.modules.session.internal.filter.attributes.AbstractSessionAttributes;
import org.apache.geode.modules.session.internal.filter.attributes.SessionAttributes;
import org.apache.geode.modules.util.ClassLoaderObjectInputStream;

/**
* Class which implements a Gemfire persisted {@code HttpSession}
*/
@SuppressWarnings("deprecation")
public class GemfireHttpSession implements HttpSession, DataSerializable, Delta {

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

/**
Expand Down Expand Up @@ -464,4 +465,3 @@ public String getJvmOwnerId() {
return null;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@

package org.apache.geode.modules.session.internal.filter;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.naming.InitialContext;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.geode.cache.CacheClosedException;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.EntryNotFoundException;
Expand All @@ -35,19 +50,6 @@
import org.apache.geode.modules.session.internal.filter.util.TypeAwareMap;
import org.apache.geode.modules.session.internal.jmx.SessionStatistics;
import org.apache.geode.modules.util.RegionHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.naming.InitialContext;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
* This class implements the session management using a Gemfire distributedCache as a persistent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@

package org.apache.geode.modules.session.internal.filter.attributes;

import org.apache.geode.DataSerializer;
import org.apache.geode.Delta;
import org.apache.geode.InvalidDeltaException;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
Expand All @@ -29,6 +25,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.geode.DataSerializer;
import org.apache.geode.Delta;
import org.apache.geode.InvalidDeltaException;

/**
* This abstract class contains the structures and methods to handle delta updates to attributes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@

package org.apache.geode.modules.session.internal.filter.attributes;

import org.apache.geode.DataSerializer;
import org.apache.geode.internal.InternalDataSerializer;
import org.apache.geode.internal.Version;
import org.apache.geode.internal.util.BlobHelper;
import org.apache.geode.modules.session.internal.filter.GemfireHttpSession;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
Expand All @@ -32,6 +26,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.geode.DataSerializer;
import org.apache.geode.internal.InternalDataSerializer;
import org.apache.geode.internal.Version;
import org.apache.geode.internal.util.BlobHelper;
import org.apache.geode.modules.session.internal.filter.GemfireHttpSession;

/**
* Abstract implementation for attributes. Should be sub-classed to provide differing
* implementations for synchronous or delta propagation. The backing store used is defined by the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@

package org.apache.geode.modules.session.internal.filter.attributes;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.geode.DataSerializable;
import org.apache.geode.DataSerializer;
import org.apache.geode.internal.util.BlobHelper;
import org.apache.geode.modules.session.internal.filter.GemfireHttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
* Capture the update to a particular name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@

package org.apache.geode.modules.session.internal.filter.attributes;

import org.apache.geode.DataSerializable;
import org.apache.geode.Instantiator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.geode.DataSerializable;
import org.apache.geode.Instantiator;

/**
* This class implements delayed attribute delta propagation. Updates to attributes are only
* propagated once the session goes out of scope - i.e. as the request is done being processed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@

package org.apache.geode.modules.session.internal.filter.attributes;

import org.apache.geode.DataSerializable;
import org.apache.geode.Instantiator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.geode.DataSerializable;
import org.apache.geode.Instantiator;

/**
* This class implements synchronous attribute delta propagation. Updates to attributes are
* immediately propagated.
Expand Down
Loading

0 comments on commit 96684f3

Please sign in to comment.