You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/12/06 08:42:14 UTC

[1/2] httpcomponents-core git commit: [HTTPCORE-496] Add API org.apache.http.protocol.UriPatternMatcher.entrySet() [Forced Update!]

Repository: httpcomponents-core
Updated Branches:
  refs/heads/master 04c420f94 -> c81801f8a (forced update)


[HTTPCORE-496] Add API org.apache.http.protocol.UriPatternMatcher.entrySet()


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/ffbe8aae
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/ffbe8aae
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/ffbe8aae

Branch: refs/heads/master
Commit: ffbe8aae055be99d949455cf296e2e16a2c57b5d
Parents: c86029c
Author: Gary Gregory <gg...@apache.org>
Authored: Tue Dec 5 14:22:34 2017 -0700
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Wed Dec 6 09:38:52 2017 +0100

----------------------------------------------------------------------
 RELEASE_NOTES.txt                                   | 10 ++++++++++
 .../hc/core5/http/protocol/UriPatternMatcher.java   | 14 ++++++++++++++
 .../core5/http/protocol/TestUriPatternMatcher.java  | 16 ++++++++++++++++
 3 files changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ffbe8aae/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 0153927..e03aece 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,3 +1,13 @@
+Release 5.0-BETA2
+-------------------
+
+Changelog
+-------------------
+
+* HTTPCORE-496: Add API org.apache.http.protocol.UriPatternMatcher.entrySet().
+  Contributed by Gary Gregory <ggregory at apache.org>
+
+
 Release 5.0-BETA1
 -------------------
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ffbe8aae/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriPatternMatcher.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriPatternMatcher.java b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriPatternMatcher.java
index ac5233e..f6bc730 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriPatternMatcher.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriPatternMatcher.java
@@ -29,6 +29,8 @@ package org.apache.hc.core5.http.protocol;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
@@ -59,6 +61,18 @@ public class UriPatternMatcher<T> implements LookupRegistry<T> {
     }
 
     /**
+     * Returns a {@link Set} view of the mappings contained in this matcher.
+     *
+     * @return  a set view of the mappings contained in this matcher.
+     *
+     * @see Map#entrySet()
+     * @since 4.4.9
+     */
+    public Set<Entry<String, T>> entrySet() {
+        return map.entrySet();
+    }
+
+    /**
      * Registers the given object for URIs matching the given pattern.
      *
      * @param pattern

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ffbe8aae/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriPatternMatcher.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriPatternMatcher.java b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriPatternMatcher.java
index 2ae9592..ef45281 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriPatternMatcher.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriPatternMatcher.java
@@ -33,6 +33,22 @@ import org.junit.Test;
 public class TestUriPatternMatcher {
 
     @Test
+    public void testEntrySet() throws Exception {
+        final Object h1 = new Object();
+        final Object h2 = new Object();
+        final Object h3 = new Object();
+
+        final UriPatternMatcher<Object> matcher = new UriPatternMatcher<>();
+        Assert.assertEquals(0, matcher.entrySet().size());
+        matcher.register("/h1", h1);
+        Assert.assertEquals(1, matcher.entrySet().size());
+        matcher.register("/h2", h2);
+        Assert.assertEquals(2, matcher.entrySet().size());
+        matcher.register("/h3", h3);
+        Assert.assertEquals(3, matcher.entrySet().size());
+    }
+
+    @Test
     public void testRegisterUnregister() throws Exception {
         final Object h1 = new Object();
         final Object h2 = new Object();


[2/2] httpcomponents-core git commit: [HTTPCORE-496] Fixed synchronization bug

Posted by ol...@apache.org.
[HTTPCORE-496] Fixed synchronization bug


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/c81801f8
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/c81801f8
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/c81801f8

Branch: refs/heads/master
Commit: c81801f8ab0bb404e17d5617e0186c1f72108f9d
Parents: ffbe8aa
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Wed Dec 6 09:30:19 2017 +0100
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Wed Dec 6 09:39:32 2017 +0100

----------------------------------------------------------------------
 .../org/apache/hc/core5/http/protocol/UriPatternMatcher.java  | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/c81801f8/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriPatternMatcher.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriPatternMatcher.java b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriPatternMatcher.java
index f6bc730..be37a22 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriPatternMatcher.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriPatternMatcher.java
@@ -28,9 +28,10 @@
 package org.apache.hc.core5.http.protocol;
 
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 import java.util.Map.Entry;
+import java.util.Set;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
@@ -68,8 +69,8 @@ public class UriPatternMatcher<T> implements LookupRegistry<T> {
      * @see Map#entrySet()
      * @since 4.4.9
      */
-    public Set<Entry<String, T>> entrySet() {
-        return map.entrySet();
+    public synchronized Set<Entry<String, T>> entrySet() {
+        return new HashSet<>(map.entrySet());
     }
 
     /**