drools-legacy

Remove some inefficient exception handling

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.5
  • Fix Version/s: 2.5
  • Component/s: io
  • Labels:
    None
  • Number of attachments :
    1

Description

Using exceptions for flow control can be very inefficient on most modern VMs. This is because exception handling is rarely optimized. Thus it is highly preferable to use conditionals to test for exceptional conditions and avoid them instead of using a try/catch to knowingly trigger them.

I saw some code in org.drools.io.RuleSetReader.resolveSchema() that tested various locations for the xsd file using exceptions for flow control. Attached is a patch that eliminates that with identical functionality.

Activity

Hide
Michael Neale added a comment -

yes that could be better, checking for null streams. The impact on this would be minimal, as most of the time it will work with the first try, also its a one off loading cost.

Finally, this piece of code has been retired from Drools 3, and has been sent out the pasture (or perhaps the shed, and then shot in the head). No you can't visit it.

Show
Michael Neale added a comment - yes that could be better, checking for null streams. The impact on this would be minimal, as most of the time it will work with the first try, also its a one off loading cost. Finally, this piece of code has been retired from Drools 3, and has been sent out the pasture (or perhaps the shed, and then shot in the head). No you can't visit it.
Hide
Greg Barton added a comment -

Cool. Mind if I spelunk the code for other similar issues?

Show
Greg Barton added a comment - Cool. Mind if I spelunk the code for other similar issues?
Hide
Michael Neale added a comment -

yeah in Drools 3, go for it.

Show
Michael Neale added a comment - yeah in Drools 3, go for it.
Hide
Mark Proctor added a comment -

We have an XML Reader in Drools 3.0 now - so I'm applying this code

Show
Mark Proctor added a comment - We have an XML Reader in Drools 3.0 now - so I'm applying this code

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: