summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard/config/Peer.java
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-12-11 02:28:34 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-12-11 02:28:34 +0100
commit266ee7626c4c602c6f690c7c663526e38141986b (patch)
treeb28166b4cf938d0a75fc5ad82f84c0cda89cd350 /app/src/main/java/com/wireguard/config/Peer.java
parentc1ba1f409cd1566cb11d0c26d610ffdff4d2e24c (diff)
Throw illegalargumentexception instead of nullpointerexception for builder errors
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/config/Peer.java')
-rw-r--r--app/src/main/java/com/wireguard/config/Peer.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/src/main/java/com/wireguard/config/Peer.java b/app/src/main/java/com/wireguard/config/Peer.java
index c15d3ae9..1eb30197 100644
--- a/app/src/main/java/com/wireguard/config/Peer.java
+++ b/app/src/main/java/com/wireguard/config/Peer.java
@@ -35,12 +35,14 @@ public final class Peer {
private final Key publicKey;
private Peer(final Builder builder) {
+ if (builder.publicKey == null)
+ throw new IllegalArgumentException("Peers must have a public key");
// Defensively copy to ensure immutability even if the Builder is reused.
allowedIps = Collections.unmodifiableSet(new LinkedHashSet<>(builder.allowedIps));
endpoint = builder.endpoint;
persistentKeepalive = builder.persistentKeepalive;
preSharedKey = builder.preSharedKey;
- publicKey = Objects.requireNonNull(builder.publicKey, "Peers must have a public key");
+ publicKey = builder.publicKey;
}
/**