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 2020/07/17 02:24:24 UTC

[james-project] 10/31: [REFACTORING] MessageResultUtils never throws

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 344154778f224971f95ffba2b9a29da6b9622f4c
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Jul 16 11:23:51 2020 +0700

    [REFACTORING] MessageResultUtils never throws
---
 .../imap/processor/fetch/MessageResultUtils.java   | 24 +++++++---------------
 .../fetch/MailboxMessageResultUtilsTest.java       |  6 +++---
 2 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/MessageResultUtils.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/MessageResultUtils.java
index 3416670..2778747 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/MessageResultUtils.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/fetch/MessageResultUtils.java
@@ -25,9 +25,6 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
-import javax.mail.MessagingException;
-
-import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.Header;
 
 public class MessageResultUtils {
@@ -39,8 +36,6 @@ public class MessageResultUtils {
      *            {@link Header} <code>Iterator</code>
      * @return <code>List</code> of <code>MessageResult.Header<code>'s,
      * in their natural order
-     * 
-     * @throws MessagingException
      */
     public static List<Header> getAll(Iterator<Header> iterator) {
         final List<Header> results = new ArrayList<>();
@@ -62,9 +57,8 @@ public class MessageResultUtils {
      *            {@link Header} <code>Iterator</code>
      * @return <code>List</code> of <code>MessageResult.Header</code>'s, in
      *         their natural order
-     * @throws MessagingException
      */
-    public static List<Header> getMatching(String[] names, Iterator<Header> iterator) throws MailboxException {
+    public static List<Header> getMatching(String[] names, Iterator<Header> iterator) {
         final List<Header> results = new ArrayList<>(20);
         if (iterator != null) {
             while (iterator.hasNext()) {
@@ -91,13 +85,12 @@ public class MessageResultUtils {
      *            {@link Header} <code>Iterator</code>
      * @return <code>List</code> of <code>MessageResult.Header</code>'s, in
      *         their natural order
-     * @throws MessagingException
      */
-    public static List<Header> getMatching(Collection<String> names, Iterator<Header> iterator) throws MailboxException {
+    public static List<Header> getMatching(Collection<String> names, Iterator<Header> iterator) {
         return matching(names, iterator, false);
     }
 
-    private static List<Header> matching(Collection<String> names, Iterator<Header> iterator, boolean not) throws MailboxException {
+    private static List<Header> matching(Collection<String> names, Iterator<Header> iterator, boolean not) {
         final List<Header> results = new ArrayList<>(names.size());
         if (iterator != null) {
             while (iterator.hasNext()) {
@@ -112,7 +105,7 @@ public class MessageResultUtils {
         return results;
     }
 
-    private static boolean contains(Collection<String> names, Header header) throws MailboxException {
+    private static boolean contains(Collection<String> names, Header header) {
         final String headerName = header.getName();
         if (headerName != null) {
             return names.stream().anyMatch(name -> name.equalsIgnoreCase(headerName));
@@ -130,9 +123,8 @@ public class MessageResultUtils {
      *            {@link Header} <code>Iterator</code>
      * @return <code>List</code> of <code>MessageResult.Header</code>'s, in
      *         their natural order
-     * @throws MessagingException
      */
-    public static List<Header> getNotMatching(Collection<String> names, Iterator<Header> iterator) throws MailboxException {
+    public static List<Header> getNotMatching(Collection<String> names, Iterator<Header> iterator) {
         return matching(names, iterator, true);
     }
 
@@ -146,9 +138,8 @@ public class MessageResultUtils {
      *            not null
      * @return <code>MessageResult.Header</code>, or null if the header does not
      *         exist
-     * @throws MessagingException
      */
-    public static Header getMatching(String name, Iterator<Header> iterator) throws MailboxException {
+    public static Header getMatching(String name, Iterator<Header> iterator) {
         Header result = null;
         if (name != null) {
             while (iterator.hasNext()) {
@@ -173,9 +164,8 @@ public class MessageResultUtils {
      *            {@link Header} <code>Iterator</code>
      * @return <code>List</code> of <code>@MessageResult.Header</code>'s, in
      *         their natural order
-     * @throws MessagingException
      */
-    public static List<Header> getNotMatching(String[] names, Iterator<Header> iterator) throws MailboxException {
+    public static List<Header> getNotMatching(String[] names, Iterator<Header> iterator) {
         final List<Header> results = new ArrayList<>(20);
         if (iterator != null) {
             while (iterator.hasNext()) {
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/fetch/MailboxMessageResultUtilsTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/fetch/MailboxMessageResultUtilsTest.java
index c77374e..e554b51 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/fetch/MailboxMessageResultUtilsTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/fetch/MailboxMessageResultUtilsTest.java
@@ -62,7 +62,7 @@ public class MailboxMessageResultUtilsTest {
     }
 
     @Test
-    public void testGetMatching() throws Exception {
+    public void testGetMatching() {
         List<Header> results = MessageResultUtils
                 .getMatching(NAMES, headers.iterator());
         assertThat(results.size()).isEqualTo(2);
@@ -71,7 +71,7 @@ public class MailboxMessageResultUtilsTest {
     }
 
     @Test
-    public void testGetNotMatching() throws Exception {
+    public void testGetNotMatching() {
         List<Header> results = MessageResultUtils.getNotMatching(NAMES, headers
                 .iterator());
         assertThat(results.size()).isEqualTo(1);
@@ -79,7 +79,7 @@ public class MailboxMessageResultUtilsTest {
     }
 
     @Test
-    public void testGetMatchingSingle() throws Exception {
+    public void testGetMatchingSingle() {
         assertThat(MessageResultUtils.getMatching("One", headers
                 .iterator())).isEqualTo(headerOne);
         assertThat(MessageResultUtils.getMatching("Three",


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org