-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Introduce an abstraction over files and classpath resources. #279
Conversation
private final String path; | ||
private String resolvedPath = null; | ||
|
||
private MountableFile(final String path) { |
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.
@RequiredArgsConstructor(access = lombok.AccessLevel.PRIVATE)
*/ | ||
public String getMountablePath() { | ||
|
||
// Don't recompute if already resolved |
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.
how about @Getter(lazy = true)
?
} | ||
String internalPath = hostPath.replaceAll("[^!]*!/", ""); | ||
|
||
try (JarFile jarFile = new JarFile(urldecodedJarPath)) { |
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.
starting from Java 7 we can use Jar (aka zip) FileSystem provider:
http://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/zipfilesystemprovider.html
it also might contain path escaping OOTB (not sure here, have to re-check)
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.
Ah great - I missed this. This should make things quite a bit easier. Thanks!
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.
I tried this, but it ended up not being any clearer, so I kept as-is!
public void forClasspathResource() throws Exception { | ||
final MountableFile mountableFile = MountableFile.forClasspathResource("mappable-resource/test-resource.txt"); | ||
|
||
performChecks(mountableFile); |
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.
how about @Parameterized
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.
3 out of 5 test methods could be joined using Parameterized, but there would still have been two quite different test cases. In the end I've left as it was - it's fairly obvious what's going on, and we'd not have reduced the amount of code much by using Parameterized tests here.
@rnorth how is the progress? Do you need my help to deliver it? |
a819a30
to
aaec507
Compare
## [1.2.0] - 2017-03-12 ### Fixed - Fix various escaping issues that may arise when paths contain spaces (#263, #279) - General documentation fixes/improvements (#300, #303, #304) - Improve reliability of `ResourceReaper` when there are a large number of containers returned by `docker ps -a` (#295) ### Changed - Support Docker for Windows via TCP socket connection (#291, #297, #309). _Note that Docker Compose is not yet supported under Docker for Windows (see #306) - Expose `docker-java`'s `CreateContainerCmd` API for low-level container tweaking (#301) - Shade `org.newsclub` and Guava dependencies (#299, #292) - Add `org.testcontainers` label to all containers created by Testcontainers (#294)
This encapsulates all the complexity of generating a path that the Docker daemon is about to create a volume mount for.
This should resolve a general problem with spaces in paths, which was seen in one particular form as #263.
Additional tests for the specific problem in #263 will be added shortly.