Skip to content

Commit

Permalink
greenmail-mail-test#293 - do not break missing command behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Frühbeck committed Nov 11, 2019
1 parent 92e1f4c commit f709423
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ public Pop3CommandRegistry(Map<Command, Pop3Command> commands) {
}

public Pop3Command getCommand(String name) {
return commands.get(Command.valueOf(name));
Command value;
try {
value = Command.valueOf(name);
} catch (IllegalArgumentException iae) {
return null;
}
return commands.get(value);
}

public Pop3Command getCommand(Command name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.HashMap;
import java.util.Map;

import com.icegreen.greenmail.pop3.commands.Pop3CommandRegistry.Command;


public class SmtpCommandRegistry {
public enum Command { AUTH, HELO, EHLO, NOOP, RSET, QUIT, MAIL, RCPT, DATA, VRFY };
Expand Down Expand Up @@ -42,7 +44,13 @@ public SmtpCommandRegistry(Map<Command, SmtpCommand> commands) {
}

public SmtpCommand getCommand(String name) {
return commands.get(Command.valueOf(name));
Command value;
try {
value = Command.valueOf(name);
} catch (IllegalArgumentException iae) {
return null;
}
return commands.get(value);
}

public SmtpCommand getCommand(Command command) {
Expand Down

0 comments on commit f709423

Please sign in to comment.