-
Notifications
You must be signed in to change notification settings - Fork 6k
Add getRequiredAddress() and getMaskBits() to IpAddressMatcher.java #16795
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
Conversation
Based on the OP's description, it is only needed for logging. It's quite common for a Also, adding a Are you able to change the PR to implement |
To be clear, I understand that getters were suggested and the OP agreed that they may have value. Unless there is a present need, we usually wait to add to the public API. |
Thanks @jzheaux ! In my experience with Spring, toString() is often used to output the full object structure, like:
I’d really appreciate your thoughts on which direction would be more appropriate. Also, I’m curious — from your experience, which approach is more commonly used for logging purposes in the Spring ecosystem: |
Good questions, @wtigerhyunsu. The primary context of my recommendation is about noticing the overlap between the original request and the fact that adding I prefer printing out the IP Address in a standardized format (CIDR in this case) in the same way that I prefer printing out the method and path as
which follows the convention for
We can always add another public method should the need arise. I'd like to wait on |
Closes spring-projectsgh-16795 Signed-off-by: wtigerhyunsu <[email protected]>
Closes spring-projectsgh-16795 Signed-off-by: wtigerhyunsu <[email protected]>
Closes spring-projectsgh-16795 Signed-off-by: wtigerhyunsu <[email protected]>
Closes spring-projectsgh-16795 Signed-off-by: wtigerhyunsu <[email protected]>
Closes spring-projectsgh-16795 Signed-off-by: wtigerhyunsu <[email protected]>
Closes spring-projectsgh-16795 Signed-off-by: wtigerhyunsu <[email protected]>
Signed-off-by: wtigerhyunsu <[email protected]> Add toString() to IpAddressMatcher.java Closes spring-projectsgh-16795 Signed-off-by: wtigerhyunsu <[email protected]>
Closes spring-projectsgh-16795 Signed-off-by: wtigerhyunsu <[email protected]>
Closes gh-16795 Signed-off-by: wtigerhyunsu <[email protected]>
Closes gh-16693
When reviewing the issue, the original request was to add a toString() method to IpAddressMatcher.
However, what the reporter actually needed was the hostAddress that had been set in the IpAddressMatcher.
I didn’t think it was appropriate to override toString() just to return the hostAddress, because toString() should ideally reflect the entire object state or be used for debugging purposes—not to expose a specific internal value. So I decided not to implement it that way.
As for getRequiredAddress(), I believed that it was sufficient to return the raw InetAddress directly without wrapping or transforming it to a hostAddress. This way, users can still access what they need without inconvenience.
On the other hand, since getMaskBits() is tightly coupled with the subnet concept and is inherently derived from the original hostAddress, I felt it was appropriate to expose that detail explicitly through this method.