Skip to content

Commit 8a3348e

Browse files
committed
Don't return null for getDomain()
1 parent e2da159 commit 8a3348e

4 files changed

Lines changed: 9 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ CHANGELOG
2626
`IpAddress.getCountry()` now returns a `com.maxmind.geoip2.record.Country`.
2727
* Removed deprecated `Payment.Processor.VERAPAY` enum value. Use `VEREPAY`
2828
instead.
29+
* `Email.getDomain()` will now return an empty object rather than null if
30+
there is no domain data. This is match other response model class getters.
2931
* Upgraded the `geoip2` dependency to 2.16.1. This adds mobile country code
3032
(MCC) and mobile network code (MNC) to minFraud Insights and Factors
3133
responses. These are available at

src/main/java/com/maxmind/minfraud/response/Email.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ public Email(
3030
@JsonProperty("is_high_risk") Boolean isHighRisk,
3131
@JsonProperty("first_seen") String firstSeen
3232
) {
33-
this.domain = domain;
33+
this.domain = domain == null ? new EmailDomain() : domain;
3434
this.isDisposable = isDisposable;
3535
this.isFree = isFree;
3636
this.isHighRisk = isHighRisk;
3737
this.firstSeen = firstSeen;
3838
}
3939

4040
public Email() {
41-
this(null, null, null);
41+
this(null, null, null, null, null);
4242
}
4343

4444
/**

src/main/java/com/maxmind/minfraud/response/EmailDomain.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ public EmailDomain(
1717
this.firstSeen = firstSeen;
1818
}
1919

20+
public EmailDomain() {
21+
this(null);
22+
}
23+
2024
/**
2125
* @return A date to identify the date an email domain was first
2226
* seen by MaxMind.

src/test/java/com/maxmind/minfraud/response/EmailTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public void testEmailWithoutFirstSeen() throws Exception {
4848
.finish()
4949
);
5050

51+
assertNotNull(email.getDomain());
5152
assertNull(email.isDisposable());
5253
assertFalse(email.isFree());
5354
assertTrue(email.isHighRisk());

0 commit comments

Comments
 (0)