JIRA

  • Log In Access more options
    • Online Help
    • GreenHopper Help
    • Agile Answers
    • Use Agile By Default
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Agile Access more options (Alt+g)
  • Create Issue
  • Mule
  • MULE-4147

Current contract for Connectable.validateConnection() is wrong

  • Agile Board
  • More Actions
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: ITR15, 2.2
  • Fix Version/s: ITR15, 2.2
  • Component/s: Core: API
  • Labels:
    None
  • User impact:
    Medium
  • Similar Issues:
    None

Description

Current method signature and docs:

/**

  • Test whether the connector is able to connect to its resource(s).
  • This will allow a retry policy to go into effect in the case of failure.
    *
  • @return true if the connector is able to connect successfully
  • @throws Exception if the connector fails to connect
    */
    boolean validateConnection() throws Exception;

However, the AbstractConnector uses it as:

if (!validateConnection())

{ throw new ConnectException(MessageFactory.createStaticMessage("Unable to connect to resource"), null); }

According to the doc, an exception is thrown, thus the code block is never executable.

Instead, the signature must be changed to throw no exception, but return true/false.

Issue Links

relates to

Improvement - An improvement or enhancement to an existing feature or task. MULE-4130 Create a flag for disabling the validateConnection() "blip" for performance reasons

  • Minor - Minor loss of function, or other problem where easy workaround is present.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
  • Transitions
  • Commits
  • Source
  • Builds
Hide
Permalink
Travis Carlson added a comment - 08/Feb/09 01:24 PM

Yes, I agree it's a bit ambiguous, the boolean return value is because I was thinking there might be a transport where you could actually test the connection cleanly without necessary generating an exception (e.g., "return resource.IsConnected();")

If you change it to:
boolean validateConnection();
then the original cause of failure will not be shown in the stack trace.

Maybe it's better to change it to:
void validateConnection() throws Exception;
and we'll assume the test was sucessful if no exception was thrown. Then the if statement can be removed completely from AbstractConnector.

Show
Travis Carlson added a comment - 08/Feb/09 01:24 PM Yes, I agree it's a bit ambiguous, the boolean return value is because I was thinking there might be a transport where you could actually test the connection cleanly without necessary generating an exception (e.g., "return resource.IsConnected();") If you change it to: boolean validateConnection(); then the original cause of failure will not be shown in the stack trace. Maybe it's better to change it to: void validateConnection() throws Exception; and we'll assume the test was sucessful if no exception was thrown. Then the if statement can be removed completely from AbstractConnector.
Hide
Permalink
Andrew Perepelytsya added a comment - 09/Feb/09 08:39 AM

On a related note, there is this org.mule.transport.AbstractConnectable#validate() , which is trivial and never called anywhere. I'm tempted to remove it to avoid duplication and confusion.

Show
Andrew Perepelytsya added a comment - 09/Feb/09 08:39 AM On a related note, there is this org.mule.transport.AbstractConnectable#validate() , which is trivial and never called anywhere. I'm tempted to remove it to avoid duplication and confusion.
Hide
Permalink
Andrew Perepelytsya added a comment - 09/Feb/09 11:52 AM

Committed http://fisheye.codehaus.org/changelog/mule/?cs=13978 for a review, read the commit log for details.

Show
Andrew Perepelytsya added a comment - 09/Feb/09 11:52 AM Committed http://fisheye.codehaus.org/changelog/mule/?cs=13978 for a review, read the commit log for details.
Hide
Permalink
Andrew Perepelytsya added a comment - 09/Feb/09 01:07 PM

Closing based on the feedback

Show
Andrew Perepelytsya added a comment - 09/Feb/09 01:07 PM Closing based on the feedback

People

  • Assignee:
    Andrew Perepelytsya
    Reporter:
    Andrew Perepelytsya
Vote (0)
Watch (0)

Dates

  • Created:
    06/Feb/09 07:03 PM
    Updated:
    09/Feb/09 01:07 PM
    Resolved:
    09/Feb/09 01:07 PM

Agile

  • View on Board
  • Atlassian JIRA (v5.0.7#734-sha1:8ad78a6)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for MuleForge. Try JIRA - bug tracking software for your team.