Moved listeners from list to set

This commit is contained in:
Emmanuel Bigeon 2018-10-14 09:26:55 -04:00
parent 7c94dea7b5
commit 74c66dcbdd

View File

@ -71,9 +71,10 @@ package net.bigeon.gclc;
*/
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -125,7 +126,7 @@ public final class ConsoleApplication implements ICommandProvider {
/** The state of this application. */
private boolean running;
/** The listeners. */
private final List<CommandRequestListener> listeners = new ArrayList<>();
private final Set<CommandRequestListener> listeners = new LinkedHashSet<>();
/** Create a console application.
*
@ -188,9 +189,9 @@ public final class ConsoleApplication implements ICommandProvider {
List<String> args;
try {
args = GCLCConstants.splitCommand(cmd);
} catch (final CommandParsingException e1) {
} catch (final CommandParsingException e) {
out.println("Command line cannot be parsed"); //$NON-NLS-1$
LOGGER.log(Level.FINE, "Invalid user command " + cmd, e1); //$NON-NLS-1$
LOGGER.log(Level.FINE, "Invalid user command " + cmd, e); //$NON-NLS-1$
return;
}
if (!args.isEmpty()) {