[ 
https://issues.apache.org/jira/browse/BOOKKEEPER-782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14134961#comment-14134961
 ] 

Rakesh R commented on BOOKKEEPER-782:
-------------------------------------

bq.as I commented before, we shouldn't have setInstanceId in Cookie, as Cookie 
is an immutable object.
Actually #setInstanceId is not changing the state of the Cookie, instead it 
creates a new cookie object with the given instanceId and return back the new 
one. I think method name {{setInstanceId}} gives the impression of changing the 
state of the object. 

Is that OK, if I directly inline the logic inside Bookie.java like below?
{code}
            String instanceId = getInstanceId(zk);
            Cookie masterCookie = Cookie.generateCookie(conf);
            if (null != instanceId) {
                Cookie.Builder builder = Cookie.newBuilder(masterCookie);
                builder.setInstanceId(instanceId);
                masterCookie = builder.build();
            }
{code}

> Use builder pattern for Cookie
> ------------------------------
>
>                 Key: BOOKKEEPER-782
>                 URL: https://issues.apache.org/jira/browse/BOOKKEEPER-782
>             Project: Bookkeeper
>          Issue Type: Sub-task
>          Components: bookkeeper-server
>            Reporter: Rakesh R
>            Assignee: Rakesh R
>             Fix For: 4.3.0
>
>         Attachments: BOOKKEEPER-782.patch, BOOKKEEPER-782.patch, 
> BOOKKEEPER-782.patch, BOOKKEEPER-782.patch
>
>
> It would be good to use builder pattern for Cookie, rather than modifying the 
> fields in place.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to