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

File extension is now preserved by the temp file caching strategy #225

Merged
merged 5 commits into from
Sep 26, 2018
Merged

File extension is now preserved by the temp file caching strategy #225

merged 5 commits into from
Sep 26, 2018

Conversation

lucaspcram
Copy link
Contributor

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

MikeGost
MikeGost previously approved these changes Sep 25, 2018
Copy link
Contributor

@MikeGost MikeGost left a 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!

Copy link
Collaborator

@matthieun matthieun 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, 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")
Copy link
Collaborator

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")));

Copy link
Contributor Author

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.

MikeGost
MikeGost previously approved these changes Sep 25, 2018
Copy link
Contributor

@MikeGost MikeGost left a 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();
Copy link
Collaborator

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?

Copy link
Contributor Author

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.)

Copy link
Collaborator

@matthieun matthieun left a comment

Choose a reason for hiding this comment

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

Thanks!

@matthieun matthieun merged commit b8da42c into osmlab:dev Sep 26, 2018
@lucaspcram lucaspcram deleted the cache branch September 26, 2018 20:41
@matthieun matthieun added this to the 5.1.13 milestone Oct 17, 2018
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.

3 participants