[ 
https://issues.apache.org/jira/browse/BEAM-3314?focusedWorklogId=114354&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-114354
 ]

ASF GitHub Bot logged work on BEAM-3314:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 21/Jun/18 14:38
            Start Date: 21/Jun/18 14:38
    Worklog Time Spent: 10m 
      Work Description: jbonofre closed pull request #5714: [BEAM-3314] Set 
correctly host and port on RedisIO
URL: https://github.com/apache/beam/pull/5714
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/sdks/java/io/redis/src/main/java/org/apache/beam/sdk/io/redis/RedisIO.java 
b/sdks/java/io/redis/src/main/java/org/apache/beam/sdk/io/redis/RedisIO.java
index b433482530f..686883579e4 100644
--- a/sdks/java/io/redis/src/main/java/org/apache/beam/sdk/io/redis/RedisIO.java
+++ b/sdks/java/io/redis/src/main/java/org/apache/beam/sdk/io/redis/RedisIO.java
@@ -162,8 +162,7 @@ public Read withEndpoint(String host, int port) {
       checkArgument(host != null, "host can not be null");
       checkArgument(port > 0, "port can not be negative or 0");
       return builder()
-          .setConnectionConfiguration(connectionConfiguration().withHost(host))
-          .setConnectionConfiguration(connectionConfiguration().withPort(port))
+          
.setConnectionConfiguration(connectionConfiguration().withHost(host).withPort(port))
           .build();
     }
 
@@ -227,8 +226,7 @@ public ReadAll withEndpoint(String host, int port) {
       checkArgument(host != null, "host can not be null");
       checkArgument(port > 0, "port can not be negative or 0");
       return builder()
-          .setConnectionConfiguration(connectionConfiguration().withHost(host))
-          .setConnectionConfiguration(connectionConfiguration().withPort(port))
+          
.setConnectionConfiguration(connectionConfiguration().withHost(host).withPort(port))
           .build();
     }
 
@@ -359,8 +357,7 @@ public Write withEndpoint(String host, int port) {
       checkArgument(host != null, "host can not be null");
       checkArgument(port > 0, "port can not be negative or 0");
       return builder()
-          .setConnectionConfiguration(connectionConfiguration().withHost(host))
-          .setConnectionConfiguration(connectionConfiguration().withPort(port))
+          
.setConnectionConfiguration(connectionConfiguration().withHost(host).withPort(port))
           .build();
     }
 
diff --git 
a/sdks/java/io/redis/src/test/java/org/apache/beam/sdk/io/redis/RedisIOTest.java
 
b/sdks/java/io/redis/src/test/java/org/apache/beam/sdk/io/redis/RedisIOTest.java
index 445c12a0491..0a48483319d 100644
--- 
a/sdks/java/io/redis/src/test/java/org/apache/beam/sdk/io/redis/RedisIOTest.java
+++ 
b/sdks/java/io/redis/src/test/java/org/apache/beam/sdk/io/redis/RedisIOTest.java
@@ -27,6 +27,7 @@
 import org.apache.beam.sdk.values.KV;
 import org.apache.beam.sdk.values.PCollection;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -77,6 +78,24 @@ public void testWriteRead() throws Exception {
     readPipeline.run();
   }
 
+  @Test
+  public void testReadBuildsCorrectly() {
+    RedisIO.Read read = RedisIO.read().withEndpoint("test", 
111).withAuth("pass").withTimeout(5);
+    Assert.assertEquals("test", read.connectionConfiguration().host());
+    Assert.assertEquals(111, read.connectionConfiguration().port());
+    Assert.assertEquals("pass", read.connectionConfiguration().auth());
+    Assert.assertEquals(5, read.connectionConfiguration().timeout());
+  }
+
+  @Test
+  public void testWriteBuildsCorrectly() {
+    RedisIO.Write write = RedisIO.write().withEndpoint("test", 
111).withAuth("pass").withTimeout(5);
+    Assert.assertEquals("test", write.connectionConfiguration().host());
+    Assert.assertEquals(111, write.connectionConfiguration().port());
+    Assert.assertEquals("pass", write.connectionConfiguration().auth());
+    Assert.assertEquals(5, write.connectionConfiguration().timeout());
+  }
+
   /**
    * Simple embedded Redis instance wrapper to control Redis server.
    */


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 114354)
    Time Spent: 3h  (was: 2h 50m)

> RedisIO: RedisConnectionConfiguration withEndpoint does not set host 
> correctly.
> -------------------------------------------------------------------------------
>
>                 Key: BEAM-3314
>                 URL: https://issues.apache.org/jira/browse/BEAM-3314
>             Project: Beam
>          Issue Type: Bug
>          Components: io-java-redis
>    Affects Versions: 2.2.0
>            Reporter: Vinay varma
>            Assignee: Vinay varma
>            Priority: Minor
>          Time Spent: 3h
>  Remaining Estimate: 0h
>
> {code:java}
>     public Read withEndpoint(String host, int port) {
>       checkArgument(host != null, "host can not be null");
>       checkArgument(port > 0, "port can not be negative or 0");
>       return builder()
>           
> .setConnectionConfiguration(connectionConfiguration().withHost(host))
>           
> .setConnectionConfiguration(connectionConfiguration().withPort(port))
>           .build();
>     }
> {code}
> think because setConnectionConfiguration sets the object back into the 
> builder, the second set was overwriting the effects of setting the host.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to