Check whether ~/.docker is readable when extracting paths
Now an exception with a more meaningful message is thrown.
Fixes
@@ -168,10 +168,16 @@ public class DockerConnectionDetector {
// Try default locations as last resort
if (this.certPath == null) {
File dockerHome = new File(System.getProperty("user.home") + "/.docker");
- if (dockerHome.isDirectory() && dockerHome.list(SuffixFileFilter.PEM_FILTER).length > 0) {
+ if (dockerHome.isDirectory()) {
+ String entries[] = dockerHome.list(SuffixFileFilter.PEM_FILTER);
+ if (entries == null) {
+ throw new IOException("Can not read directory " + dockerHome + ". Please check file permissions.");
+ }
+ if (entries.length > 0) {
this.certPath = dockerHome.getAbsolutePath();
}
}
}
}
}
+}
