Skip to content

Commit 17ea0a6

Browse files
authored
[CQ] fix unchecked ops in AddToAppUtils (#8064)
Fixes unchecked operations that are unsafe **and** clutter our plugin runs with noise. ![image](https://github.com/user-attachments/assets/45657424-5d1a-4988-a48d-a2922c37892d) ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md
1 parent b9cd748 commit 17ea0a6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

flutter-studio/src/io/flutter/utils/AddToAppUtils.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public void modulesAdded(@NotNull Project proj, @NotNull List<? extends Module>
9191
}
9292

9393
// Derived from the method in ReflectionUtil, with the addition of setAccessible().
94-
public static <T> T getStaticFieldValue(@NotNull Class objectClass,
94+
@Nullable
95+
public static <T> T getStaticFieldValue(@NotNull Class<?> objectClass,
9596
@Nullable("null means any type") Class<T> fieldType,
9697
@NotNull @NonNls String fieldName) {
9798
try {
@@ -168,6 +169,7 @@ public void processAttached(@NotNull DebugProcess process) {
168169
PubRoot pubRoot = ((SdkAttachConfig)runConfig).pubRoot;
169170
Application app = ApplicationManager.getApplication();
170171
project.putUserData(ATTACH_IS_ACTIVE, ThreeState.fromBoolean(true));
172+
if (app == null) return;
171173
// Note: Using block comments to preserve formatting.
172174
app.invokeLater( /* After the Android launch completes, */
173175
() -> app.executeOnPooledThread( /* but not on the EDT, */
@@ -178,12 +180,16 @@ public void processAttached(@NotNull DebugProcess process) {
178180

179181
@Override
180182
public void sessionCreated(DebuggerSession session) {
181-
session.getProcess().addDebugProcessListener(dpl);
183+
if (session != null) {
184+
session.getProcess().addDebugProcessListener(dpl);
185+
}
182186
}
183187

184188
@Override
185189
public void sessionRemoved(DebuggerSession session) {
186-
session.getProcess().removeDebugProcessListener(dpl);
190+
if (session != null) {
191+
session.getProcess().removeDebugProcessListener(dpl);
192+
}
187193
}
188194
};
189195
}

0 commit comments

Comments
 (0)