You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/12/13 10:01:13 UTC
[james-project] 08/17: [Refactoring] Enhance code style in
AbstractImapCommandParser
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 07fc183701a7e4fd379f2238677c3605c57443ee
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Dec 12 08:50:37 2019 +0100
[Refactoring] Enhance code style in AbstractImapCommandParser
- Avoid a reversed condition
- Remove uneeded else block
- Remove useless call to super
- Return early and avoid variable reallocation
---
.../imap/decode/base/AbstractImapCommandParser.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java
index b49c5a5..e846ebc 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java
@@ -67,15 +67,15 @@ public abstract class AbstractImapCommandParser implements ImapCommandParser {
*/
@Override
public final ImapMessage parse(ImapRequestLineReader request, Tag tag, ImapSession session) {
- if (!command.validForState(session.getState())) {
- return statusResponseFactory.taggedNo(tag, command, HumanReadableText.INVALID_COMMAND);
- }
- try {
- return decode(command, request, tag, session);
- } catch (DecodingException e) {
- LOGGER.debug("Cannot parse protocol ", e);
- return statusResponseFactory.taggedBad(tag, command, e.getKey());
+ if (command.validForState(session.getState())) {
+ try {
+ return decode(command, request, tag, session);
+ } catch (DecodingException e) {
+ LOGGER.debug("Cannot parse protocol ", e);
+ return statusResponseFactory.taggedBad(tag, command, e.getKey());
+ }
}
+ return statusResponseFactory.taggedNo(tag, command, HumanReadableText.INVALID_COMMAND);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org