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 ro...@apache.org on 2019/10/23 09:02:52 UTC
[james-project] branch master updated (2c460a2 -> b26313c)
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git.
from 2c460a2 JAMES-2926 Fix injection for MailQueueFactory
new e90031e JAMES-2928 Make GenericMailet's precondition policy consistent
new b26313c JAMES-2928 WithPriority's checkstyle fixes
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../main/java/org/apache/mailet/base/GenericMailet.java | 10 +++++++---
.../org/apache/james/transport/mailets/WithPriority.java | 16 ++++++++--------
2 files changed, 15 insertions(+), 11 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 02/02: JAMES-2928 WithPriority's checkstyle fixes
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit b26313c471034be571b9e2c66e381a4f1f52688c
Author: Gautier DI FOLCO <gd...@linagora.com>
AuthorDate: Tue Oct 22 11:40:33 2019 +0200
JAMES-2928 WithPriority's checkstyle fixes
---
.../org/apache/james/transport/mailets/WithPriority.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WithPriority.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WithPriority.java
index 3fc9776..3138f4b 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WithPriority.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WithPriority.java
@@ -50,17 +50,17 @@ public class WithPriority extends GenericMailet {
@Override
public void init() throws MessagingException {
Integer priorityRaw = Optional.ofNullable(getInitParameter("priority", null))
- .map(Integer::valueOf)
- .orElseThrow(() -> new IllegalArgumentException("'priority' init parameter is compulsory"));
+ .map(Integer::valueOf)
+ .orElseThrow(() -> new IllegalArgumentException("'priority' init parameter is compulsory"));
if (priorityRaw < 0 || priorityRaw > 9) {
throw new IllegalArgumentException("Invalid priority: Priority should be from 0 to 9");
- }
- priority = new Attribute(MailPrioritySupport.MAIL_PRIORITY, AttributeValue.of(priorityRaw));
}
+ priority = new Attribute(MailPrioritySupport.MAIL_PRIORITY, AttributeValue.of(priorityRaw));
+ }
- @Override
- public void service(Mail mail) throws MessagingException {
- mail.setAttribute(priority);
- }
+ @Override
+ public void service(Mail mail) throws MessagingException {
+ mail.setAttribute(priority);
}
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 01/02: JAMES-2928 Make GenericMailet's precondition
policy consistent
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit e90031e9562ccd69003cd0da176aeff8f200300b
Author: Gautier DI FOLCO <gd...@linagora.com>
AuthorDate: Tue Oct 22 11:38:33 2019 +0200
JAMES-2928 Make GenericMailet's precondition policy consistent
---
.../src/main/java/org/apache/mailet/base/GenericMailet.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/mailet/base/src/main/java/org/apache/mailet/base/GenericMailet.java b/mailet/base/src/main/java/org/apache/mailet/base/GenericMailet.java
index 9e3ea5d..6dce7c5 100644
--- a/mailet/base/src/main/java/org/apache/mailet/base/GenericMailet.java
+++ b/mailet/base/src/main/java/org/apache/mailet/base/GenericMailet.java
@@ -37,6 +37,7 @@ import org.apache.mailet.MailetContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
/**
@@ -57,6 +58,7 @@ public abstract class GenericMailet implements Mailet, MailetConfig {
private static final String NO = "no";
private static final String TRUE = "true";
private static final String FALSE = "false";
+ private static final String CONFIG_IS_NULL_ERROR_MESSAGE = "Mailet configuration must be set before getInitParameter is called.";
private MailetConfig config = null;
@@ -82,9 +84,7 @@ public abstract class GenericMailet implements Mailet, MailetConfig {
* @throws NullPointerException before {@link #init(MailetConfig)}
*/
public boolean getInitParameter(String name, boolean defaultValue) {
- if (config == null) {
- throw new NullPointerException("Mailet configuration must be set before getInitParameter is called.");
- }
+ Preconditions.checkState(config != null, CONFIG_IS_NULL_ERROR_MESSAGE);
return MailetUtil.getInitParameter(config, name).orElse(defaultValue);
}
@@ -126,6 +126,7 @@ public abstract class GenericMailet implements Mailet, MailetConfig {
*/
@Override
public String getInitParameter(String name) {
+ Preconditions.checkState(config != null, CONFIG_IS_NULL_ERROR_MESSAGE);
return config.getInitParameter(name);
}
@@ -142,6 +143,7 @@ public abstract class GenericMailet implements Mailet, MailetConfig {
* @return a String containing the value of the initalization parameter
*/
public String getInitParameter(String name, String defValue) {
+ Preconditions.checkState(config != null, CONFIG_IS_NULL_ERROR_MESSAGE);
String res = config.getInitParameter(name);
if (res == null) {
return defValue;
@@ -163,6 +165,7 @@ public abstract class GenericMailet implements Mailet, MailetConfig {
*/
@Override
public Iterator<String> getInitParameterNames() {
+ Preconditions.checkState(config != null, CONFIG_IS_NULL_ERROR_MESSAGE);
return config.getInitParameterNames();
}
@@ -206,6 +209,7 @@ public abstract class GenericMailet implements Mailet, MailetConfig {
*/
@Override
public String getMailetName() {
+ Preconditions.checkState(config != null, CONFIG_IS_NULL_ERROR_MESSAGE);
return config.getMailetName();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org