Skip to content

Commit 24e2aee

Browse files
committed
refactor(api): address review feedback on int64_as_string PR
Three small adjustments per review on PR #6699: - GetTransactionCountByBlockNumServlet: add trailing newline at end of file to satisfy checkstyle. - Util.getInt64AsString: align control flow with the existing Util.getVisible (single-return via local boolean, Boolean.valueOf instead of Boolean.parseBoolean). Functionally identical -- both return true only when the parameter value is "true" (case-insensitive). - Util.INT64_AS_STRING -> Util.INT64_AS_STRING_PARAM: rename the public parameter-name constant to avoid potential confusion with the unrelated private ThreadLocal field of the same simple name in JsonFormat. The user-facing query parameter remains "int64_as_string" -- only the Java identifier changes.
1 parent cb77f36 commit 24e2aee

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

framework/src/main/java/org/tron/core/services/http/GetTransactionCountByBlockNumServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ private void fillResponse(long num, HttpServletResponse response) throws IOExcep
4545
: "{\"count\": " + count + "}";
4646
response.getWriter().println(out);
4747
}
48-
}
48+
}

framework/src/main/java/org/tron/core/services/http/Util.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class Util {
6666

6767
public static final String PERMISSION_ID = "Permission_id";
6868
public static final String VISIBLE = "visible";
69-
public static final String INT64_AS_STRING = "int64_as_string";
69+
public static final String INT64_AS_STRING_PARAM = "int64_as_string";
7070
public static final String TRANSACTION = "transaction";
7171
public static final String TRANSACTION_EXTENSION = "transactionExtension";
7272
public static final String VALUE = "value";
@@ -355,10 +355,11 @@ public static boolean existVisible(final HttpServletRequest request) {
355355
* downstream servlets.
356356
*/
357357
public static boolean getInt64AsString(final HttpServletRequest request) {
358-
if (StringUtil.isNotBlank(request.getParameter(INT64_AS_STRING))) {
359-
return Boolean.parseBoolean(request.getParameter(INT64_AS_STRING));
358+
boolean int64AsString = false;
359+
if (StringUtil.isNotBlank(request.getParameter(INT64_AS_STRING_PARAM))) {
360+
int64AsString = Boolean.valueOf(request.getParameter(INT64_AS_STRING_PARAM));
360361
}
361-
return false;
362+
return int64AsString;
362363
}
363364

364365
public static boolean getVisiblePost(final String input) {

0 commit comments

Comments
 (0)