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 2019/11/12 09:05:49 UTC

[httpcomponents-core] branch master updated: HTTPCLIENT-2026: Fixed URIBuilder#isOpaque() logic

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 850847c  HTTPCLIENT-2026: Fixed URIBuilder#isOpaque() logic
850847c is described below

commit 850847c88ba371c61b29ce09193595718670a9d8
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Tue Nov 12 10:00:16 2019 +0100

    HTTPCLIENT-2026: Fixed URIBuilder#isOpaque() logic
---
 httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java    | 2 +-
 .../src/test/java/org/apache/hc/core5/net/TestURIBuilder.java      | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java
index bae3c23..4857719 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java
@@ -530,7 +530,7 @@ public class URIBuilder {
     }
 
     public boolean isOpaque() {
-        return isPathEmpty();
+        return this.pathSegments == null && this.encodedPath == null;
     }
 
     public String getScheme() {
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/net/TestURIBuilder.java b/httpcore5/src/test/java/org/apache/hc/core5/net/TestURIBuilder.java
index 3e16d9a..aeabdcb 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/net/TestURIBuilder.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/net/TestURIBuilder.java
@@ -448,4 +448,11 @@ public class TestURIBuilder {
         Assert.assertThat(uri, CoreMatchers.equalTo(URI.create("ftp:/blah")));
     }
 
+    @Test
+    public void testOpaque() throws Exception {
+        final URIBuilder uriBuilder = new URIBuilder("http://host.com");
+        final URI uri = uriBuilder.build();
+        Assert.assertThat(uriBuilder.isOpaque(), CoreMatchers.equalTo(uri.isOpaque()));
+    }
+
 }