Skip to content

[MPMD-412] Simplify stub setup by not swallowing exceptions #226

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

Merged
merged 8 commits into from
Jun 12, 2025
Merged

Conversation

elharo
Copy link
Contributor

@elharo elharo commented Jun 7, 2025

Removing Scm objects that were thrown away by the setter not setting anything, and pushing duplicate code up into the superclass.

This PR only changes files in src/test so it should have no effect on the correctness of the actual plugin.

@elharo elharo changed the title Simplify stub setup by not swallowing exceptions [MPMD-412] Simplify stub setup by not swallowing exceptions Jun 7, 2025
@elharo elharo marked this pull request as ready for review June 7, 2025 13:58
@elharo elharo requested a review from michael-o June 7, 2025 13:59
setModel(model);
} catch (Exception e) {
}
InputStream in = new FileInputStream(getBasedir() + "/" + getPOM());
Copy link
Member

Choose a reason for hiding this comment

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

stream should be closed also in tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, if we do that the test fails when the pomReader closes the inputstream. Previously this failure was hidden by the empty catch block. This surprised me too.

Copy link
Member

Choose a reason for hiding this comment

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

In my test stream is still open after pomReader.read(is), can you show code where is closed in pomReader.read(is)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, maybe that's not where it is, but two tests broke for that inobvious reason when I initially set this up with try with resources. I had to drop the closing to make them pass.

This comment was marked as duplicate.

Copy link
Member

Choose a reason for hiding this comment

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

maybe we should not skip exception and find root cause
by the way all tests pass on CI, I also didn't have a problems locally

Copy link
Contributor Author

@elharo elharo left a comment

Choose a reason for hiding this comment

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

PTAL. I've now moved a lot of duplicate code into the superclass and removed still more code that wasn't needed. Since this is all src/test code for this repo only, it's safe to make these API breaking changes in the name of simplicity.

@elharo
Copy link
Contributor Author

elharo commented Jun 8, 2025

Previously we were suppressing the exception with an empty catch block. This seems to have hidden failures in existing tests. With PR we are no longer hiding such failures

@@ -427,7 +423,6 @@ public void testSuppressMarkerConfiguration() throws Exception {
// check if there's a link to the JXR files
str = readFile(generatedReport);

assertTrue(str.contains("/xref/def/configuration/AppSample.html#L27"));
Copy link
Member

Choose a reason for hiding this comment

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

why this assertion was removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because as best I can tell the assert is incorrect and broken and has been for some time. That is, I don't think this string is actually expected to appear in the output. However, the bad catch block hid the failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or maybe not, let me take a deeper look

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, asserts restored

@elharo elharo marked this pull request as draft June 11, 2025 12:01
@elharo elharo marked this pull request as ready for review June 11, 2025 12:12
@elharo elharo merged commit 04894a5 into master Jun 12, 2025
57 checks passed
@elharo elharo deleted the MPMD-412 branch June 12, 2025 11:15
@github-actions github-actions bot added this to the 3.26.1 milestone Jun 12, 2025
@jira-importer
Copy link

Resolve #379

1 similar comment
@jira-importer
Copy link

Resolve #379

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants