Details
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
-
MULE-4130
Create a flag for disabling the validateConnection() "blip" for performance reasons
-
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.