* Replaced Cookie.setPortList(int[]) with Cookie.setPortList(int...)
* Improved DefaultCooke.setPortList() integrity check * DefaultCookie.getPortList() returns a copy
This commit is contained in:
parent
395d57b6eb
commit
df3ac447ff
@ -47,5 +47,5 @@ public interface Cookie extends Comparable<Cookie> {
|
||||
boolean isDiscard();
|
||||
void setDiscard(boolean discard);
|
||||
int[] getPortList();
|
||||
void setPortList(int[] portList);
|
||||
void setPortList(int... portList);
|
||||
}
|
@ -128,11 +128,20 @@ public class DefaultCookie implements Cookie {
|
||||
}
|
||||
|
||||
public int[] getPortList() {
|
||||
return portList;
|
||||
return portList.clone();
|
||||
}
|
||||
|
||||
public void setPortList(int[] portList) {
|
||||
this.portList = portList;
|
||||
public void setPortList(int... portList) {
|
||||
if (portList == null) {
|
||||
throw new NullPointerException("portList");
|
||||
}
|
||||
int[] portListCopy = portList.clone();
|
||||
for (int p: portListCopy) {
|
||||
if (p <= 0 || p > 65535) {
|
||||
throw new IllegalArgumentException("port out of range: " + p);
|
||||
}
|
||||
}
|
||||
this.portList = portListCopy;
|
||||
}
|
||||
|
||||
public int getMaxAge() {
|
||||
|
Loading…
Reference in New Issue
Block a user