File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
objectbox-java/src/main/java/io/objectbox Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -151,13 +151,13 @@ public BoxStoreBuilder androidContext(Object context) {
151
151
File filesDir = getAndroidFilesDir (context );
152
152
File baseDir = new File (filesDir , "objectbox" );
153
153
if (!baseDir .exists ()) {
154
- boolean ok = baseDir .mkdirs ();
155
- if (!ok ) {
156
- System . err . print ("Could not create base dir" );
154
+ baseDir .mkdir ();
155
+ if (!baseDir . exists ()) { // check baseDir.exists() because of potential concurrent processes
156
+ throw new RuntimeException ("Could not init Android base dir at " + baseDir . getAbsolutePath () );
157
157
}
158
158
}
159
- if (!baseDir .exists () || ! baseDir . isDirectory ()) {
160
- throw new RuntimeException ("Could not init Android base dir at " + baseDir .getAbsolutePath ());
159
+ if (!baseDir .isDirectory ()) {
160
+ throw new RuntimeException ("Android base dir is not a dir: " + baseDir .getAbsolutePath ());
161
161
}
162
162
baseDirectory = baseDir ;
163
163
android = true ;
@@ -182,6 +182,9 @@ private File getAndroidFilesDir(Object context) {
182
182
if (filesDir == null ) {
183
183
throw new IllegalStateException ("Android files dir is null" );
184
184
}
185
+ if (!filesDir .exists ()) {
186
+ throw new IllegalStateException ("Android files dir does not exist" );
187
+ }
185
188
return filesDir ;
186
189
}
187
190
You can’t perform that action at this time.
0 commit comments