Copilot commented on code in PR #799:
URL: https://github.com/apache/ranger/pull/799#discussion_r2681163860


##########
security-admin/src/main/java/org/apache/ranger/db/XXGlobalStateDao.java:
##########
@@ -167,20 +167,21 @@ private void createGlobalStateForAppDataVersion(String 
stateName) {
 
         appDataVersion.put(APP_DATA_ENTRY_VERSION, Long.toString(1L));
 
-        globalState.setAppData(new Gson().toJson(appDataVersion));
+        globalState.setAppData(JsonUtils.mapToJson(appDataVersion));
 
         create(globalState);
     }
 
     private void updateGlobalStateForAppDataVersion(XXGlobalState globalState, 
String stateName) {
-        Map<String, String> appDataVersionJson = new 
Gson().fromJson(globalState.getAppData(), Map.class);
+        Map<String, String> appDataVersionJson = 
JsonUtils.jsonToMapStringString(globalState.getAppData());
 
         if (MapUtils.isNotEmpty(appDataVersionJson)) {
-            Long appDataVersion = 
Long.valueOf(appDataVersionJson.get(APP_DATA_ENTRY_VERSION)) + 1L;
+            String versionStr     = 
appDataVersionJson.get(APP_DATA_ENTRY_VERSION);
+            long   appDataVersion = StringUtils.isNotBlank(versionStr) ? 
(Long.parseLong(versionStr) + 1L) : 1L;

Review Comment:
   The variable type changed from Long to primitive long. While this works, 
it's inconsistent with the pattern on line 119 where Long.valueOf() is used. 
Consider using Long consistently throughout the method for uniformity, or 
update line 119 to also use long primitive type.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to