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
#2617 User can safely add the same proxy filter many times #2630
Conversation
it's convenient to store a filter into a constant, and add it before every `open(url)` - without checking if it was already added earlier. ``` var MY_CONSTANT_LOGGER = new RequestFilter() {...} getSelenideProxy().addRequestFilter("request-logger", MY_CONSTANT_LOGGER); ```
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
@@ -116,15 +116,14 @@ public boolean isStarted() { | |||
* @param requestFilter the filter | |||
*/ | |||
public void addRequestFilter(String name, RequestFilter requestFilter) { | |||
if (isRequestFilterAdded(name)) { | |||
RequestFilter currentFilter = requestFilter(name); | |||
if (currentFilter != null && !currentFilter.equals(requestFilter)) { |
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.
Maybe better to use such verification and skip next currentFilter
null check as well?
if (currentFilter != null && !currentFilter.equals(requestFilter)) { | |
if (Objects.equals(currentFilter, requestFilter)) { |
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.
@rosolko Nice try, but no :)
Then this method will throw exception if currentFilter == null
. But should not.
@@ -134,11 +133,14 @@ private boolean isRequestFilterAdded(String name) { | |||
* @param responseFilter the filter | |||
*/ | |||
public void addResponseFilter(String name, ResponseFilter responseFilter) { | |||
if (responseFilters.containsKey(name)) { | |||
ResponseFilter currentFilter = responseFilter(name); | |||
if (currentFilter != null && !currentFilter.equals(responseFilter)) { |
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.
Same here
it's convenient to store a filter into a constant, and add it before every
open(url)
- without checking if it was already added earlier.