You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2018/09/14 18:05:15 UTC

httpcomponents-core git commit: Update the org.apache.hc.core5.http.protocol.HttpContext.setAttribute(String, Object) API to return the previous value.

Repository: httpcomponents-core
Updated Branches:
  refs/heads/master a2cb4f507 -> 5201f2b48


Update the
org.apache.hc.core5.http.protocol.HttpContext.setAttribute(String,
Object) API to return the previous value.

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

Branch: refs/heads/master
Commit: 5201f2b48e5b35e812ff39f8bb5954103d2ab328
Parents: a2cb4f5
Author: Gary Gregory <gg...@rocketsoftware.com>
Authored: Fri Sep 14 12:05:11 2018 -0600
Committer: Gary Gregory <gg...@rocketsoftware.com>
Committed: Fri Sep 14 12:05:11 2018 -0600

----------------------------------------------------------------------
 RELEASE_NOTES.txt                                             | 4 ++++
 .../org/apache/hc/core5/http/protocol/BasicHttpContext.java   | 7 +++----
 .../java/org/apache/hc/core5/http/protocol/HttpContext.java   | 4 +++-
 .../org/apache/hc/core5/http/protocol/HttpCoreContext.java    | 4 ++--
 4 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5201f2b4/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index ddb8ab2..fff6540 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -8,6 +8,10 @@ Changelog
 -------------------
 
 * Fix typo in message generated by org.apache.hc.core5.io.SocketTimeoutExceptionFactory.toMessage(int).
+  Contributed by Gary Gregory <ggregory at apache.org>
+
+* Update the org.apache.hc.core5.http.protocol.HttpContext.setAttribute(String, Object) API to return the previous value.
+  Contributed by Gary Gregory <ggregory at apache.org>
 
 
 Release 5.0-BETA3

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5201f2b4/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/BasicHttpContext.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/BasicHttpContext.java b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/BasicHttpContext.java
index 16821c7..b980de8 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/BasicHttpContext.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/BasicHttpContext.java
@@ -73,13 +73,12 @@ public class BasicHttpContext implements HttpContext {
     }
 
     @Override
-    public void setAttribute(final String id, final Object obj) {
+    public Object setAttribute(final String id, final Object obj) {
         Args.notNull(id, "Id");
         if (obj != null) {
-            this.map.put(id, obj);
-        } else {
-            this.map.remove(id);
+            return this.map.put(id, obj);
         }
+        return this.map.remove(id);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5201f2b4/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/HttpContext.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/HttpContext.java b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/HttpContext.java
index c9e259f..fd5e63f 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/HttpContext.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/HttpContext.java
@@ -80,8 +80,10 @@ public interface HttpContext {
      *
      * @param id the attribute name.
      * @param obj the attribute value.
+     * @return the previous value associated with <code>id</code>, or
+     *         <tt>null</tt> if there was no mapping for <code>id</code>.
      */
-    void setAttribute(String id, Object obj);
+    Object setAttribute(String id, Object obj);
 
     /**
      * Removes attribute with the given name from the context.

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5201f2b4/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/HttpCoreContext.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/HttpCoreContext.java b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/HttpCoreContext.java
index f8bf621..2998c0d 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/HttpCoreContext.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/HttpCoreContext.java
@@ -115,8 +115,8 @@ public class HttpCoreContext implements HttpContext {
     }
 
     @Override
-    public void setAttribute(final String id, final Object obj) {
-        context.setAttribute(id, obj);
+    public Object setAttribute(final String id, final Object obj) {
+        return context.setAttribute(id, obj);
     }
 
     @Override