Commit 8a567b3
authored
Fix NPE in InPlaceEditView.reLayoutEdit (#4235)
* Fix NPE in InPlaceEditView.reLayoutEdit
InPlaceEditView.reLayoutEdit accesses sInstance.impl within a Runnable posted to callSerially. If sInstance is cleared (e.g. by stopEdit) before this Runnable executes or inside it, sInstance.impl can throw a NPE or crash if sInstance is null.
This change captures sInstance to a local variable and checks for nullity before accessing its members.
Also added a reproduction test case in HelloCodenameOneInstrumentedTest.java.
* Fix NPE in InPlaceEditView.reLayoutEdit and add reproduction test
InPlaceEditView.reLayoutEdit accesses sInstance.impl within a Runnable posted to callSerially. If sInstance is cleared (e.g. by stopEdit) before this Runnable executes or inside it, sInstance.impl can throw a NPE.
This change captures sInstance to a local variable and checks for nullity before accessing its members.
Also added a reproduction test case in scripts/hellocodenameone using a NativeInterface to reproduce the race condition on Android.
Deleted unused dead code HelloCodenameOneInstrumentedTest.java.
* Fix NPE in InPlaceEditView.reLayoutEdit and add reproduction test
InPlaceEditView.reLayoutEdit accesses sInstance.impl within a Runnable posted to callSerially. If sInstance is cleared (e.g. by stopEdit) before this Runnable executes or inside it, sInstance.impl can throw a NPE.
This change captures sInstance to a local variable and checks for nullity before accessing its members.
Also added a reproduction test case in scripts/hellocodenameone using a NativeInterface to reproduce the race condition on Android.
Deleted unused dead code HelloCodenameOneInstrumentedTest.java.
Added iOS stub for the reproduction test.
Updated test to avoid blocking EDT during wait.
* Fix NPE in InPlaceEditView.reLayoutEdit and add reproduction test
InPlaceEditView.reLayoutEdit accesses sInstance.impl within a Runnable posted to callSerially. If sInstance is cleared (e.g. by stopEdit) before this Runnable executes or inside it, sInstance.impl can throw a NPE.
This change captures sInstance to a local variable and checks for nullity before accessing its members.
Also added a reproduction test case in scripts/hellocodenameone using a NativeInterface to reproduce the race condition on Android.
Deleted unused dead code HelloCodenameOneInstrumentedTest.java.
Added iOS stub (ObjC) for the reproduction test to avoid compilation errors.
Updated test to avoid blocking EDT during wait.
* Restore iOS Java stub for InPlaceEditViewNativeImpl
Restored scripts/hellocodenameone/ios/src/main/java/com/codenameone/examples/hellocodenameone/InPlaceEditViewNativeImpl.java which is required for NativeLookup on iOS, complementing the Objective-C implementation.
Confirmed Android implementation exists.
* Remove iOS implementation of InPlaceEditViewNativeImpl
Removed the iOS Java stub and Objective-C implementation files. InPlaceEditViewNativeImpl should only exist in the Android subproject. On iOS, NativeLookup will simply not find the implementation, which is the desired behavior (skipping the test). This also avoids compilation issues related to missing native headers on iOS when the Java class is present.
* Refactor InPlaceEditViewTest to use callback and adapt harness
Updated InPlaceEditViewNativeImpl (Android) to use direct imports (removing reflection) and a callback for result reporting.
Added ReproductionCallback interface.
Updated iOS stub and ObjC files to match the new signature.
Adapted BaseTest and Cn1ssDeviceRunner to support explicit test failure reporting and screenshot status logging.
InPlaceEditViewTest now waits for the callback and fails if an error occurs during reproduction.
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>1 parent 2e316af commit 8a567b3
File tree
11 files changed
+182
-385
lines changed- Ports/Android/src/com/codename1/impl/android
- scripts
- android/tests
- hellocodenameone
- android/src/main/java/com/codenameone/examples/hellocodenameone
- common/src/main/java/com/codenameone/examples/hellocodenameone
- tests
- ios/src/main
- java/com/codenameone/examples/hellocodenameone
- objectivec
11 files changed
+182
-385
lines changedLines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1540 | 1540 | | |
1541 | 1541 | | |
1542 | 1542 | | |
1543 | | - | |
1544 | | - | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
1545 | 1547 | | |
1546 | 1548 | | |
1547 | 1549 | | |
| |||
1572 | 1574 | | |
1573 | 1575 | | |
1574 | 1576 | | |
| 1577 | + | |
1575 | 1578 | | |
1576 | 1579 | | |
1577 | 1580 | | |
| |||
0 commit comments