[
https://issues.apache.org/jira/browse/OFBIZ-6291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14509267#comment-14509267
]
Adam Heath commented on OFBIZ-6291:
-----------------------------------
* The patch introduces new blank lines; that should be done separately.
* int i = foo.compareTo(baz); return i <= 0; this is an anti-pattern. Remove
the use of the local variable.
Also, doing if (foo instanceof Bar), then casting with (Bar), is slower, than
just attempting the cast, and catching an exception. If the fast-path items
are done first, then no throw ever happens, and you don't waste cycles on the
instanceOf operator, and the jump that happens.
I haven't attempted to apply the patch, I was just reading it, but a smell test
seems to say -1.
Also, I have done some unit tests against ObjectType in the past; I don't know
how current they still are. The change to an instanceOf condiitional needs to
pass those tests, and, should also be done with cobertura, and the code
coverage should stay the same before and after. But that all hinges on the
currentness of the unit testing.
> Update code to check for types rather than throw ClassCastException
> -------------------------------------------------------------------
>
> Key: OFBIZ-6291
> URL: https://issues.apache.org/jira/browse/OFBIZ-6291
> Project: OFBiz
> Issue Type: Improvement
> Components: framework
> Affects Versions: Trunk
> Reporter: Gareth Carter
> Priority: Trivial
> Attachments: LocalizedConverters.patch, minilang_compare.patch
>
>
> framework/minilang/src/org/ofbiz/minilang/method/conditional/Compare.java
> framework/base/src/org/ofbiz/base/util/ObjectType.java
> framework/minilang/src/org/ofbiz/minilang/MiniLangUtil.java
> all throw ClassCastExceptions and are ignored instead of checking types
> This caused issues in debugging when adding a ClassCastException breakpoint
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)