Skip to content

Commit

Permalink
errorprone :: ConstantField - more core classes (#864)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdahlke authored Aug 1, 2024
1 parent ad36e1d commit de36e49
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/main/java/emissary/command/AgentsCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
subcommands = {HelpCommand.class})
public class AgentsCommand extends MonitorCommand<AgentsResponseEntity> {

public static String COMMAND_NAME = "agents";
public static final String COMMAND_NAME = "agents";

@Override
public String getCommandName() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/command/ConfigCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class ConfigCommand extends HttpCommand {
@Spec
private CommandSpec spec;
private static final Logger logger = LoggerFactory.getLogger(ConfigCommand.class);
public static int DEFAULT_PORT = 8001;
public static String COMMAND_NAME = "config";
public static final int DEFAULT_PORT = 8001;
public static final String COMMAND_NAME = "config";

@Option(names = {"--place"}, description = "fully-qualified place", arity = "1", required = true)
private String place;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/command/TopologyCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class TopologyCommand extends HttpCommand {

static final Logger LOG = LoggerFactory.getLogger(TopologyCommand.class);

public static String COMMAND_NAME = "topology";
public static int DEFAULT_PORT = 8001;
public static final String COMMAND_NAME = "topology";
public static final int DEFAULT_PORT = 8001;

@Override
public String getCommandName() {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/emissary/config/ServiceConfigGuide.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class ServiceConfigGuide implements Configurator, Serializable {

// Used on the RHS to make a null assignment
// Obsolete, use @{NULL}
protected String NULL_VALUE = "<null>";
protected static final String NULL_VALUE = "<null>";

// Hold all service specific parameters in a list
protected List<ConfigEntry> p_service_parameters = new ArrayList<>();
Expand All @@ -76,12 +76,12 @@ public class ServiceConfigGuide implements Configurator, Serializable {
protected Map<String, String> values = new HashMap<>();

// Get this once per jvm
private static String THIS_HOST_NAME = "localhost";
private static String hostname = "localhost";

// Grab the hostname for @{HOST} replacement
static {
try {
THIS_HOST_NAME = InetAddress.getLocalHost().getCanonicalHostName();
hostname = InetAddress.getLocalHost().getCanonicalHostName();
} catch (UnknownHostException e) {
logger.error("Error getting host name", e);
}
Expand Down Expand Up @@ -174,7 +174,7 @@ protected void initializeValues() {
this.values.put("PROJECT_BASE", ConfigUtil.getProjectBase());
this.values.put("OUTPUT_ROOT", ConfigUtil.getOutputRoot());
this.values.put("BIN_DIR", ConfigUtil.getBinDir());
this.values.put("HOST", THIS_HOST_NAME);
this.values.put("HOST", hostname);
this.values.put("/", File.separator);
this.values.put("TMPDIR", System.getProperty("java.io.tmpdir"));
this.values.put("NULL", null);
Expand Down Expand Up @@ -374,9 +374,9 @@ protected String handleReplacements(final String svalArg, final String filename,
}

// This is obsolete
if (sval != null && sval.equals(this.NULL_VALUE)) {
if (sval != null && sval.equals(NULL_VALUE)) {
sval = null;
logger.debug("Using {} is deprecated, please just use {}NULL{}", this.NULL_VALUE, VSTART, VEND);
logger.debug("Using {} is deprecated, please just use {}NULL{}", NULL_VALUE, VSTART, VEND);
}
return sval;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/pickup/PickUpSpace.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class PickUpSpace extends PickUpPlace implements IPickUpSpace {
protected Map<String, String> pendingBundles = new HashMap<>();

// Number of consecutive take errors that cause space to close
protected int TAKE_ERROR_MAX = 10;
protected static final int TAKE_ERROR_MAX = 10;

/**
* Create using default configuration
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/emissary/pickup/file/FileDataServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,16 @@ public void run() {
// Process files currently in the pickup directory, list
// the first bundleSize in a batch
String[] fileList = theDirectory.list(new FilenameFilter() {
final int MAXFILESTOLIST = bundleSize;
final int maxFileToList = bundleSize;
int filesInList = 0;

@Override
public boolean accept(File dir, String name) {
return !name.startsWith(".") && ++filesInList <= MAXFILESTOLIST;
return !name.startsWith(".") && ++filesInList <= maxFileToList;
}
});

// Rename all of the selected files out of the
// polling area
// Rename all the selected files out of the polling area
for (int i = 0; fileList != null && i < fileList.length; i++) {
File f = new File(theDataDir, fileList[i]);

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/emissary/pickup/file/FilePickUpPlace.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class FilePickUpPlace extends PickUpPlace implements IPickUp {
protected List<FileDataServer> theDataServer = new ArrayList<>();

// How many files the FileDataServer should group
protected int BUNDLE_SIZE = 20;
protected static final int DEFAULT_BUNDLE_SIZE = 20;
protected int bundleSize;

// Input directories to poll
protected String[] inputDataDirs;
Expand Down Expand Up @@ -53,7 +54,7 @@ public FilePickUpPlace(String configInfo, String dir, String placeLoc) throws IO
*/
protected void configurePlace() {
pollingInterval = configG.findIntEntry("POLLING_INTERVAL", pollingInterval);
BUNDLE_SIZE = configG.findIntEntry("BUNDLE_SIZE", BUNDLE_SIZE);
bundleSize = configG.findIntEntry("BUNDLE_SIZE", DEFAULT_BUNDLE_SIZE);
List<String> params = configG.findEntries("INPUT_DATA");
inputDataDirs = params.toArray(new String[0]);
}
Expand Down Expand Up @@ -116,7 +117,7 @@ public void startDataServer() {
FileDataServer fds = new FileDataServer(inputDataDirs[i], this, pollingInterval);

// Tell it how many files to pick up at a time
fds.setBundleSize(BUNDLE_SIZE);
fds.setBundleSize(bundleSize);

// Set priority below agent processing
fds.setPriority(Thread.NORM_PRIORITY - 1);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/emissary/place/ServiceProviderPlaceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ServiceProviderPlaceTest extends UnitTest {
+ "SERVICE_QUALITY = 90\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY\"\n"
+ "SERVICE_PROXY_DENY = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DENY != \"*\"\n").getBytes();

String CFGDIR = System.getProperty(ConfigUtil.CONFIG_DIR_PROPERTY);
String configDir = System.getProperty(ConfigUtil.CONFIG_DIR_PROPERTY);

@Override
@BeforeEach
Expand Down Expand Up @@ -228,9 +228,9 @@ private void runFileConfiguredTest(boolean usePackage, int ctorType) throws IOEx
Path cfg;
// Write out the config data to the temp config dir
if (usePackage) {
cfg = Paths.get(CFGDIR, thisPackage.getName() + ".MyFileConfigedTestPlace" + ConfigUtil.CONFIG_FILE_ENDING);
cfg = Paths.get(configDir, thisPackage.getName() + ".MyFileConfigedTestPlace" + ConfigUtil.CONFIG_FILE_ENDING);
} else {
cfg = Paths.get(CFGDIR, "MyFileConfigedTestPlace" + ConfigUtil.CONFIG_FILE_ENDING);
cfg = Paths.get(configDir, "MyFileConfigedTestPlace" + ConfigUtil.CONFIG_FILE_ENDING);
}

try (OutputStream fos = Files.newOutputStream(cfg)) {
Expand Down

0 comments on commit de36e49

Please sign in to comment.