You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2018/02/01 17:35:50 UTC

[1/2] qpid-broker-j git commit: QPID-8067: [Broker-J] Fix an evaluation of start time for queue default arrival time filter

Repository: qpid-broker-j
Updated Branches:
  refs/heads/7.0.x 5fc361733 -> 0d6b0897d


QPID-8067: [Broker-J] Fix an evaluation of start time for queue default arrival time filter


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/e5dce3c1
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/e5dce3c1
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/e5dce3c1

Branch: refs/heads/7.0.x
Commit: e5dce3c10fc96278a89661d490cdff9e506fbd01
Parents: 5fc3617
Author: Alex Rudyy <or...@apache.org>
Authored: Thu Feb 1 10:56:00 2018 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Thu Feb 1 17:35:12 2018 +0000

----------------------------------------------------------------------
 .../server/filter/ArrivalTimeFilterFactory.java |  6 +--
 .../filter/ArrivalTimeFilterFactoryTest.java    | 50 ++++++++++++++++++++
 2 files changed, 52 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/e5dce3c1/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java b/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java
index 382a3ac..fc965db 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java
@@ -36,10 +36,8 @@ public final class ArrivalTimeFilterFactory implements MessageFilterFactory
         {
             throw new IllegalArgumentException("Cannot create a filter from these arguments: " + arguments);
         }
-        String arg = arguments.get(0);
-        long startingFrom= Long.parseLong(arg);
-
-        return new ArrivalTimeFilter(System.currentTimeMillis() + startingFrom, startingFrom==0l);
+        long periodInSeconds = Long.parseLong(arguments.get(0));
+        return new ArrivalTimeFilter(System.currentTimeMillis() - periodInSeconds * 1000L, periodInSeconds == 0L);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/e5dce3c1/broker-core/src/test/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactoryTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactoryTest.java b/broker-core/src/test/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactoryTest.java
new file mode 100644
index 0000000..7c3cee0
--- /dev/null
+++ b/broker-core/src/test/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactoryTest.java
@@ -0,0 +1,50 @@
+/*
+ *
+ * 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.qpid.server.filter;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class ArrivalTimeFilterFactoryTest extends QpidTestCase
+{
+    public void testNewInstance() throws Exception
+    {
+        long currentTime = System.currentTimeMillis();
+        int periodInSeconds = 60;
+        MessageFilter filter =
+                new ArrivalTimeFilterFactory().newInstance(Collections.singletonList(String.valueOf(periodInSeconds)));
+
+        Filterable message = mock(Filterable.class);
+        when(message.getArrivalTime()).thenReturn(currentTime - periodInSeconds * 1000 - 1);
+
+        assertFalse("Message arrived before '1 minute before filter creation' should not be accepted",
+                    filter.matches(message));
+        when(message.getArrivalTime()).thenReturn(currentTime - periodInSeconds  * 1000 / 2);
+        assertTrue("Message arrived after '1 minute before filter creation' should be accepted",
+                   filter.matches(message));
+        when(message.getArrivalTime()).thenReturn(System.currentTimeMillis());
+        assertTrue("Message arrived after filter creation should be accepted", filter.matches(message));
+    }
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[2/2] qpid-broker-j git commit: QPID-8067: [Broker-J] Improve exception if x-qpid-replay-period does not contain a parseable long

Posted by kw...@apache.org.
QPID-8067: [Broker-J] Improve exception if x-qpid-replay-period does not contain a parseable long


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/0d6b0897
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/0d6b0897
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/0d6b0897

Branch: refs/heads/7.0.x
Commit: 0d6b0897d8691f16434dce171977ea69c86ffaac
Parents: e5dce3c
Author: Keith Wall <kw...@apache.org>
Authored: Thu Feb 1 17:18:11 2018 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Thu Feb 1 17:35:25 2018 +0000

----------------------------------------------------------------------
 .../server/filter/ArrivalTimeFilterFactory.java     | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/0d6b0897/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java b/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java
index fc965db..28031d3 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/filter/ArrivalTimeFilterFactory.java
@@ -34,10 +34,20 @@ public final class ArrivalTimeFilterFactory implements MessageFilterFactory
     {
         if(arguments == null || arguments.size() != 1)
         {
-            throw new IllegalArgumentException("Cannot create a filter from these arguments: " + arguments);
+            throw new IllegalArgumentException(String.format("Cannot create a %s filter from these arguments: %s",
+                                                             getType(), arguments));
+        }
+        final String periodArgument = arguments.get(0);
+        try
+        {
+            long periodInSeconds = Long.parseLong(periodArgument);
+            return new ArrivalTimeFilter(System.currentTimeMillis() - (periodInSeconds * 1000L), periodInSeconds == 0L);
+        }
+        catch (NumberFormatException e)
+        {
+            throw new IllegalArgumentException(String.format("Cannot create a %s filter.  Period value '%s' does not contain a parsable long value",
+                                                             getType(), periodArgument), e);
         }
-        long periodInSeconds = Long.parseLong(arguments.get(0));
-        return new ArrivalTimeFilter(System.currentTimeMillis() - periodInSeconds * 1000L, periodInSeconds == 0L);
     }
 
     @Override


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org