Paul Zepernick
2018-08-21 16:32:00 UTC
I was doing some work on a custom interceptor that was working with the HttpParameters class. At first glance, it appears that it is supposed to be immutable based on some of the exceptions thrown for implementations of Map methods, for example:
@Override
public Parameter put(String key, Parameter value) {
throw new IllegalAccessError("HttpParameters are immutable, you cannot put value directly!");
}
@Override
public Parameter remove(Object key) {
throw new IllegalAccessError("HttpParameters are immutable, you cannot remove object directly!");
}
But then this method is there:
public HttpParameters remove(Set<String> paramsToRemove) {
for (String paramName : paramsToRemove) {
parameters.remove(paramName);
}
return this;
}
Which is removing the parameter from the object, I would have expected that this return a modified copy?
Just wondering the intentions of the class, and if this should be logged as a bug?
Paul
Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.
@Override
public Parameter put(String key, Parameter value) {
throw new IllegalAccessError("HttpParameters are immutable, you cannot put value directly!");
}
@Override
public Parameter remove(Object key) {
throw new IllegalAccessError("HttpParameters are immutable, you cannot remove object directly!");
}
But then this method is there:
public HttpParameters remove(Set<String> paramsToRemove) {
for (String paramName : paramsToRemove) {
parameters.remove(paramName);
}
return this;
}
Which is removing the parameter from the object, I would have expected that this return a modified copy?
Just wondering the intentions of the class, and if this should be logged as a bug?
Paul
Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.