Skip to content

Add FileClasspathEntry validation #93

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

therepanic
Copy link

Since it doesn't make sense to throw a non-directory or jar file into FileClasspathEntry, I think it's worth adding a check to the constructor.

Fix: #59

@therepanic therepanic force-pushed the add-FileClasspathEntry-validation branch from 310cce7 to 147ca8d Compare April 17, 2025 18:45
Copy link
Collaborator

@rwinch rwinch left a 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! Can you please add tests for this? I've also provided feedback inline.

public FileClasspathEntry(String filePath) {
File file = new File(filePath);
if (!file.isDirectory() && !file.getName().toLowerCase().endsWith("jar")) {
throw new IllegalArgumentException("File must be a jar file or directory");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please include the file path in the error message?

Copy link
Author

Choose a reason for hiding this comment

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

Will it be enough for us?:

throw new IllegalArgumentException("File must be a jar file or directory " + filePath);

@therepanic therepanic force-pushed the add-FileClasspathEntry-validation branch 2 times, most recently from c2e250e to 5853212 Compare June 30, 2025 23:19
@therepanic therepanic requested a review from rwinch June 30, 2025 23:19
Signed-off-by: Andrey Litvitski <[email protected]>
@therepanic therepanic force-pushed the add-FileClasspathEntry-validation branch from 5853212 to 69b5789 Compare June 30, 2025 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FileClasspathEntry validation
2 participants