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 2017/08/24 03:46:43 UTC
[18/38] james-project git commit: JAMES-2114 Remove LOGGER from IMAP
Session API
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/main/java/org/apache/james/imap/processor/StoreProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/StoreProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/StoreProcessor.java
index 44aecce..3936d71 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/StoreProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/StoreProcessor.java
@@ -58,10 +58,13 @@ import org.apache.james.mailbox.model.MessageResult;
import org.apache.james.mailbox.model.MessageResultIterator;
import org.apache.james.metrics.api.MetricFactory;
import org.apache.james.util.MDCBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableList;
public class StoreProcessor extends AbstractMailboxProcessor<StoreRequest> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(StoreProcessor.class);
/**
* The {@link ImapCommand} which should be used for the response if some CONDSTORE option is used
@@ -213,12 +216,12 @@ public class StoreProcessor extends AbstractMailboxProcessor<StoreRequest> {
}
}
} catch (MessageRangeException e) {
- if (session.getLog().isDebugEnabled()) {
- session.getLog().debug("Store failed for mailbox " + session.getSelected().getPath() + " because of an invalid sequence-set " + ImmutableList.copyOf(idSet), e);
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Store failed for mailbox " + session.getSelected().getPath() + " because of an invalid sequence-set " + ImmutableList.copyOf(idSet), e);
}
taggedBad(imapCommand, tag, responder, HumanReadableText.INVALID_MESSAGESET);
} catch (MailboxException e) {
- session.getLog().error("Store failed for mailbox " + session.getSelected().getPath() + " and sequence-set " + ImmutableList.copyOf(idSet), e);
+ LOGGER.error("Store failed for mailbox " + session.getSelected().getPath() + " and sequence-set " + ImmutableList.copyOf(idSet), e);
no(imapCommand, tag, responder, HumanReadableText.SAVE_FAILED);
}
}
@@ -292,8 +295,8 @@ public class StoreProcessor extends AbstractMailboxProcessor<StoreRequest> {
final int msn = selected.msn(uid);
if (msn == SelectedMailbox.NO_SUCH_MESSAGE) {
- if(session.getLog().isDebugEnabled()) {
- session.getLog().debug("No message found with uid " + uid + " in the uid<->msn mapping for mailbox " + selected.getPath().getFullName(mailboxSession.getPathDelimiter()) +" , this may be because it was deleted by a concurrent session. So skip it..");
+ if(LOGGER.isDebugEnabled()) {
+ LOGGER.debug("No message found with uid " + uid + " in the uid<->msn mapping for mailbox " + selected.getPath().getFullName(mailboxSession.getPathDelimiter()) +" , this may be because it was deleted by a concurrent session. So skip it..");
}
// skip this as it was not found in the mapping
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/main/java/org/apache/james/imap/processor/SubscribeProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/SubscribeProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/SubscribeProcessor.java
index 732a584..36b63ce 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/SubscribeProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/SubscribeProcessor.java
@@ -34,8 +34,11 @@ import org.apache.james.mailbox.SubscriptionManager;
import org.apache.james.mailbox.exception.SubscriptionException;
import org.apache.james.metrics.api.MetricFactory;
import org.apache.james.util.MDCBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class SubscribeProcessor extends AbstractSubscriptionProcessor<SubscribeRequest> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SubscribeProcessor.class);
public SubscribeProcessor(ImapProcessor next, MailboxManager mailboxManager, SubscriptionManager subscriptionManager, StatusResponseFactory factory,
MetricFactory metricFactory) {
@@ -59,8 +62,8 @@ public class SubscribeProcessor extends AbstractSubscriptionProcessor<SubscribeR
okComplete(command, tag, responder);
} catch (SubscriptionException e) {
- if (session.getLog().isInfoEnabled()) {
- session.getLog().info("Subscribe failed for mailbox " + mailboxName, e);
+ if (LOGGER.isInfoEnabled()) {
+ LOGGER.info("Subscribe failed for mailbox " + mailboxName, e);
}
unsolicitedResponses(session, responder, false);
no(command, tag, responder, HumanReadableText.GENERIC_SUBSCRIPTION_FAILURE);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/main/java/org/apache/james/imap/processor/SystemMessageProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/SystemMessageProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/SystemMessageProcessor.java
index 2054368..f42f13d 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/SystemMessageProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/SystemMessageProcessor.java
@@ -30,11 +30,14 @@ import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.util.MDCBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Processes system messages unrelated to IMAP.
*/
public class SystemMessageProcessor extends AbstractChainedProcessor<SystemMessage> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SystemMessageProcessor.class);
private final MailboxManager mailboxManager;
@@ -51,11 +54,11 @@ public class SystemMessageProcessor extends AbstractChainedProcessor<SystemMessa
forceLogout(session);
break;
default:
- session.getLog().info("Unknown system message " + message);
+ LOGGER.info("Unknown system message " + message);
break;
}
} catch (MailboxException e) {
- session.getLog().error("Cannot force logout", e);
+ LOGGER.error("Cannot force logout", e);
}
}
@@ -70,8 +73,8 @@ public class SystemMessageProcessor extends AbstractChainedProcessor<SystemMessa
private void forceLogout(ImapSession imapSession) throws MailboxException {
final MailboxSession session = ImapSessionUtils.getMailboxSession(imapSession);
if (session == null) {
- if (imapSession.getLog().isTraceEnabled()) {
- imapSession.getLog().trace("No mailbox session so no force logout needed");
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.trace("No mailbox session so no force logout needed");
}
} else {
session.close();
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/main/java/org/apache/james/imap/processor/UnsubscribeProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/UnsubscribeProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/UnsubscribeProcessor.java
index b40bc6d..675947a 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/UnsubscribeProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/UnsubscribeProcessor.java
@@ -34,8 +34,11 @@ import org.apache.james.mailbox.SubscriptionManager;
import org.apache.james.mailbox.exception.SubscriptionException;
import org.apache.james.metrics.api.MetricFactory;
import org.apache.james.util.MDCBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class UnsubscribeProcessor extends AbstractSubscriptionProcessor<UnsubscribeRequest> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(UnsubscribeProcessor.class);
public UnsubscribeProcessor(ImapProcessor next, MailboxManager mailboxManager, SubscriptionManager subscriptionManager, StatusResponseFactory factory,
MetricFactory metricFactory) {
@@ -59,8 +62,8 @@ public class UnsubscribeProcessor extends AbstractSubscriptionProcessor<Unsubscr
okComplete(command, tag, responder);
} catch (SubscriptionException e) {
- if (session.getLog().isInfoEnabled()) {
- session.getLog().info("Unsubscribe failed for mailbox " + mailboxName, e);
+ if (LOGGER.isInfoEnabled()) {
+ LOGGER.info("Unsubscribe failed for mailbox " + mailboxName, e);
}
unsolicitedResponses(session, responder, false);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
index fdd95cc..18b0d7f 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
@@ -42,6 +42,8 @@ import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.SearchQuery;
import org.apache.james.mailbox.model.UpdatedFlags;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
@@ -50,6 +52,7 @@ import com.google.common.collect.ImmutableList;
* Default implementation of {@link SelectedMailbox}
*/
public class SelectedMailboxImpl implements SelectedMailbox, MailboxListener{
+ private static final Logger LOGGER = LoggerFactory.getLogger(SelectedMailboxImpl.class);
private final Set<MessageUid> recentUids = new TreeSet<>();
@@ -121,7 +124,7 @@ public class SelectedMailboxImpl implements SelectedMailbox, MailboxListener{
try {
mailboxManager.removeListener(path, this, mailboxSession);
} catch (MailboxException e) {
- session.getLog().error("Unable to remove listener " + this + " from mailbox while closing it", e);
+ LOGGER.error("Unable to remove listener " + this + " from mailbox while closing it", e);
}
uidMsnConverter.clear();
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/main/java/org/apache/james/imap/processor/base/UnknownRequestProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/UnknownRequestProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/UnknownRequestProcessor.java
index b2e42c5..75f99dd 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/UnknownRequestProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/UnknownRequestProcessor.java
@@ -29,8 +29,10 @@ import org.apache.james.imap.api.message.response.StatusResponseFactory;
import org.apache.james.imap.api.process.ImapProcessor;
import org.apache.james.imap.api.process.ImapSession;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class UnknownRequestProcessor implements ImapProcessor {
+ private static final Logger LOGGER = LoggerFactory.getLogger(UnknownRequestProcessor.class);
private final StatusResponseFactory factory;
@@ -39,10 +41,9 @@ public class UnknownRequestProcessor implements ImapProcessor {
this.factory = factory;
}
- public ImapResponseMessage process(ImapMessage message, ImapSession session) {
- Logger logger = session.getLog();
- if (logger != null && logger.isDebugEnabled()) {
- logger.debug("Unknown message: " + message);
+ public ImapResponseMessage process(ImapMessage message) {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Unknown message: " + message);
}
final ImapResponseMessage result;
if (message instanceof ImapRequest) {
@@ -57,7 +58,7 @@ public class UnknownRequestProcessor implements ImapProcessor {
}
public void process(ImapMessage message, Responder responder, ImapSession session) {
- final ImapResponseMessage response = process(message, session);
+ final ImapResponseMessage response = process(message);
responder.respond(response);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java
index 333691f..0fea83b 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java
@@ -42,14 +42,10 @@ import org.apache.james.mime4j.dom.address.Mailbox;
import org.apache.james.mime4j.dom.address.MailboxList;
import org.apache.james.mime4j.field.address.LenientAddressParser;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class EnvelopeBuilder {
- private final Logger logger;
-
- public EnvelopeBuilder(Logger logger) {
- super();
- this.logger = logger;
- }
+ private static final Logger LOGGER = LoggerFactory.getLogger(EnvelopeBuilder.class);
public FetchResponse.Envelope buildEnvelope(Headers headers) throws MailboxException {
final String date = headerValue(headers, ImapConstants.RFC822_DATE);
@@ -145,7 +141,7 @@ public final class EnvelopeBuilder {
addresses.add(mailboxAddress);
} else {
- logger.warn("Unknown address type {}", address.getClass());
+ LOGGER.warn("Unknown address type {}", address.getClass());
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java
index 5c3ed47..7ff90c3 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java
@@ -52,10 +52,13 @@ import org.apache.james.mailbox.model.MessageResult.MimePath;
import org.apache.james.mailbox.model.MessageResultIterator;
import org.apache.james.metrics.api.MetricFactory;
import org.apache.james.util.MDCBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableList;
public class FetchProcessor extends AbstractMailboxProcessor<FetchRequest> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FetchProcessor.class);
public FetchProcessor(ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory,
MetricFactory metricFactory) {
@@ -130,12 +133,12 @@ public class FetchProcessor extends AbstractMailboxProcessor<FetchRequest> {
unsolicitedResponses(session, responder, omitExpunged, useUids);
okComplete(command, tag, responder);
} catch (MessageRangeException e) {
- if (session.getLog().isDebugEnabled()) {
- session.getLog().debug("Fetch failed for mailbox " + session.getSelected().getPath() + " because of invalid sequence-set " + ImmutableList.copyOf(idSet), e);
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Fetch failed for mailbox " + session.getSelected().getPath() + " because of invalid sequence-set " + ImmutableList.copyOf(idSet), e);
}
taggedBad(command, tag, responder, HumanReadableText.INVALID_MESSAGESET);
} catch (MailboxException e) {
- session.getLog().error("Fetch failed for mailbox " + session.getSelected().getPath() + " and sequence-set " + ImmutableList.copyOf(idSet), e);
+ LOGGER.error("Fetch failed for mailbox " + session.getSelected().getPath() + " and sequence-set " + ImmutableList.copyOf(idSet), e);
no(command, tag, responder, HumanReadableText.SEARCH_FAILED);
}
}
@@ -156,7 +159,7 @@ public class FetchProcessor extends AbstractMailboxProcessor<FetchRequest> {
* @throws MailboxException
*/
protected void processMessageRanges(ImapSession session, MessageManager mailbox, List<MessageRange> ranges, FetchData fetch, boolean useUids, MailboxSession mailboxSession, Responder responder) throws MailboxException {
- final FetchResponseBuilder builder = new FetchResponseBuilder(new EnvelopeBuilder(session.getLog()));
+ final FetchResponseBuilder builder = new FetchResponseBuilder(new EnvelopeBuilder());
FetchGroup resultToFetch = getFetchGroup(fetch);
for (MessageRange range : ranges) {
@@ -175,15 +178,15 @@ public class FetchProcessor extends AbstractMailboxProcessor<FetchRequest> {
} catch (MessageRangeException e) {
// we can't for whatever reason find the message so
// just skip it and log it to debug
- if (session.getLog().isDebugEnabled()) {
- session.getLog().debug("Unable to find message with uid " + result.getUid(), e);
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Unable to find message with uid " + result.getUid(), e);
}
} catch (MailboxException e) {
// we can't for whatever reason find parse all requested parts of the message. This may because it was deleted while try to access the parts.
// So we just skip it
//
// See IMAP-347
- session.getLog().error("Unable to fetch message with uid " + result.getUid() + ", so skip it", e);
+ LOGGER.error("Unable to fetch message with uid " + result.getUid() + ", so skip it", e);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/test/java/org/apache/james/imap/decode/main/ImapRequestStreamHandler.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/decode/main/ImapRequestStreamHandler.java b/protocols/imap/src/test/java/org/apache/james/imap/decode/main/ImapRequestStreamHandler.java
index ef30873..cd8ce27 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/decode/main/ImapRequestStreamHandler.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/decode/main/ImapRequestStreamHandler.java
@@ -35,11 +35,13 @@ import org.apache.james.imap.main.AbstractImapRequestHandler;
import org.apache.james.imap.message.request.SystemMessage;
import org.apache.james.protocols.imap.DecodingException;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
*/
public final class ImapRequestStreamHandler extends AbstractImapRequestHandler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ImapRequestStreamHandler.class);
public ImapRequestStreamHandler(ImapDecoder decoder, ImapProcessor processor, ImapEncoder encoder) {
super(decoder, processor, encoder);
@@ -64,11 +66,10 @@ public final class ImapRequestStreamHandler extends AbstractImapRequestHandler {
} else {
ImapRequestLineReader request = new ImapRequestStreamLineReader(input, output);
- final Logger logger = session.getLog();
try {
request.nextChar();
} catch (DecodingException e) {
- logger.debug("Unexpected end of line. Cannot handle request: ", e);
+ LOGGER.debug("Unexpected end of line. Cannot handle request: ", e);
abandon(output, session);
return false;
}
@@ -84,17 +85,17 @@ public final class ImapRequestStreamHandler extends AbstractImapRequestHandler {
} catch (DecodingException e) {
// Cannot clean up. No recovery is therefore possible.
// Abandon connection.
- if (logger.isInfoEnabled()) {
- logger.info("Fault during clean up: " + e.getMessage());
+ if (LOGGER.isInfoEnabled()) {
+ LOGGER.info("Fault during clean up: " + e.getMessage());
}
- logger.debug("Abandoning after fault in clean up", e);
+ LOGGER.debug("Abandoning after fault in clean up", e);
abandon(output, session);
return false;
}
result = !(ImapSessionState.LOGOUT == session.getState());
} else {
- logger.debug("Connection was abandoned after request processing failed.");
+ LOGGER.debug("Connection was abandoned after request processing failed.");
result = false;
abandon(output, session);
}
@@ -106,8 +107,8 @@ public final class ImapRequestStreamHandler extends AbstractImapRequestHandler {
try {
output.write(MAILBOX_DELETED_SIGNOFF);
} catch (IOException e) {
- session.getLog().warn("Failed to write signoff");
- session.getLog().debug("Failed to write signoff:", e);
+ LOGGER.warn("Failed to write signoff");
+ LOGGER.debug("Failed to write signoff:", e);
}
}
@@ -116,13 +117,13 @@ public final class ImapRequestStreamHandler extends AbstractImapRequestHandler {
try {
session.logout();
} catch (Throwable t) {
- session.getLog().warn("Session logout failed. Resources may not be correctly recycled.");
+ LOGGER.warn("Session logout failed. Resources may not be correctly recycled.");
}
}
try {
out.write(ABANDON_SIGNOFF);
} catch (Throwable t) {
- session.getLog().debug("Failed to write ABANDON_SIGNOFF", t);
+ LOGGER.debug("Failed to write ABANDON_SIGNOFF", t);
}
processor.process(SystemMessage.FORCE_LOGOUT, new SilentResponder(), session);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/MockLogger.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/MockLogger.java b/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/MockLogger.java
deleted file mode 100644
index ea9e752..0000000
--- a/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/MockLogger.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one *
- * or more contributor license agreements. See the NOTICE file *
- * distributed with this work for additional information *
- * regarding copyright ownership. The ASF licenses this file *
- * to you under the Apache License, Version 2.0 (the *
- * "License"); you may not use this file except in compliance *
- * with the License. You may obtain a copy of the License at *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, *
- * software distributed under the License is distributed on an *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
- * KIND, either express or implied. See the License for the *
- * specific language governing permissions and limitations *
- * under the License. *
- ****************************************************************/
-
-/**
- *
- */
-package org.apache.james.imap.decode.parser;
-
-import org.slf4j.Logger;
-import org.slf4j.Marker;
-
-
-final class MockLogger implements Logger {
-
- public void debug(Marker arg0, String arg1, Object arg2, Object arg3) {
- }
-
- public void debug(Marker arg0, String arg1, Object arg2) {
- }
-
- public void debug(Marker arg0, String arg1, Object... arg2) {
- }
-
- public void debug(Marker arg0, String arg1, Throwable arg2) {
- }
-
- public void debug(Marker arg0, String arg1) {
- }
-
- public void debug(String arg0, Object arg1, Object arg2) {
- }
-
- public void debug(String arg0, Object arg1) {
- }
-
- public void debug(String arg0, Object... arg1) {
- }
-
- public void debug(String arg0, Throwable arg1) {
- }
-
- public void debug(String arg0) {
- }
-
- public void error(Marker arg0, String arg1, Object arg2, Object arg3) {
- }
-
- public void error(Marker arg0, String arg1, Object arg2) {
- }
-
- public void error(Marker arg0, String arg1, Object... arg2) {
- }
-
- public void error(Marker arg0, String arg1, Throwable arg2) {
- }
-
- public void error(Marker arg0, String arg1) {
- }
-
- public void error(String arg0, Object arg1, Object arg2) {
- }
-
- public void error(String arg0, Object arg1) {
- }
-
- public void error(String arg0, Object... arg1) {
- }
-
- public void error(String arg0, Throwable arg1) {
- }
-
- public void error(String arg0) {
- }
-
- public String getName() {
- return null;
- }
-
- public void info(Marker arg0, String arg1, Object arg2, Object arg3) {
- }
-
- public void info(Marker arg0, String arg1, Object arg2) {
- }
-
- public void info(Marker arg0, String arg1, Object... arg2) {
- }
-
- public void info(Marker arg0, String arg1, Throwable arg2) {
- }
-
- public void info(Marker arg0, String arg1) {
- }
-
- public void info(String arg0, Object arg1, Object arg2) {
- }
-
- public void info(String arg0, Object arg1) {
- }
-
- public void info(String arg0, Object... arg1) {
- }
-
- public void info(String arg0, Throwable arg1) {
- }
-
- public void info(String arg0) {
- }
-
- public boolean isDebugEnabled() {
- return false;
- }
-
- public boolean isDebugEnabled(Marker arg0) {
- return false;
- }
-
- public boolean isErrorEnabled() {
- return false;
- }
-
- public boolean isErrorEnabled(Marker arg0) {
- return false;
- }
-
- public boolean isInfoEnabled() {
- return false;
- }
-
- public boolean isInfoEnabled(Marker arg0) {
- return false;
- }
-
- public boolean isTraceEnabled() {
- return false;
- }
-
- public boolean isTraceEnabled(Marker arg0) {
- return false;
- }
-
- public boolean isWarnEnabled() {
- return false;
- }
-
- public boolean isWarnEnabled(Marker arg0) {
- return false;
- }
-
- public void trace(Marker arg0, String arg1, Object arg2, Object arg3) {
- }
-
- public void trace(Marker arg0, String arg1, Object arg2) {
- }
-
- public void trace(Marker arg0, String arg1, Object... arg2) {
- }
-
- public void trace(Marker arg0, String arg1, Throwable arg2) {
- }
-
- public void trace(Marker arg0, String arg1) {
- }
-
- public void trace(String arg0, Object arg1, Object arg2) {
- }
-
- public void trace(String arg0, Object arg1) {
- }
-
- public void trace(String arg0, Object... arg1) {
- }
-
- public void trace(String arg0, Throwable arg1) {
- }
-
- public void trace(String arg0) {
- }
-
- public void warn(Marker arg0, String arg1, Object arg2, Object arg3) {
- }
-
- public void warn(Marker arg0, String arg1, Object arg2) {
- }
-
- public void warn(Marker arg0, String arg1, Object... arg2) {
- }
-
- public void warn(Marker arg0, String arg1, Throwable arg2) {
- }
-
- public void warn(Marker arg0, String arg1) {
- }
-
- public void warn(String arg0, Object arg1, Object arg2) {
- }
-
- public void warn(String arg0, Object arg1) {
- }
-
- public void warn(String arg0, Object... arg1) {
- }
-
- public void warn(String arg0, Throwable arg1) {
- }
-
- public void warn(String arg0) {
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java b/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
index 0b808eb..e55e9d6 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
@@ -25,7 +25,6 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.nio.charset.Charset;
-
import org.apache.james.imap.api.ImapCommand;
import org.apache.james.imap.api.ImapMessage;
import org.apache.james.imap.api.display.CharsetUtil;
@@ -100,7 +99,6 @@ public class SearchCommandParserCharsetTest {
with(same(command)),
with(equal(HumanReadableText.BAD_CHARSET)),
with(equal(StatusResponse.ResponseCode.badCharset(CharsetUtil.getAvailableCharsetNames()))));
- oneOf (session).getLog(); returnValue(new MockLogger());
}});
ImapRequestLineReader reader = new ImapRequestStreamLineReader(
new ByteArrayInputStream("CHARSET BOGUS ".getBytes("US-ASCII")),
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java b/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java
index bcb3b20..97e84b2 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java
@@ -19,7 +19,8 @@
package org.apache.james.imap.decode.parser;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -185,7 +186,6 @@ public class SearchCommandParserQuotedCharsetTest {
with(same(command)),
with(equal(HumanReadableText.BAD_CHARSET)),
with(equal(StatusResponse.ResponseCode.badCharset(CharsetUtil.getAvailableCharsetNames()))));
- oneOf(session).getLog(); returnValue(new MockLogger());
}});
ImapRequestLineReader reader = new ImapRequestStreamLineReader(
new ByteArrayInputStream("CHARSET BOGUS ".getBytes("US-ASCII")),
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/test/java/org/apache/james/imap/encode/AnnotationResponseEncoderTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/encode/AnnotationResponseEncoderTest.java b/protocols/imap/src/test/java/org/apache/james/imap/encode/AnnotationResponseEncoderTest.java
index 16e3730..66ea607 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/encode/AnnotationResponseEncoderTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/encode/AnnotationResponseEncoderTest.java
@@ -21,10 +21,7 @@ package org.apache.james.imap.encode;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import com.google.common.collect.ImmutableList;
import org.apache.james.imap.api.process.ImapSession;
import org.apache.james.imap.encode.base.ByteImapResponseWriter;
import org.apache.james.imap.encode.base.EndImapEncoder;
@@ -34,7 +31,8 @@ import org.apache.james.mailbox.model.MailboxAnnotation;
import org.apache.james.mailbox.model.MailboxAnnotationKey;
import org.junit.Before;
import org.junit.Test;
-import org.slf4j.Logger;
+
+import com.google.common.collect.ImmutableList;
public class AnnotationResponseEncoderTest {
private static final MailboxAnnotationKey PRIVATE_KEY = new MailboxAnnotationKey("/private/comment");
@@ -47,16 +45,12 @@ public class AnnotationResponseEncoderTest {
private ImapResponseComposer composer;
private AnnotationResponseEncoder encoder;
private ImapSession imapSession;
- private Logger log;
@Before
public void setUp() throws Exception {
byteImapResponseWriter = new ByteImapResponseWriter();
imapSession = mock(ImapSession.class);
- log = mock(Logger.class);
-
- when(imapSession.getLog()).thenReturn(log);
composer = new ImapResponseComposerImpl(byteImapResponseWriter, 1024);
encoder = new AnnotationResponseEncoder(new EndImapEncoder());
@@ -103,7 +97,6 @@ public class AnnotationResponseEncoderTest {
encoder.encode(response, composer, imapSession);
- verify(log).warn("There is nil data of key {} on store: ", PRIVATE_KEY.asString());
assertThat(byteImapResponseWriter.getString()).isEqualTo("* METADATA \"INBOX\" ()\r\n");
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/test/java/org/apache/james/imap/encode/FakeImapSession.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/encode/FakeImapSession.java b/protocols/imap/src/test/java/org/apache/james/imap/encode/FakeImapSession.java
index a95f60e..cbccd1b 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/encode/FakeImapSession.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/encode/FakeImapSession.java
@@ -25,13 +25,9 @@ import org.apache.james.imap.api.ImapSessionState;
import org.apache.james.imap.api.process.ImapLineHandler;
import org.apache.james.imap.api.process.ImapSession;
import org.apache.james.imap.api.process.SelectedMailbox;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class FakeImapSession implements ImapSession {
-
- private static final Logger LOG = LoggerFactory.getLogger(FakeImapSession.class);
-
+
private ImapSessionState state = ImapSessionState.NON_AUTHENTICATED;
private SelectedMailbox selectedMailbox = null;
@@ -88,11 +84,6 @@ public class FakeImapSession implements ImapSession {
attributesByKey.put(key, value);
}
}
-
- public Logger getLog() {
- return LOG;
- }
-
public boolean startTLS() {
return false;
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/test/java/org/apache/james/imap/processor/CopyProcessorTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/CopyProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/CopyProcessorTest.java
index 3bd3658..f074209 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/CopyProcessorTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/CopyProcessorTest.java
@@ -49,8 +49,6 @@ import org.apache.james.mailbox.store.MailboxMetaData;
import org.apache.james.metrics.api.NoopMetricFactory;
import org.junit.Before;
import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
@@ -58,7 +56,6 @@ import com.google.common.collect.Lists;
public class CopyProcessorTest {
public static final String TAG = "TAG";
- private static final Logger LOGGER = LoggerFactory.getLogger(CopyProcessorTest.class);
private CopyProcessor testee;
private ImapProcessor mockNextProcessor;
@@ -197,7 +194,6 @@ public class CopyProcessorTest {
when(user.getUserName()).thenReturn("username");
when(mockMailboxSession.getPersonalSpace()).thenReturn("");
when(mockMailboxSession.getUser()).thenReturn(user);
- when(mockImapSession.getLog()).thenReturn(LOGGER);
when(mockMailboxSession.getSessionId()).thenReturn(42L);
when(mockImapSession.getState()).thenReturn(ImapSessionState.SELECTED);
when(mockImapSession.getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY)).thenReturn(mockMailboxSession);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/test/java/org/apache/james/imap/processor/GetAnnotationProcessorTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetAnnotationProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetAnnotationProcessorTest.java
index 8d96a52..4adbf77 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetAnnotationProcessorTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetAnnotationProcessorTest.java
@@ -58,7 +58,6 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.MockitoAnnotations;
-import org.slf4j.Logger;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
@@ -92,7 +91,6 @@ public class GetAnnotationProcessorTest {
private GetAnnotationRequest.Builder annotationRequestBuilder;
private MailboxPath inbox;
- private Logger log;
private ArgumentCaptor<HumanReadableText> humanTextCaptor;
private ArgumentCaptor<ResponseCode> captorResponsecode;
private ArgumentCaptor<AnnotationResponse> captorAnnotationResponse;
@@ -104,7 +102,6 @@ public class GetAnnotationProcessorTest {
mockStatusResponseFactory = mock(StatusResponseFactory.class);
mockResponder = mock(ImapProcessor.Responder.class);
mockImapSession = mock(ImapSession.class);
- log = mock(Logger.class);
mailboxSession = new MockMailboxSession("username");
inbox = MailboxPath.inbox(mailboxSession);
@@ -119,7 +116,6 @@ public class GetAnnotationProcessorTest {
when(mockImapSession.getState()).thenReturn(ImapSessionState.SELECTED);
when(mockImapSession.getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY)).thenReturn(mailboxSession);
- when(mockImapSession.getLog()).thenReturn(log);
}
@Before
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/test/java/org/apache/james/imap/processor/MoveProcessorTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/MoveProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/MoveProcessorTest.java
index ca96cc8..cdf5729 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/MoveProcessorTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/MoveProcessorTest.java
@@ -52,8 +52,6 @@ import org.apache.james.mailbox.store.MailboxMetaData;
import org.apache.james.metrics.api.NoopMetricFactory;
import org.junit.Before;
import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
@@ -61,7 +59,6 @@ import com.google.common.collect.Lists;
public class MoveProcessorTest {
public static final String TAG = "TAG";
- private static final Logger LOGGER = LoggerFactory.getLogger(MoveProcessorTest.class);
private MoveProcessor testee;
private ImapProcessor mockNextProcessor;
@@ -217,7 +214,6 @@ public class MoveProcessorTest {
when(user.getUserName()).thenReturn("username");
when(mockMailboxSession.getPersonalSpace()).thenReturn("");
when(mockMailboxSession.getUser()).thenReturn(user);
- when(mockImapSession.getLog()).thenReturn(LOGGER);
when(mockMailboxSession.getSessionId()).thenReturn(42L);
when(mockImapSession.getState()).thenReturn(ImapSessionState.SELECTED);
when(mockImapSession.getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY)).thenReturn(mockMailboxSession);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java
index a604d4a..5a63525 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java
@@ -63,8 +63,6 @@ import org.jmock.integration.junit4.JUnit4Mockery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
@@ -125,9 +123,7 @@ public class SearchProcessorTest {
SelectedMailbox selectedMailbox;
private Mockery mockery = new JUnit4Mockery();
-
- private Logger logger = LoggerFactory.getLogger(this.getClass());
-
+
@Before
public void setUp() throws Exception {
serverResponseFactory = mockery.mock(StatusResponseFactory.class);
@@ -495,7 +491,6 @@ public class SearchProcessorTest {
allowing(session).setAttribute(SearchProcessor.SEARCH_MODSEQ, null);
allowing(session).getAttribute(
with(equal(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY))); will(returnValue((MailboxSession) mailboxSession));
- allowing(session).getLog(); will(returnValue(logger));
oneOf(mailbox).search(
with(equal(query)),
with(equal(mailboxSession)));will(
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/protocols/imap/src/test/java/org/apache/james/imap/processor/SetAnnotationProcessorTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/SetAnnotationProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/SetAnnotationProcessorTest.java
index 9a11a7c..c79e58e 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/SetAnnotationProcessorTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/SetAnnotationProcessorTest.java
@@ -57,7 +57,6 @@ import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.MockitoAnnotations;
-import org.slf4j.Logger;
import com.google.common.collect.ImmutableList;
@@ -78,7 +77,6 @@ public class SetAnnotationProcessorTest {
private List<MailboxAnnotation> MAILBOX_ANNOTATIONS;
private StatusResponse okResponse;
- private Logger log;
private MailboxPath inbox;
@@ -92,7 +90,6 @@ public class SetAnnotationProcessorTest {
mockStatusResponseFactory = mock(StatusResponseFactory.class);
mockResponder = mock(ImapProcessor.Responder.class);
mockImapSession = mock(ImapSession.class);
- log = mock(Logger.class);;
mockMailboxSession = new MockMailboxSession("username");
inbox = MailboxPath.inbox(mockMailboxSession);
@@ -122,8 +119,6 @@ public class SetAnnotationProcessorTest {
@Test
public void processShouldResponseNoWithNoSuchMailboxWhenManagerThrowMailboxNotFoundException() throws Exception {
- when(mockImapSession.getLog()).thenReturn(log);
-
doThrow(MailboxNotFoundException.class).when(mockMailboxManager).updateAnnotations(eq(inbox),
eq(mockMailboxSession), eq(MAILBOX_ANNOTATIONS));
@@ -137,8 +132,6 @@ public class SetAnnotationProcessorTest {
@Test
public void processShouldResponseNoWithGenericFailureWhenManagerThrowMailboxException() throws Exception {
- when(mockImapSession.getLog()).thenReturn(log);
-
doThrow(MailboxException.class).when(mockMailboxManager).updateAnnotations(eq(inbox), eq(mockMailboxSession), eq(MAILBOX_ANNOTATIONS));
processor.process(request, mockResponder, mockImapSession);
@@ -164,8 +157,6 @@ public class SetAnnotationProcessorTest {
@Test
public void processShouldResponseNoWhenManagerThrowsAnnotationException() throws Exception {
- when(mockImapSession.getLog()).thenReturn(log);
-
doThrow(AnnotationException.class).when(mockMailboxManager).updateAnnotations(eq(inbox), eq(mockMailboxSession), eq(MAILBOX_ANNOTATIONS));
processor.process(request, mockResponder, mockImapSession);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServer.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServer.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServer.java
index 887cf3b..b043428 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServer.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServer.java
@@ -19,9 +19,13 @@
package org.apache.james.imapserver.netty;
import static org.jboss.netty.channel.Channels.pipeline;
+
import java.util.concurrent.TimeUnit;
+
import javax.net.ssl.SSLEngine;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.james.imap.api.ImapConfiguration;
import org.apache.james.imap.api.ImapConstants;
import org.apache.james.imap.api.process.ImapProcessor;
@@ -33,13 +37,6 @@ import org.apache.james.protocols.netty.ChannelGroupHandler;
import org.apache.james.protocols.netty.ChannelHandlerFactory;
import org.apache.james.protocols.netty.ConnectionLimitUpstreamHandler;
import org.apache.james.protocols.netty.ConnectionPerIpLimitUpstreamHandler;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Splitter;
-import com.google.common.collect.ImmutableSet;
-
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.ChannelUpstreamHandler;
@@ -53,6 +50,10 @@ import org.jboss.netty.util.HashedWheelTimer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableSet;
+
/**
* NIO IMAP Server which use Netty.
*/
@@ -208,9 +209,9 @@ public class IMAPServer extends AbstractConfigurableAsyncServer implements ImapC
ImapChannelUpstreamHandler coreHandler;
Encryption secure = getEncryption();
if (secure!= null && secure.isStartTLS()) {
- coreHandler = new ImapChannelUpstreamHandler(hello, processor, encoder, getLogger(), compress, plainAuthDisallowed, secure.getContext(), getEnabledCipherSuites(), imapMetrics);
+ coreHandler = new ImapChannelUpstreamHandler(hello, processor, encoder, compress, plainAuthDisallowed, secure.getContext(), getEnabledCipherSuites(), imapMetrics);
} else {
- coreHandler = new ImapChannelUpstreamHandler(hello, processor, encoder, getLogger(), compress, plainAuthDisallowed, imapMetrics);
+ coreHandler = new ImapChannelUpstreamHandler(hello, processor, encoder, compress, plainAuthDisallowed, imapMetrics);
}
return coreHandler;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
index 14d1a20..5f21580 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
@@ -21,7 +21,6 @@ package org.apache.james.imapserver.netty;
import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
-import java.util.function.Supplier;
import javax.net.ssl.SSLContext;
@@ -46,13 +45,13 @@ import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
import org.jboss.netty.handler.codec.frame.TooLongFrameException;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* {@link SimpleChannelUpstreamHandler} which handles IMAP
*/
public class ImapChannelUpstreamHandler extends SimpleChannelUpstreamHandler implements NettyConstants{
-
- private final Logger logger;
+ private static final Logger LOGGER = LoggerFactory.getLogger(ImapChannelUpstreamHandler.class);
private final String hello;
@@ -73,15 +72,14 @@ public class ImapChannelUpstreamHandler extends SimpleChannelUpstreamHandler imp
private final Metric imapConnectionsMetric;
private final Metric imapCommandsMetric;
- public ImapChannelUpstreamHandler(String hello, ImapProcessor processor, ImapEncoder encoder, Logger logger, boolean compress,
+ public ImapChannelUpstreamHandler(String hello, ImapProcessor processor, ImapEncoder encoder, boolean compress,
boolean plainAuthDisallowed, ImapMetrics imapMetrics) {
- this(hello, processor, encoder, logger, compress, plainAuthDisallowed, null, null, imapMetrics);
+ this(hello, processor, encoder, compress, plainAuthDisallowed, null, null, imapMetrics);
}
- public ImapChannelUpstreamHandler(String hello, ImapProcessor processor, ImapEncoder encoder, Logger logger, boolean compress,
+ public ImapChannelUpstreamHandler(String hello, ImapProcessor processor, ImapEncoder encoder, boolean compress,
boolean plainAuthDisallowed, SSLContext context, String[] enabledCipherSuites,
ImapMetrics imapMetrics) {
- this.logger = logger;
this.hello = hello;
this.processor = processor;
this.encoder = encoder;
@@ -93,28 +91,20 @@ public class ImapChannelUpstreamHandler extends SimpleChannelUpstreamHandler imp
this.imapCommandsMetric = imapMetrics.getCommandsMetric();
}
- private Logger getLogger(final ChannelHandlerContext ctx) {
- return logger;
- }
-
@Override
public void channelBound(final ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
try (Closeable closeable = IMAPMDCContext.from(ctx, attributes)) {
- ImapSession imapsession = new NettyImapSession(ctx.getChannel(), () -> getLogger(ctx), context, enabledCipherSuites, compress, plainAuthDisallowed);
+ ImapSession imapsession = new NettyImapSession(ctx.getChannel(), context, enabledCipherSuites, compress, plainAuthDisallowed);
attributes.set(ctx.getChannel(), imapsession);
super.channelBound(ctx, e);
}
}
- private Supplier<Logger> toLogSupplier(final ChannelHandlerContext ctx) {
- return () -> getLogger(ctx);
- }
-
@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
try (Closeable closeable = IMAPMDCContext.from(ctx, attributes)) {
InetSocketAddress address = (InetSocketAddress) ctx.getChannel().getRemoteAddress();
- getLogger(ctx).info("Connection closed for " + address.getAddress().getHostAddress());
+ LOGGER.info("Connection closed for " + address.getAddress().getHostAddress());
// remove the stored attribute for the channel to free up resources
// See JAMES-1195
@@ -131,7 +121,7 @@ public class ImapChannelUpstreamHandler extends SimpleChannelUpstreamHandler imp
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
try (Closeable closeable = IMAPMDCContext.from(ctx, attributes)) {
InetSocketAddress address = (InetSocketAddress) ctx.getChannel().getRemoteAddress();
- getLogger(ctx).info("Connection established from " + address.getAddress().getHostAddress());
+ LOGGER.info("Connection established from " + address.getAddress().getHostAddress());
imapConnectionsMetric.increment();
ImapResponseComposer response = new ImapResponseComposerImpl(new ChannelImapResponseWriter(ctx.getChannel()));
@@ -146,7 +136,7 @@ public class ImapChannelUpstreamHandler extends SimpleChannelUpstreamHandler imp
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
try (Closeable closeable = IMAPMDCContext.from(ctx, attributes)) {
- getLogger(ctx).warn("Error while processing imap request", e.getCause());
+ LOGGER.warn("Error while processing imap request", e.getCause());
if (e.getCause() instanceof TooLongFrameException) {
@@ -213,10 +203,9 @@ public class ImapChannelUpstreamHandler extends SimpleChannelUpstreamHandler imp
final IOException failure = responseEncoder.getFailure();
if (failure != null) {
- final Logger logger = session.getLog();
- logger.info(failure.getMessage());
- if (logger.isDebugEnabled()) {
- logger.debug("Failed to write " + message, failure);
+ LOGGER.info(failure.getMessage());
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Failed to write " + message, failure);
}
throw failure;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapIdleStateHandler.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapIdleStateHandler.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapIdleStateHandler.java
index fd27f8d..f0d2b4a 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapIdleStateHandler.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapIdleStateHandler.java
@@ -25,12 +25,15 @@ import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.timeout.IdleState;
import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler;
import org.jboss.netty.handler.timeout.IdleStateEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* {@link IdleStateAwareChannelHandler} which will call {@link ImapSession#logout()} if the
* connected client did not receive or send any traffic in a given timeframe.
*/
public class ImapIdleStateHandler extends IdleStateAwareChannelHandler implements NettyConstants {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ImapIdleStateHandler.class);
@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception {
@@ -40,7 +43,7 @@ public class ImapIdleStateHandler extends IdleStateAwareChannelHandler implement
ImapSession session = (ImapSession) attributes.get(ctx.getChannel());
InetSocketAddress address = (InetSocketAddress) ctx.getChannel().getRemoteAddress();
- session.getLog().info("Logout client {} ({}) because it idled for too long...",
+ LOGGER.info("Logout client {} ({}) because it idled for too long...",
address.getHostName(),
address.getAddress().getHostAddress());
http://git-wip-us.apache.org/repos/asf/james-project/blob/f0170ded/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java
index 6c47b0a..d6c46e6 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java
@@ -20,7 +20,6 @@ package org.apache.james.imapserver.netty;
import java.util.HashMap;
import java.util.Map;
-import java.util.function.Supplier;
import javax.net.ssl.SSLContext;
@@ -33,24 +32,20 @@ import org.jboss.netty.handler.codec.compression.ZlibDecoder;
import org.jboss.netty.handler.codec.compression.ZlibEncoder;
import org.jboss.netty.handler.codec.compression.ZlibWrapper;
import org.jboss.netty.handler.ssl.SslHandler;
-import org.slf4j.Logger;
public class NettyImapSession implements ImapSession, NettyConstants {
-
private ImapSessionState state = ImapSessionState.NON_AUTHENTICATED;
private SelectedMailbox selectedMailbox;
private final Map<String, Object> attributesByKey = new HashMap<>();
private final SSLContext sslContext;
private final String[] enabledCipherSuites;
private final boolean compress;
- private final Supplier<Logger> log;
private final Channel channel;
private int handlerCount;
private final boolean plainAuthDisallowed;
- public NettyImapSession(Channel channel, Supplier<Logger> log, SSLContext sslContext, String[] enabledCipherSuites, boolean compress, boolean plainAuthDisallowed) {
+ public NettyImapSession(Channel channel, SSLContext sslContext, String[] enabledCipherSuites, boolean compress, boolean plainAuthDisallowed) {
this.channel = channel;
- this.log = log;
this.sslContext = sslContext;
this.enabledCipherSuites = enabledCipherSuites;
this.compress = compress;
@@ -224,13 +219,6 @@ public class NettyImapSession implements ImapSession, NettyConstants {
}
/**
- * @see org.apache.james.imap.api.process.ImapSession#getLog()
- */
- public Logger getLog() {
- return log.get();
- }
-
- /**
* @see org.apache.james.imap.api.process.ImapSession#isPlainAuthDisallowed()
*/
public boolean isPlainAuthDisallowed() {
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org