Skip to content

Commit 37699f2

Browse files
GijsWeteringsfacebook-github-bot
authored andcommitted
[skip ci] Fix Nullsafe FIXMEs for DevServerHelper.java and mark nullsafe (facebook#50060)
Summary: Gone trough all the FIXMEs added in the previous diff by the nullsafe tool, marked the class as nullsafe and ensured no remaining violations. Changelog: [Android][Fixed] Made DevServerHelper.java nullsafe Reviewed By: rshest Differential Revision: D71126391
1 parent 7f03972 commit 37699f2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import androidx.annotation.Nullable;
1616
import com.facebook.common.logging.FLog;
1717
import com.facebook.infer.annotation.Assertions;
18+
import com.facebook.infer.annotation.Nullsafe;
1819
import com.facebook.react.bridge.ReactContext;
1920
import com.facebook.react.common.ReactConstants;
2021
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
@@ -59,6 +60,7 @@
5960
* <li>Genymotion emulator with default settings: 10.0.3.2
6061
* </ul>
6162
*/
63+
@Nullsafe(Nullsafe.Mode.LOCAL)
6264
public class DevServerHelper {
6365
private static final int HTTP_CONNECT_TIMEOUT_MS = 5000;
6466

@@ -205,11 +207,13 @@ public void openInspectorConnection() {
205207
protected Void doInBackground(Void... params) {
206208
Map<String, String> metadata =
207209
AndroidInfoHelpers.getInspectorHostMetadata(mApplicationContext);
208-
210+
String deviceName = metadata.get("deviceName");
211+
if (deviceName == null) {
212+
FLog.w(ReactConstants.TAG, "Could not get device name from Inspector Host Metadata.");
213+
return null;
214+
}
209215
mInspectorPackagerConnection =
210-
new CxxInspectorPackagerConnection(
211-
// NULLSAFE_FIXME[Parameter Not Nullable]
212-
getInspectorDeviceUrl(), metadata.get("deviceName"), mPackageName);
216+
new CxxInspectorPackagerConnection(getInspectorDeviceUrl(), deviceName, mPackageName);
213217
mInspectorPackagerConnection.connect();
214218
return null;
215219
}
@@ -448,12 +452,11 @@ public String getSourceUrl(String mainModuleName) {
448452
final Request request = new Request.Builder().url(resourceURL).build();
449453

450454
try (Response response = mClient.newCall(request).execute()) {
451-
if (!response.isSuccessful()) {
455+
if (!response.isSuccessful() || response.body() == null) {
452456
return null;
453457
}
454458

455459
try (Sink output = Okio.sink(outputFile)) {
456-
// NULLSAFE_FIXME[Nullable Dereference]
457460
Okio.buffer(response.body().source()).readAll(output);
458461
}
459462

0 commit comments

Comments
 (0)