Conversation
✅ PR Checklist Validation PassedStatus: All 7 checklist items completed 🎉 This PR meets all requirements and is ready for review! This validation ensures all PR requirements are met before merging. |
| commands.put("addBuySellMark", 8); | ||
| commands.put("removeBuySellMark", 9); | ||
| commands.put("updateBuySellMark", 10); | ||
| commands.put("getBuySellMarks", 11); |
There was a problem hiding this comment.
🔴 MapBuilder.of() returns unmodifiable map, calling put() will throw UnsupportedOperationException
The code attempts to add entries to a map returned by MapBuilder.of(), which returns an unmodifiable map in React Native. Calling put() on this map will throw an UnsupportedOperationException at runtime, preventing the buy/sell mark commands from being registered.
Root Cause
At RNKLineView.java:89-97, MapBuilder.of() creates an immutable map with 7 entries. Then at lines 100-103, the code attempts to add 4 more entries using put(), which will fail:
Map<String, Integer> commands = MapBuilder.of(
"updateLastCandlestick", 1,
...
);
commands.put("addBuySellMark", 8); // Throws UnsupportedOperationExceptionImpact: The app will crash when getCommandsMap() is called, preventing any command dispatching from working on Android.
| commands.put("addBuySellMark", 8); | |
| commands.put("removeBuySellMark", 9); | |
| commands.put("updateBuySellMark", 10); | |
| commands.put("getBuySellMarks", 11); | |
| Map<String, Integer> commands = new java.util.HashMap<>(); | |
| commands.put("updateLastCandlestick", 1); | |
| commands.put("addCandlesticksAtTheEnd", 2); | |
| commands.put("addCandlesticksAtTheStart", 3); | |
| commands.put("addOrderLine", 4); | |
| commands.put("removeOrderLine", 5); | |
| commands.put("updateOrderLine", 6); | |
| commands.put("getOrderLines", 7); | |
| commands.put("addBuySellMark", 8); | |
| commands.put("removeBuySellMark", 9); | |
| commands.put("updateBuySellMark", 10); | |
| commands.put("getBuySellMarks", 11); | |
| return commands; | |
| } |
Was this helpful? React with 👍 or 👎 to provide feedback.
| final KLineEntity point = (KLineEntity) view.getItem(index); | ||
|
|
||
| // Get the basic selectedItemList | ||
| List<Map<String, Object>> itemList = new ArrayList<>(point.selectedItemList); |
There was a problem hiding this comment.
🔴 NullPointerException when selectedItemList is null in drawSelector
The code creates a new ArrayList from point.selectedItemList without null checking, but selectedItemList can be null when parsed from input data.
Root Cause
In HTKLineConfigManager.java:249, selectedItemList is set directly from the map without null checking:
entity.selectedItemList = (List<Map<String, Object>>) keyValue.get("selectedItemList");If the key doesn't exist, this sets selectedItemList to null, overwriting the default empty ArrayList from KLineEntity.java:135.
Then in MainDraw.java:343, passing null to ArrayList constructor throws NullPointerException:
List<Map<String, Object>> itemList = new ArrayList<>(point.selectedItemList);Impact: App crashes when user long-presses on a candlestick that was created from data without a selectedItemList field.
| List<Map<String, Object>> itemList = new ArrayList<>(point.selectedItemList); | |
| List<Map<String, Object>> itemList = point.selectedItemList != null ? new ArrayList<>(point.selectedItemList) : new ArrayList<>(); |
Was this helpful? React with 👍 or 👎 to provide feedback.
Pull Request
Summary
Add buy sell marks
Linear ticket: PRO-2187
Author Checklist
Web ↔ Mobile Consistency (if applicable)
Screenshots / Video (if applicable)