Skip to content

Commit 790bae1

Browse files
committed
Merge pull request #7 from maxmind/greg/null-guards
Add some guards against null values
2 parents 2d99ee5 + b70bc2a commit 790bae1

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
0.5.0 (2016-XX-XX)
5+
------------------
6+
7+
* This API now throws an `IllegalArgumentException` when `null` values are
8+
passed to constructors or methods that require non-null values.
9+
410
0.4.0 (2016-05-23)
511
------------------
612

src/main/java/com/maxmind/minfraud/WebServiceClient.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ public WebServiceClient.Builder port(int val) {
144144
* @return Builder object
145145
*/
146146
public WebServiceClient.Builder locales(List<String> val) {
147+
if (locales == null) {
148+
throw new IllegalArgumentException("locales must not be null");
149+
}
147150
locales = new ArrayList<>(val);
148151
return this;
149152
}
@@ -245,6 +248,9 @@ public ScoreResponse score(Transaction transaction) throws IOException,
245248

246249
private <T> T responseFor(String service, Transaction transaction, Class<T> cls)
247250
throws IOException, MinFraudException {
251+
if (transaction == null) {
252+
throw new IllegalArgumentException("transaction must not be null");
253+
}
248254
URL url = createUrl(WebServiceClient.pathBase + service);
249255
HttpPost request = requestFor(transaction, url);
250256

src/main/java/com/maxmind/minfraud/request/Device.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public static final class Builder {
3535
* by the customer in the transaction.
3636
*/
3737
public Builder(InetAddress ipAddress) {
38+
if (ipAddress == null) {
39+
throw new IllegalArgumentException("ipAddress must not be null");
40+
}
41+
3842
this.ipAddress = ipAddress;
3943
}
4044

src/main/java/com/maxmind/minfraud/request/Transaction.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public static class Builder {
5656
* @param device The {@code Device} model for the request
5757
*/
5858
public Builder(Device device) {
59+
if (device == null) {
60+
throw new IllegalArgumentException("device must not be null");
61+
}
5962
this.device = device;
6063
}
6164

0 commit comments

Comments
 (0)