[jira] [Commented] (LANG-703) StringUtils.join throws NPE when toString returns null for one of objects in collection
[ https://issues.apache.org/jira/browse/LANG-703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13045038#comment-13045038 ] Sebb commented on LANG-703: --- Seems to me that the simplest solution would be just to assume that the average entry size is 16, and not bother with trying to use the actual sizes at all. > StringUtils.join throws NPE when toString returns null for one of objects in > collection > --- > > Key: LANG-703 > URL: https://issues.apache.org/jira/browse/LANG-703 > Project: Commons Lang > Issue Type: Bug >Reporter: Ilya > Attachments: StringUtil_Join_NPE.patch > > > Try > {code} > StringUtils.join(new Object[]{ > new Object() { > @Override > public String toString() { > return null; > } > } > }, ','); > {code} > ToString should probably never return null, but it does in > javax.mail.internet.InternetAddress -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (LANG-703) StringUtils.join throws NPE when toString returns null for one of objects in collection
[ https://issues.apache.org/jira/browse/LANG-703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13044938#comment-13044938 ] Asela Illayapparachchi commented on LANG-703: - {code:java} StringUtils.join(new Object[]{ new Object() { @Override public String toString() { return ""; } }, new Object() { @Override public String toString() { return null; } } }, ','); {code} NPE occurs only when first Object toString method returns null > StringUtils.join throws NPE when toString returns null for one of objects in > collection > --- > > Key: LANG-703 > URL: https://issues.apache.org/jira/browse/LANG-703 > Project: Commons Lang > Issue Type: Bug >Reporter: Ilya > > Try > {code} > StringUtils.join(new Object[]{ > new Object() { > @Override > public String toString() { > return null; > } > } > }, ','); > {code} > ToString should probably never return null, but it does in > javax.mail.internet.InternetAddress -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (LANG-703) StringUtils.join throws NPE when toString returns null for one of objects in collection
[ https://issues.apache.org/jira/browse/LANG-703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13044925#comment-13044925 ] Asela Illayapparachchi commented on LANG-703: - I suppose following code makes the issue 3297bufSize *= ((array[startIndex] == null ? 16 : array[startIndex].toString().length()) + 1); 3298StringBuilder buf = new StringBuilder(bufSize); > StringUtils.join throws NPE when toString returns null for one of objects in > collection > --- > > Key: LANG-703 > URL: https://issues.apache.org/jira/browse/LANG-703 > Project: Commons Lang > Issue Type: Bug >Reporter: Ilya > > Try > {code} > StringUtils.join(new Object[]{ > new Object() { > @Override > public String toString() { > return null; > } > } > }, ','); > {code} > ToString should probably never return null, but it does in > javax.mail.internet.InternetAddress -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira