Skip to content

Commit

Permalink
errorprone :: InconsistentOverloads
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-mlb committed Sep 26, 2024
1 parent 785d38c commit 11e7d91
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 14 deletions.
9 changes: 8 additions & 1 deletion src/main/java/emissary/output/roller/JournaledCoalescer.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,9 @@ public boolean isRolling() {

/** @deprecated replaced by {@link #finalizeRoll(Collection, Path, Path)} */
@Deprecated(since = "8.1.0")
@SuppressWarnings("InconsistentOverloads")
protected void finalize(Collection<Journal> journals, Path rolledOutputPath, Path finalOutputPath) throws IOException { // NOSONAR
finalizeRoll(journals, rolledOutputPath, finalOutputPath);
finalizeRoll(rolledOutputPath, finalOutputPath, journals);
}

/** @deprecated replaced by {@link #finalizeRoll(Path, Path)} */
Expand All @@ -335,7 +336,13 @@ protected void finalize(Path rolledOutputPath, Path finalOutputPath) throws IOEx
finalizeRoll(rolledOutputPath, finalOutputPath);
}

@Deprecated(forRemoval = true)
@SuppressWarnings("InconsistentOverloads")
protected void finalizeRoll(Collection<Journal> journals, Path rolledOutputPath, Path finalOutputPath) throws IOException {
finalizeRoll(rolledOutputPath, finalOutputPath, journals);
}

protected void finalizeRoll(Path rolledOutputPath, Path finalOutputPath, Collection<Journal> journals) throws IOException {
cleanupFiles(journals);
finalizeRoll(rolledOutputPath, finalOutputPath);
}
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/emissary/parser/ParserFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,24 @@ public SessionParser makeSessionParser(SeekableByteChannel channel) {
* @param type the type of data
* @param channel the data to be parsed
* @return SessionParser implementation
* @deprecated use {@link #makeSessionParser(SeekableByteChannel, String)}
*/
@Deprecated(forRemoval = true)
@SuppressWarnings("InconsistentOverloads")
public SessionParser makeSessionParser(String type, SeekableByteChannel channel) {
return makeSessionParser(channel, type);
}

/**
* Make a session parser with the data in channel. If no NIO parser is configured for the type of this data, a standard
* byte[] parser will be produced if there is one available and the size of the data in the channel is less than the
* configured MAX_NIO_FALLBACK_SIZE. Otherwise the default NIO parser will be used.
*
* @param channel the data to be parsed
* @param type the type of data
* @return SessionParser implementation
*/
public SessionParser makeSessionParser(SeekableByteChannel channel, String type) {
SessionParser sp;

if (nioTypeMap.containsKey(type)) {
Expand Down
19 changes: 17 additions & 2 deletions src/main/java/emissary/place/MultiFileUnixCommandPlace.java
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ protected void postSprout(byte[] data, IBaseDataObject parent, File f, int birth
*/
protected int processSingleChild(IBaseDataObject d, File f) {
byte[] theData = Executrix.readDataFromFile(f.getAbsolutePath());
return processSingleChild(d, theData, f);
return processSingleChild(d, f, theData);
}


Expand All @@ -489,7 +489,7 @@ protected int processSingleChild(IBaseDataObject d, File f) {
* @param f the file the data comes from
* @return 0 when it works
*/
protected int processSingleChild(IBaseDataObject d, byte[] theData, File f) {
protected int processSingleChild(IBaseDataObject d, File f, byte[] theData) {
String filename = f.getName();
d.setData(theData);
if (setTitleToFile) {
Expand All @@ -503,6 +503,21 @@ protected int processSingleChild(IBaseDataObject d, byte[] theData, File f) {
return 0;
}

/**
* Process in a custom way when there is only one file result
*
* @param d the parent payload
* @param theData the bytes to process
* @param f the file the data comes from
* @return 0 when it works
* @deprecated use {@link #processSingleChild(IBaseDataObject, File, byte[])}
*/
@Deprecated(forRemoval = true)
@SuppressWarnings("InconsistentOverloads")
protected int processSingleChild(IBaseDataObject d, byte[] theData, File f) {
return processSingleChild(d, f, theData);
}

/**
* Process an incoming payload in synchronized fashion
*
Expand Down
69 changes: 59 additions & 10 deletions src/main/java/emissary/util/shell/Executrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -910,13 +910,13 @@ public String[] writeDataToNewTempDir(final byte[] data, final int start, final

/**
* Write data out for processing into a new subdir under our configured temp area
*
* @param dirn the string name of a new tmp directory to use
*
* @param data the bytes to write
* @param dirn the string name of a new tmp directory to use
* @return the file that was created
*/
@Nullable
public File writeDataToNewTempDir(final String dirn, final byte[] data) {
public File writeDataToNewTempDir(final byte[] data, final String dirn) {
final File dir = new File(dirn);
if (!dir.mkdirs()) {
logger.warn("Unable to create directory path for file {}", dirn);
Expand All @@ -932,6 +932,21 @@ public File writeDataToNewTempDir(final String dirn, final byte[] data) {
return new File(inputFileName);
}

/**
* Write data out for processing into a new subdir under our configured temp area
*
* @param dirn the string name of a new tmp directory to use
* @param data the bytes to write
* @return the file that was created
* @deprecated use {@link #writeDataToNewTempDir(byte[], String)}
*/
@Nullable
@Deprecated(forRemoval = true)
@SuppressWarnings("InconsistentOverloads")
public File writeDataToNewTempDir(final String dirn, final byte[] data) {
return writeDataToNewTempDir(data, dirn);
}

/**
* Gets the value of command that this instance will execute adding configured limits and configured paths to the
* configuration value
Expand All @@ -950,19 +965,19 @@ public String getCommand() {
* @return the value of command
*/
public String[] getCommand(final String[] tmpNames) {
return getCommand(getCommand(), tmpNames, this.cpuTimeLimit, this.vmSizeLimit);
return getCommand(tmpNames, getCommand(), this.cpuTimeLimit, this.vmSizeLimit);
}

/**
* Gets the value of a command that can be executed adding configured limits and supplied paths to the configuration
* value
*
* @param commandArg a command string to work with
*
* @param tmpNames set of input/output directory names
* @param commandArg a command string to work with
* @return the value of command
*/
public String[] getCommand(final String commandArg, final String[] tmpNames) {
return getCommand(commandArg, tmpNames, this.cpuTimeLimit, this.vmSizeLimit);
public String[] getCommand(final String[] tmpNames, final String commandArg) {
return getCommand(tmpNames, commandArg, this.cpuTimeLimit, this.vmSizeLimit);
}

/**
Expand All @@ -971,13 +986,13 @@ public String[] getCommand(final String commandArg, final String[] tmpNames) {
* &lt;INPUT_NAME&gt;, and &lt;OUTPUT_NAME&gt;. On unix systems it is wrapped like
* <code>/bin/sh -c ulimit -c 0; ulimit -v val; your command</code>
*
* @param commandArg a command string to work with
* @param tmpNames set of input/output directory names
* @param commandArg a command string to work with
* @param cpuLimit the cpu limit for the ulimit command
* @param vmSzLimit for the ulimit command
* @return the value of command
*/
public String[] getCommand(final String commandArg, final String[] tmpNames, final int cpuLimit, final int vmSzLimit) {
public String[] getCommand(final String[] tmpNames, final String commandArg, final int cpuLimit, final int vmSzLimit) {
String c = commandArg;
c = c.replaceAll("<INPUT_PATH>", tmpNames[INPATH]);
c = c.replaceAll("<OUTPUT_PATH>", tmpNames[OUTPATH]);
Expand All @@ -992,6 +1007,40 @@ public String[] getCommand(final String commandArg, final String[] tmpNames, fin
return new String[] {"/bin/sh", "-c", "ulimit -c 0; " + ulimitv + "cd " + tmpNames[DIR] + "; " + c};
}

/**
* Gets the value of a command that can be executed adding configured limits and supplied paths to the configuration
* value
*
* @param commandArg a command string to work with
* @param tmpNames set of input/output directory names
* @return the value of command
* @deprecated use {@link #getCommand(String[], String)}
*/
@Deprecated(forRemoval = true)
@SuppressWarnings("InconsistentOverloads")
public String[] getCommand(final String commandArg, final String[] tmpNames) {
return getCommand(tmpNames, commandArg);
}

/**
* Gets the value of a command that can be executed adding supplied limits and supplied paths to the configuration value
* The values in the command string that can be replaced are &lt;INPUT_PATH&gt;, &lt;OUTPUT_PATH&gt;,
* &lt;INPUT_NAME&gt;, and &lt;OUTPUT_NAME&gt;. On unix systems it is wrapped like
* <code>/bin/sh -c ulimit -c 0; ulimit -v val; your command</code>
*
* @param commandArg a command string to work with
* @param tmpNames set of input/output directory names
* @param cpuLimit the cpu limit for the ulimit command
* @param vmSzLimit for the ulimit command
* @return the value of command
* @deprecated use {@link #getCommand(String[], String, int, int)}
*/
@Deprecated(forRemoval = true)
@SuppressWarnings("InconsistentOverloads")
public String[] getCommand(final String commandArg, final String[] tmpNames, final int cpuLimit, final int vmSzLimit) {
return getCommand(tmpNames, commandArg, cpuLimit, vmSzLimit);
}

/**
* Sets the value of command that this instance will execute
*
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/emissary/util/shell/ExecutrixTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void testExecute() throws IOException {
assertNotNull(data, "Data must be read from " + names[Executrix.INPATH]);

final String cmd = "cp <INPUT_NAME> <OUTPUT_NAME>";
String[] c = e.getCommand(cmd, names);
String[] c = e.getCommand(names, cmd);
assertNotNull(c, "Command returned");
assertEquals("/bin/sh", c[0], "Command runner");

Expand Down

0 comments on commit 11e7d91

Please sign in to comment.