-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[fix]bugfix:Prevent Long.parseLong() error when search param is a float #3483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
starryCoder
wants to merge
28
commits into
apache:master
Choose a base branch
from
starryCoder:fix-search-float-parsing-error
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+43
−4
Open
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
3358f16
[fix]bugfix:Prevent Long.parseLong() error when search param is a float
starryCoder 63e7379
Merge branch 'master' into fix-search-float-parsing-error
starryCoder de247da
Merge branch 'master' into fix-search-float-parsing-error
Aias00 e771f97
Merge branch 'master' into fix-search-float-parsing-error
tomsun28 9170f9a
add unit tests for getMonitors and isLong
starryCoder 05ee462
Merge branch 'master' into fix-search-float-parsing-error
Aias00 b4939fc
Merge branch 'master' into fix-search-float-parsing-error
Aias00 68ac004
Merge branch 'master' into fix-search-float-parsing-error
Aias00 fab91f4
Merge branch 'master' into fix-search-float-parsing-error
Aias00 4361986
Merge branch 'master' into fix-search-float-parsing-error
Aias00 3ff5deb
Merge branch 'master' into fix-search-float-parsing-error
Calvin979 d3c4a53
Merge branch 'master' into fix-search-float-parsing-error
lynx009 bda9565
Merge branch 'master' into fix-search-float-parsing-error
lynx009 7e66038
Merge branch 'master' into fix-search-float-parsing-error
Calvin979 28e1430
Merge branch 'master' into fix-search-float-parsing-error
Aias00 1c4ccd1
Merge branch 'master' into fix-search-float-parsing-error
Aias00 2c3ee59
Merge branch 'master' into fix-search-float-parsing-error
Aias00 e78cb91
Merge branch 'master' into fix-search-float-parsing-error
Calvin979 9f1a82c
Merge branch 'master' into fix-search-float-parsing-error
Aias00 32b8271
Merge branch 'master' into fix-search-float-parsing-error
Aias00 7992e1b
Merge branch 'master' into fix-search-float-parsing-error
Aias00 7402633
Merge branch 'master' into fix-search-float-parsing-error
yuluo-yx df1c3e2
Merge branch 'master' into fix-search-float-parsing-error
pwallk 6cc3151
Merge branch 'master' into fix-search-float-parsing-error
Aias00 d6c2c89
Merge branch 'master' into fix-search-float-parsing-error
Aias00 93d9562
Merge branch 'master' into fix-search-float-parsing-error
yuluo-yx 917d1c9
Merge branch 'master' into fix-search-float-parsing-error
Aias00 12e65a9
Merge branch 'master' into fix-search-float-parsing-error
yuluo-yx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -608,7 +608,7 @@ public Page<Monitor> getMonitors(List<Long> monitorIds, String app, String searc | |
if (StringUtils.hasText(search)) { | ||
Predicate predicateHost = criteriaBuilder.like(root.get("host"), "%" + search + "%"); | ||
Predicate predicateName = criteriaBuilder.like(criteriaBuilder.lower(root.get("name")), "%" + search.toLowerCase() + "%"); | ||
if (CommonUtil.isNumeric(search)){ | ||
if (CommonUtil.isLong(search)){ | ||
Predicate predicateId = criteriaBuilder.equal(root.get("id"), Long.parseLong(search)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Long.parseLong can still fail if the number has lots of digits, eg 20 or more. |
||
orList.add(predicateId); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi can you help add some unit test cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I've added unit tests for isLong, and I noticed that the mock behavior covers the exception (monitorDao.findAll() directly returns mockPage without actually executing the query). Then I ensured test coverage by triggering toPredicate() with thenAnswer().