Skip to content

Commit b832f48

Browse files
committed
fix: 🐛 for throwing NPE during initializing middleware android sdk
1 parent b143a45 commit b832f48

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public void initialize(ReadableMap configMap, Promise promise) {
8080
.setGlobalAttributes(attributesFromMap(globalAttributes))
8181
.setDeploymentEnvironment(deploymentEnvironment)
8282
.disableActivityLifecycleMonitoring()
83-
.build(Objects.requireNonNull(getReactApplicationContext().getCurrentActivity()).getApplication());
83+
.build((Application) getReactApplicationContext().getApplicationContext());
8484

85-
if("true".equals(sessionRecording)) {
85+
if ("true".equals(sessionRecording)) {
8686
Middleware middleware = Middleware.getInstance();
8787
middleware.startNativeRecording(getCurrentActivity());
8888
}
@@ -103,7 +103,8 @@ public void nativeCrash() {
103103
new Thread(() -> {
104104
try {
105105
Thread.sleep(2000);
106-
} catch (InterruptedException e) {}
106+
} catch (InterruptedException e) {
107+
}
107108
throw new RuntimeException("test crash");
108109
}).start();
109110
}
@@ -242,7 +243,7 @@ private ReactSpanProperties propertiesFromMap(SpanMapReader mapReader) {
242243

243244
final ReadableArray readerEvents = mapReader.getEvents();
244245
final List<EventData> newEvents = new ArrayList<>();
245-
for(int index = 0; index < readerEvents.size(); index++) {
246+
for (int index = 0; index < readerEvents.size(); index++) {
246247
final ReadableMap readableMap = readerEvents.getMap(index);
247248
final EventData eventData = EventData.create(
248249
Long.parseLong(Objects.requireNonNull(readableMap.getString("time"))),

0 commit comments

Comments
 (0)