Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errorprone: ImmutableMemberCollection - suppressing in Emissary class #905

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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