-
Notifications
You must be signed in to change notification settings - Fork 80
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
File extension is now preserved by the temp file caching strategy #225
Conversation
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.
Great change, thanks @lucaspcram!
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.
Looks good, just have one question about hardcoded paths, that I did not catch before.
@@ -78,6 +80,10 @@ private void compareFetchedResource(final URI resourceURI, final Resource golden | |||
.get("src/test/resources/org/openstreetmap/atlas/utilities/configuration/feature.json") | |||
.toAbsolutePath(); | |||
private static final URI LOCAL_TEST_FILE_2_URI = LOCAL_TEST_FILE_2.toUri(); | |||
private static final Path LOCAL_TEST_FILE_3 = Paths | |||
.get("src/test/resources/org/openstreetmap/atlas/utilities/caching/fileNoExt") |
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 might not be the right place to say this, but, it would be better to not have hardcoded paths there (in case we change package names in the future, this will be missed).
How about doing this in the tests below:
ByteArrayResource originalFileBytes = new ByteArrayResource();
originalFileBytes.copyFrom(new InputStreamresource(() ->
CachingTests.class.getResourceAsStream("fileNoExt")));
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.
This is a good call. I think there are a lot of places in the codebase that could use this change.
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.
Nice set of changes.
URI resourceUri; | ||
try | ||
{ | ||
resourceUri = CachingTests.class.getResource(LOG4J_PROPERTIES).toURI(); |
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.
Is log4j.properties used as a random file to test the cache, or did you need it for configuring log4j here?
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 just a random, non-empty file to test the caching. Should I change it? (I assume it may have logging implications.)
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!
Description:
The file extension of a cached resource is now preserved by the temporary file strategy. This makes the changes in this PR unnecessary.
Potential Impact:
This will technically impact any users of
SystemTemporaryFileCachingStrategy
. But the impact is all internal and will go unnoticed by users of the class.Unit Test Approach:
Added some additional testing to
CachingTests.testBaseCacheWithGivenStrategy
to make sure the file extension saving is working.Test Results:
Test results passed. Additionally, I manually verified that file extensions are saved correctly by checking my local tmp file system.
In doubt: Contributing Guidelines