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) {
151151 File filesDir = getAndroidFilesDir (context );
152152 File baseDir = new File (filesDir , "objectbox" );
153153 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 () );
157157 }
158158 }
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 ());
161161 }
162162 baseDirectory = baseDir ;
163163 android = true ;
@@ -182,6 +182,9 @@ private File getAndroidFilesDir(Object context) {
182182 if (filesDir == null ) {
183183 throw new IllegalStateException ("Android files dir is null" );
184184 }
185+ if (!filesDir .exists ()) {
186+ throw new IllegalStateException ("Android files dir does not exist" );
187+ }
185188 return filesDir ;
186189 }
187190
You can’t perform that action at this time.
0 commit comments