Skip to content

Commit 2bc5d3e

Browse files
committed
Randomize the Android downloaded bundle filename
1 parent 78d5705 commit 2bc5d3e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public class DevSupportManagerImpl implements
101101

102102
private static final int JAVA_ERROR_COOKIE = -1;
103103
private static final int JSEXCEPTION_ERROR_COOKIE = -1;
104-
private static final String JS_BUNDLE_FILE_NAME = "ReactNativeDevBundle.js";
104+
private static final String JS_BUNDLE_FILE_FORMAT = "ReactNativeDevBundle.%d.js";
105105
private static enum ErrorType {
106106
JS,
107107
NATIVE
@@ -229,11 +229,15 @@ public void onReceive(Context context, Intent intent) {
229229
};
230230

231231
// We store JS bundle loaded from dev server in a single destination in app's data dir.
232+
// (We randomize the name in the event that there are multiple JS bridges running.)
232233
// In case when someone schedule 2 subsequent reloads it may happen that JS thread will
233234
// start reading first reload output while the second reload starts writing to the same
234235
// file. As this should only be the case in dev mode we leave it as it is.
235236
// TODO(6418010): Fix readers-writers problem in debug reload from HTTP server
236-
mJSBundleTempFile = new File(applicationContext.getFilesDir(), JS_BUNDLE_FILE_NAME);
237+
mJSBundleTempFile = new File(
238+
applicationContext.getFilesDir(),
239+
String.format(JS_BUNDLE_FILE_FORMAT, (int)(Math.random() * 1000000))
240+
);
237241

238242
mDefaultNativeModuleCallExceptionHandler = new DefaultNativeModuleCallExceptionHandler();
239243

0 commit comments

Comments
 (0)