Skip to content

Commit

Permalink
errorprone: ImmutableMemberCollection - suppressing in Emissary class
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdahlke committed Sep 1, 2024
1 parent c2ce2fb commit 9206e63
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/java/emissary/Emissary.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
*
* Parses command line arguments and delegates commands
*/
@SuppressWarnings("ImmutableMemberCollection")
public class Emissary {
private static final Logger LOG = LoggerFactory.getLogger(Emissary.class);

Expand All @@ -53,17 +54,15 @@ public class Emissary {
private boolean bannerDumped = false;

static {
List<Class<? extends EmissaryCommand>> cmds =
List<Class<? extends EmissaryCommand>> commandClasses =
Arrays.asList(ServerCommand.class, HelpCommand.class, TopologyCommand.class, FeedCommand.class,
AgentsCommand.class, PoolCommand.class, VersionCommand.class, EnvCommand.class,
PeersCommand.class, ConfigCommand.class, DirectoryCommand.class);
Map<String, EmissaryCommand> staticCopy = new HashMap<>();
for (Class<? extends EmissaryCommand> clz : cmds) {
EmissaryCommand cmd;
for (Class<? extends EmissaryCommand> commandClass : commandClasses) {
try {
cmd = clz.getDeclaredConstructor().newInstance();
String name = cmd.getCommandName();
staticCopy.put(name, cmd);
EmissaryCommand command = commandClass.getDeclaredConstructor().newInstance();
staticCopy.put(command.getCommandName(), command);
} catch (ReflectiveOperationException e) {
LOG.error("Couldn't make EMISSARY_COMMANDS", e);
System.exit(1);
Expand Down

0 comments on commit 9206e63

Please sign in to comment.