File tree 2 files changed +21
-1
lines changed
main/java/net/snowflake/client/core
test/java/net/snowflake/client/core
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -264,7 +264,7 @@ synchronized <T> T withLock(Supplier<T> supplier) {
264
264
/** Reads the cache file. */
265
265
synchronized JsonNode readCacheFile () {
266
266
try {
267
- if (!cacheFile .exists ()) {
267
+ if (cacheFile == null || !cacheFile .exists ()) {
268
268
logger .debug ("Cache file doesn't exists. File: {}" , cacheFile );
269
269
return null ;
270
270
}
Original file line number Diff line number Diff line change @@ -107,6 +107,26 @@ public void throwWhenReadCacheFileWithPermissionDifferentThanReadWriteForUserTes
107
107
}
108
108
}
109
109
110
+ @ Test
111
+ @ RunOnLinuxOrMac
112
+ public void notThrowExceptionWhenCacheFolderIsNotAccessible () throws IOException {
113
+ try {
114
+ Files .setPosixFilePermissions (
115
+ cacheFile .getParentFile ().toPath (), PosixFilePermissions .fromString ("---------" ));
116
+ FileCacheManager fcm =
117
+ FileCacheManager .builder ()
118
+ .setCacheDirectorySystemProperty (CACHE_DIR_PROP )
119
+ .setCacheDirectoryEnvironmentVariable (CACHE_DIR_ENV )
120
+ .setBaseCacheFileName (CACHE_FILE_NAME )
121
+ .setCacheFileLockExpirationInSeconds (CACHE_FILE_LOCK_EXPIRATION_IN_SECONDS )
122
+ .build ();
123
+ assertDoesNotThrow (fcm ::readCacheFile );
124
+ } finally {
125
+ Files .setPosixFilePermissions (
126
+ cacheFile .getParentFile ().toPath (), PosixFilePermissions .fromString ("rwx------" ));
127
+ }
128
+ }
129
+
110
130
@ Test
111
131
@ RunOnLinuxOrMac
112
132
public void throwWhenOverrideCacheFileHasDifferentOwnerThanCurrentUserTest () {
You can’t perform that action at this time.
0 commit comments