{"action":"opened","issue":{"url":"https://api.github.com/repos/highsource/jaxb2-basics/issues/29","labels_url":"https://api.github.com/repos/highsource/jaxb2-basics/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/highsource/jaxb2-basics/issues/29/comments","events_url":"https://api.github.com/repos/highsource/jaxb2-basics/issues/29/events","html_url":"https://github.com/highsource/jaxb2-basics/issues/29","id":80613706,"number":29,"title":"Make list setters 'null' safe","user":{"login":"cr0man","id":686422,"avatar_url":"https://avatars.githubusercontent.com/u/686422?v=3","gravatar_id":"","url":"https://api.github.com/users/cr0man","html_url":"https://github.com/cr0man","followers_url":"https://api.github.com/users/cr0man/followers","following_url":"https://api.github.com/users/cr0man/following{/other_user}","gists_url":"https://api.github.com/users/cr0man/gists{/gist_id}","starred_url":"https://api.github.com/users/cr0man/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cr0man/subscriptions","organizations_url":"https://api.github.com/users/cr0man/orgs","repos_url":"https://api.github.com/users/cr0man/repos","events_url":"https://api.github.com/users/cr0man/events{/privacy}","received_events_url":"https://api.github.com/users/cr0man/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-25T17:51:34Z","updated_at":"2015-05-25T17:51:34Z","closed_at":null,"body":"From my point of view the below code is not null safe.\r\nIf value is null, draftl.addAll(value) will throw a NullPointerException\r\n```\r\npublic void setStrings(List<String> value) {\r\n    this.strings = null;\r\n    List<String> draftl = this.getStrings();\r\n    draftl.addAll(value);\r\n}\r\n```\r\nThere are situations where I can simply do not have the chance to test the value before. Eg: setStrings() is automatically invoked by some framework (like Dozer)\r\nCould you make it look like below:\r\n```\r\npublic void setStrings(List<String> value) {\r\n    this.strings = null;\r\n    if (value != null) {\r\n      List<String> draftl = this.getStrings();\r\n      draftl.addAll(value);\r\n    }\r\n}\r\n```\r\nOne workaround is to use the direct access, but if the incoming list is unmodifiable, then we are on dangerous grounds."}}