JAMES-1773 SizeGreaterThan should not accept negative or null size

Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/d77682f3
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/d77682f3
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/d77682f3

Branch: refs/heads/master
Commit: d77682f31b88a27f675daadbd57be2ada8a7dc10
Parents: 6b46cdf
Author: Benoit Tellier <[email protected]>
Authored: Wed Aug 17 12:36:07 2016 +0700
Committer: Benoit Tellier <[email protected]>
Committed: Wed Aug 31 00:59:27 2016 +0700

----------------------------------------------------------------------
 .../james/transport/matchers/SizeGreaterThan.java       |  3 +++
 .../james/transport/matchers/SizeGreaterThanTest.java   | 12 ++++++++++++
 2 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/d77682f3/mailet/standard/src/main/java/org/apache/james/transport/matchers/SizeGreaterThan.java
----------------------------------------------------------------------
diff --git 
a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SizeGreaterThan.java
 
b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SizeGreaterThan.java
index 1ab8943..78175f3 100644
--- 
a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SizeGreaterThan.java
+++ 
b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SizeGreaterThan.java
@@ -65,6 +65,9 @@ public class SizeGreaterThan extends GenericMatcher {
         } catch (NumberFormatException e) {
             throw new MessagingException("Invalid amount: " + amount);
         }
+        if (cutoff < 1) {
+            throw new MessagingException("Amount should be strictly superior 
to 0");
+        }
     }
 
     /*

http://git-wip-us.apache.org/repos/asf/james-project/blob/d77682f3/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
----------------------------------------------------------------------
diff --git 
a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
 
b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
index b197eff..3f4f805 100644
--- 
a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
+++ 
b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
@@ -78,4 +78,16 @@ public class SizeGreaterThanTest {
         FakeMatcherConfig matcherConfiguration = new 
FakeMatcherConfig("SizeGreaterThan=1mb", FakeMailContext.defaultContext());
         matcher.init(matcherConfiguration);
     }
+
+    @Test(expected = MessagingException.class)
+    public void initShouldThrowOnNullSize() throws Exception {
+        FakeMatcherConfig matcherConfiguration = new 
FakeMatcherConfig("SizeGreaterThan=0", FakeMailContext.defaultContext());
+        matcher.init(matcherConfiguration);
+    }
+
+    @Test(expected = MessagingException.class)
+    public void initShouldThrowOnNegativeSize() throws Exception {
+        FakeMatcherConfig matcherConfiguration = new 
FakeMatcherConfig("SizeGreaterThan=-1", FakeMailContext.defaultContext());
+        matcher.init(matcherConfiguration);
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to