* 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();
|
boolean isDiscard();
|
||||||
void setDiscard(boolean discard);
|
void setDiscard(boolean discard);
|
||||||
int[] getPortList();
|
int[] getPortList();
|
||||||
void setPortList(int[] portList);
|
void setPortList(int... portList);
|
||||||
}
|
}
|
@ -128,11 +128,20 @@ public class DefaultCookie implements Cookie {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int[] getPortList() {
|
public int[] getPortList() {
|
||||||
return portList;
|
return portList.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPortList(int[] portList) {
|
public void setPortList(int... portList) {
|
||||||
this.portList = 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() {
|
public int getMaxAge() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user