Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Implement Safe Casting in getPermissions Method (#13143)
* [FEATURE] Implement Safe Casting in getPermissions Method This commit addresses a potential ClassCastException issue in the getPermissions method. Previously, the method executed a type cast from Object to Map<String, Object> without checking if this cast was safe, leading to a potential risk of runtime exceptions. Changes made: 1. Added a type check using 'instanceof' to ensure that the result from executeMethod.execute is indeed a Map<?, ?> before proceeding with the cast. 2. Iterated over the entries of the resultMap, and performed a safe cast for each key-value pair, ensuring they are of types String and Boolean, respectively. 3. In case the resultObject is not an instance of Map, the method now throws an IllegalStateException with a descriptive error message, including the unexpected object's class name. These changes enhance the robustness and reliability of the getPermissions method by preventing unsafe type casts and providing clearer error handling for unexpected types. * Run ./scripts/format.sh --------- Co-authored-by: Diego Molina <[email protected]>
- Loading branch information