You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Stephen Colebourne (JIRA)" <ji...@apache.org> on 2006/12/29 19:02:24 UTC
[jira] Resolved: (LANG-301) Unnecessary code in StrTokenizer
[ http://issues.apache.org/jira/browse/LANG-301?page=all ]
Stephen Colebourne resolved LANG-301.
-------------------------------------
Fix Version/s: (was: 3.0)
Resolution: Invalid
The cloneReset() method exists to enable testing.
The return null should never happen, as super.clone() should succeed. Its really just a way around the JDK flaw of the exception not being a runtime exception.
> Unnecessary code in StrTokenizer
> --------------------------------
>
> Key: LANG-301
> URL: http://issues.apache.org/jira/browse/LANG-301
> Project: Commons Lang
> Issue Type: Bug
> Affects Versions: 2.2
> Reporter: Henri Yandell
>
> In StrTokenizer, we have the following:
> 1086 public Object clone() {
> 1087 try {
> 1088 return cloneReset();
> 1089 } catch (CloneNotSupportedException ex) {
> 1090 return null;
> 1091 }
> 1092 }
> ...
> 1101 Object cloneReset() throws CloneNotSupportedException {
> 1102 StrTokenizer cloned = (StrTokenizer) super.clone();
> 1103 if (cloned.chars != null) {
> 1104 cloned.chars = (char[]) cloned.chars.clone();
> 1105 }
> 1106 cloned.reset();
> 1107 return cloned;
> 1108 }
> FindBugs just reported it because the clone() method doesn't call super.clone(). While that's not a worry (because the method it calls does), I don't understand why we're not just doing:
> public Object clone() {
> StrTokenizer cloned = (StrTokenizer) super.clone();
> if (cloned.chars != null) {
> cloned.chars = (char[]) cloned.chars.clone();
> }
> cloned.reset();
> return cloned;
> }
> and why we return null and not a runtime CloneNotSupportedException.
> Also, is there any value in StrTokenizer being Cloneable? Or is it just done for the sake of the getXxxInstance methods?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org