Permalink
Browse files

wrap CREATE_MODULE and INITIALIZE_MODULE markers with try/finally

Reviewed By: alexeylang

Differential Revision: D4961142

fbshipit-source-id: 7d25103b2839f15bb6a913eba7eb60ef0b07eb23
  • Loading branch information...
AaaChiuuu authored and facebook-github-bot committed Apr 27, 2017
1 parent ee91eb7 commit 847876704429c804311c3020fb9a5e2ebcdb643e
@@ -75,13 +75,13 @@ public static ReactModuleInfoProvider getReactModuleInfoProviderViaReflection(
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createNativeModule")
.arg("module", holder.getType())
.flush();
ReactMarker.logMarker(
ReactMarkerConstants.CREATE_MODULE_START,
holder.getType().getSimpleName());
try {
ReactMarker.logMarker(
ReactMarkerConstants.CREATE_MODULE_START,
holder.getType().getSimpleName());
nativeModule = holder.getProvider().get();
ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END);
} finally {
ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END);
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
modules.add(nativeModule);
@@ -62,11 +62,15 @@ public void processPackage(ReactPackage reactPackage) {
throw new IllegalStateException("Native Java module " + type.getSimpleName() +
" should be annotated with @ReactModule and added to a @ReactModuleList.");
}
NativeModule module;
ReactMarker.logMarker(
ReactMarkerConstants.CREATE_MODULE_START,
moduleSpec.getType().getName());
NativeModule module = moduleSpec.getProvider().get();
ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END);
try {
module = moduleSpec.getProvider().get();
} finally {
ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END);
}
moduleHolder = new ModuleHolder(module);
} else {
moduleHolder = new ModuleHolder(reactModuleInfo, moduleSpec.getProvider());
@@ -100,14 +100,18 @@ private NativeModule create() {
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createModule")
.arg("name", mName)
.flush();
NativeModule module = assertNotNull(mProvider).get();
mProvider = null;
if (mInitializeNeeded) {
doInitialize(module);
mInitializeNeeded = false;
NativeModule module;
try {
module = assertNotNull(mProvider).get();
mProvider = null;
if (mInitializeNeeded) {
doInitialize(module);
mInitializeNeeded = false;
}
} finally {
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
ReactMarker.logMarker(CREATE_MODULE_END);
}
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
ReactMarker.logMarker(CREATE_MODULE_END);
return module;
}
@@ -121,8 +125,11 @@ private void doInitialize(NativeModule module) {
}
section.flush();
ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_START, mName);
module.initialize();
ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_END);
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
try {
module.initialize();
} finally {
ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_END);
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
}
}

0 comments on commit 8478767

Please sign in to comment.