Skip to content

Conversation

ashastr
Copy link
Contributor

@ashastr ashastr commented Feb 22, 2019

No description provided.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 22, 2019
@snicoll snicoll self-requested a review February 22, 2019 08:37
@snicoll snicoll changed the title Implement failure analyzer for Flyway's bootstrap failure Fixes #15674 Add failure analyzer for Flyway's bootstrap failure Feb 27, 2019
@snicoll snicoll self-assigned this Feb 27, 2019
Copy link
Member

@snicoll snicoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for submitting your first pull request to Spring Boot. I've added a few comments, can you please have a look? Let me know if something isn't clear.

* limitations under the License.
*/

package org.springframework.boot.diagnostics.analyzer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This failure analyzer should belong with the rest of the Flyway support. For insance HikariDriverConfigurationFailureAnalyzer is in the jdbc package of the auto-configuration module. Can you please move this class to the auto-configuration module as well (in the flyway package)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I have moved this class under flyway package of auto-configuration module.


/**
* A {@code FailureAnalyzer} that performs analysis of failures caused by a
* {@code IllegalStateException}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't really do that. The purpose of a failure analyzer is to tracker a specific exception. This is a sign that we need to provide such exception if it doesn't exist yet to avoid magic string comparison.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand. I have created a new exception as advised.

@Override
protected FailureAnalysis analyze(Throwable rootFailure, IllegalStateException cause) {
if (cause.getMessage().startsWith(MISSING_SCRIPT_MESSAGE)) {
String location = StringUtils.substringBetween(cause.getMessage(), "[", "]");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than parsing the error message, please create a FlywayMigrationScriptNotFoundException or something that could contain the original locations as an argument?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a case of no location configured at all which would fit here and would require a slightly different failure analysis.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FlywayMigrationScriptNotFoundException is now taking location as an argument.

I have added a separate comment on this thread about failure in case of no location configured.

private final FlywayMigrationScriptMissingFailureAnalyzer analyzer = new FlywayMigrationScriptMissingFailureAnalyzer();

@Test
public void analysisForFlywayScriptMissingFailureWhenIllegalStateExceptionIsForFlyway() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should change with the case where none of the locations exist and one case where no location is provided (see FlywayAutoConfiguration).

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Feb 27, 2019
…ule and add new flywayMigrationScriptMissing exception Fixes gh-15674
@ashastr
Copy link
Contributor Author

ashastr commented Feb 28, 2019

Thanks for the review comments. I have made the suggested changes for the no location exists scenario.

About the second scenario "where no location is provided",
Are you referring to a scenario when a user overrides the default property "checkLocation" and chooses to turn it off?

@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Feb 28, 2019
@snicoll snicoll added this to the 2.2.0.M1 milestone Feb 28, 2019
snicoll pushed a commit that referenced this pull request Feb 28, 2019
@snicoll snicoll closed this in d5448eb Feb 28, 2019
snicoll added a commit that referenced this pull request Feb 28, 2019
* pr/16015:
  Polish "Add failure analyzer for Flyway's bootstrap failure"
  Add failure analyzer for Flyway's bootstrap failure
@snicoll
Copy link
Member

snicoll commented Feb 28, 2019

@anandshastri1990 thank you very much for making your first contribution to Spring Boot. Your contribution is now merged on master with a polish commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants