Skip to content
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

Fix MalformedInputException in checkJUnitDependencies #1932

Merged
merged 6 commits into from
Oct 4, 2021

Conversation

CRogers
Copy link
Contributor

@CRogers CRogers commented Oct 4, 2021

Before this PR

In #1929, I had originally changed searching in sourceSet.getAllJava() to sourceSet.getAllSource() to make sure we were looking in .groovy files as well as java. I left it in there by accident. However, this has had the downside of searching through the resources too, which may contain non-utf8 encoded files. This leads to this kind of error:

java.io.UncheckedIOException: java.nio.charset.MalformedInputException: Input length = 1

as it tries to decode non-utf8 files into utf8.

Additionally, I never proved out whether groovy files are included in getAllSource and not getAllJava. Looking at the GroovyBasePlugin it actually puts the groovy source into the java source sets:

sourceSet.getAllJava().source(groovySource);
sourceSet.getAllSource().source(groovySource);

After this PR

==COMMIT_MSG==
Fix MalformedInputException when checking non-utf8 files for correct junit dependencies.
==COMMIT_MSG==

Possible downsides?

@CRogers CRogers requested a review from fawind October 4, 2021 10:55
@changelog-app
Copy link

changelog-app bot commented Oct 4, 2021

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Fix MalformedInputException when checking non-utf8 files for correct junit dependencies.

Check the box to generate changelog(s)

  • Generate changelog entry

} catch (IOException e) {
throw new RuntimeException("Unable to check file " + file, e);
return lines.anyMatch(substring);
} catch (Exception e) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

MalformedInputException is thrown as an UncheckedIOException.

@@ -164,7 +163,7 @@ private boolean hasDep(Set<ResolvedComponentResult> deps, Predicate<ModuleVersio
}

private boolean sourceSetMentionsJUnit4(SourceSet ss) {
return !ss.getAllSource()
return !ss.getAllJava()
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth adding a small comment here that getAllJava is also including groovy files.

Copy link
Contributor

@fawind fawind left a comment

Choose a reason for hiding this comment

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

Looks good!

@bulldozer-bot bulldozer-bot bot merged commit 29ba499 into develop Oct 4, 2021
@bulldozer-bot bulldozer-bot bot deleted the callumr/fix-invalid-utf8 branch October 4, 2021 12:26
@svc-autorelease
Copy link
Collaborator

Released 4.28.0

bulldozer-bot bot pushed a commit to palantir/witchcraft-api that referenced this pull request Oct 4, 2021
###### _excavator_ is a bot for automating changes across repositories.

Changes produced by the roomba/latest-baseline-oss check.

# Release Notes
## 4.28.0
| Type | Description | Link |
| ---- | ----------- | ---- |
| Fix | Fix `MalformedInputException` when checking non-utf8 files for correct junit dependencies. | palantir/gradle-baseline#1932 |



To enable or disable this check, please contact the maintainers of Excavator.
This was referenced Oct 4, 2021
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.

None yet

4 participants