{"action":"opened","issue":{"url":"https://api.github.com/repos/h908714124/zerobuilder/issues/1","repository_url":"https://api.github.com/repos/h908714124/zerobuilder","labels_url":"https://api.github.com/repos/h908714124/zerobuilder/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/h908714124/zerobuilder/issues/1/comments","events_url":"https://api.github.com/repos/h908714124/zerobuilder/issues/1/events","html_url":"https://github.com/h908714124/zerobuilder/issues/1","id":184703372,"number":1,"title":"Avoid unnecessary memory rentention in recycled builder","user":{"login":"jbgi","id":221929,"avatar_url":"https://avatars.githubusercontent.com/u/221929?v=3","gravatar_id":"","url":"https://api.github.com/users/jbgi","html_url":"https://github.com/jbgi","followers_url":"https://api.github.com/users/jbgi/followers","following_url":"https://api.github.com/users/jbgi/following{/other_user}","gists_url":"https://api.github.com/users/jbgi/gists{/gist_id}","starred_url":"https://api.github.com/users/jbgi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbgi/subscriptions","organizations_url":"https://api.github.com/users/jbgi/orgs","repos_url":"https://api.github.com/users/jbgi/repos","events_url":"https://api.github.com/users/jbgi/events{/privacy}","received_events_url":"https://api.github.com/users/jbgi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-23T17:39:58Z","updated_at":"2016-10-23T17:39:58Z","closed_at":null,"body":"btw, thanks for this cool project!\r\n\r\nEg. the generated impl. of the builder for [Request#put](/h908714124/zerobuilder/blob/master/examples/derive4j/src/main/java/net/zerobuilder/examples/derive4j/Request.java#L33) is currently:\r\n```java\r\n  static final class PutBuilderImpl implements PutBuilder.Path, PutBuilder.Body {\r\n    private String path;\r\n    private PutBuilderImpl() { }\r\n    [...]\r\n    @Override\r\n    public Request body(String body) {\r\n      return Request.put(path, body);\r\n    }\r\n  }\r\n```\r\nTo avoid unnecessary memory retention if `recycled` is on, the implementation should nullify all instance fields before returning the target instance. I.e.:\r\n```java\r\n  private static final class PutBuilderImpl implements PutBuilder.Path, PutBuilder.Body {\r\n    private String path;\r\n    PutBuilderImpl() { }\r\n    [...]\r\n    @Override\r\n    public Request body(String body) {\r\n      String path = this.path;\r\n      this.path = null;\r\n      return Request.put(path, body);\r\n    }\r\n  }\r\n```\r\nAlso, on a minor note, I suggest moving the `private` modifier from the constructor onto the class declaration (as in my snippet). So that javac does not need to generate of a package-private synthetic constructor.\r\n"}}
{"actor":{"display_login":"jbgi"}}