This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 5a86a8dd08839b6e24b4d65a17a2299912bc583f Author: Matthieu Baechler <[email protected]> AuthorDate: Fri Feb 28 18:01:07 2020 +0100 [Refactoring] replace inner class by a lambda --- .../james/vault/DeletedMessageZipperTest.java | 2 +- .../apache/james/imap/processor/IdleProcessor.java | 38 ++++++++++------------ 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/DeletedMessageZipperTest.java b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/DeletedMessageZipperTest.java index 195206f..07f7b7c 100644 --- a/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/DeletedMessageZipperTest.java +++ b/mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/DeletedMessageZipperTest.java @@ -182,8 +182,8 @@ class DeletedMessageZipperTest { @Test void zipShouldStopLoadingResourcesWhenGettingException() throws Exception { doThrow(new IOException("mocked exception")).when(zipper).createEntry(any(), any()); + // lambdas are final and thus can't be spied DeletedMessageContentLoader contentLoader = spy(new DeletedMessageContentLoader() { - // lambdas are final and thus can't be spied @Override public Optional<InputStream> load(DeletedMessage deletedMessage) { return Optional.of(new ByteArrayInputStream(CONTENT)); diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/IdleProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/IdleProcessor.java index 2af0936..58b95b4 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/IdleProcessor.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/IdleProcessor.java @@ -36,7 +36,6 @@ import org.apache.james.imap.api.display.HumanReadableText; import org.apache.james.imap.api.message.Capability; import org.apache.james.imap.api.message.response.StatusResponse; import org.apache.james.imap.api.message.response.StatusResponseFactory; -import org.apache.james.imap.api.process.ImapLineHandler; import org.apache.james.imap.api.process.ImapProcessor; import org.apache.james.imap.api.process.ImapSession; import org.apache.james.imap.api.process.SelectedMailbox; @@ -96,29 +95,26 @@ public class IdleProcessor extends AbstractMailboxProcessor<IdleRequest> impleme final AtomicBoolean idleActive = new AtomicBoolean(true); - session.pushLineHandler(new ImapLineHandler() { - @Override - public void onLine(ImapSession session, byte[] data) { - String line; - if (data.length > 2) { - line = new String(data, 0, data.length - 2); - } else { - line = ""; - } + session.pushLineHandler((session1, data) -> { + String line; + if (data.length > 2) { + line = new String(data, 0, data.length - 2); + } else { + line = ""; + } - if (registration != null) { - registration.unregister(); - } - session.popLineHandler(); - if (!DONE.equals(line.toUpperCase(Locale.US))) { - StatusResponse response = getStatusResponseFactory().taggedBad(request.getTag(), request.getCommand(), HumanReadableText.INVALID_COMMAND); - responder.respond(response); - } else { - okComplete(request, responder); + if (registration != null) { + registration.unregister(); + } + session1.popLineHandler(); + if (!DONE.equals(line.toUpperCase(Locale.US))) { + StatusResponse response = getStatusResponseFactory().taggedBad(request.getTag(), request.getCommand(), HumanReadableText.INVALID_COMMAND); + responder.respond(response); + } else { + okComplete(request, responder); - } - idleActive.set(false); } + idleActive.set(false); }); // Check if we should send heartbeats --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
