-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Improve FailureAnalyzer for embedded datasource #11953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -520,39 +520,39 @@ public void setProperties(Map<String, String> properties) { | |||
|
|||
} | |||
|
|||
static class DataSourceBeanCreationException extends BeanCreationException { | |||
class DataSourceBeanCreationException extends BeanCreationException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether I should remove static
modifier. Maybe it would be even better to move this class outside of DataSourceProperties
?
@snicoll any feedback would be appreciated :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR but that change doesn't need to be that involved. The exception doesn't need to change but perhaps it can expose extra information.
The real deal is the failure analyzer. We need to reformat the description as described in the related issue.
} | ||
|
||
private String createDescription(DataSourceBeanCreationException cause) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's what I had in mind. What we need to do here is check if "NONE" is active and change the description accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean that such detailed description should be provided only in case when connection stands for "NONE"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No that's not what I meant. I think we need to take a step back. Can you rework your PR to change the exception to expose the EmbeddedDatabaseConnection
? Then you can adapt the message when it is NONE. The change to fix that issue must not be that large. Let me know if that works for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok for me. Actually I've reworked it similarly .
} | ||
|
||
} | ||
public Environment getEnvironment() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't expose such thing in an exception.
} | ||
message.append("."); | ||
return message.toString(); | ||
public EmbeddedDatabaseConnection getConnection() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
DataSourceBeanCreationException(EmbeddedDatabaseConnection connection, | ||
Environment environment, String property) { | ||
super(getMessage(connection, environment, property)); | ||
|
||
super("Cannot auto-configure DataSource. "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to pursue this, the message should be provided by the caller, you can't hard-code it like that.
There are two options:
Which one do you prefer @snicoll ? |
@pkostrzewa Thanks. I think that we need to revert the logic and build the message in the failure analyzer as you've done initially. But I'd like the changes to be a bit more focused. Here is what you can do:
So our exception takes now a message (see above) and an |
Currently there are no tests that covers all edge cases - maybe we should take them into consideration? |
@snicoll any feedback? |
* pr/11953: Polish "Improve FailureAnalyzer for embedded datasource" Improve FailureAnalyzer for embedded datasource
@pkostrzewa this is better but not quite there yet. Given the back and forth, I've polished your last proposal, see 2f13449 |
Fixes gh-8029.
DataSourceBeanCreationFailureAnalyzer
.