Skip to content

Commit 9a97bbf

Browse files
committed
SendGrid version 0.0.8 - fixes issue of setFromName pointer potentially being null
1 parent f768152 commit 9a97bbf

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repositories {
3434
}
3535
dependencies {
3636
...
37-
compile 'com.github.scottmotte:sendgrid:0.0.7'
37+
compile 'com.github.scottmotte:sendgrid:0.0.8'
3838
}
3939
4040
...

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apply plugin: 'fatjar'
22

3-
version = "0.0.7"
3+
version = "0.0.8"
44

55
buildscript {
66
dependencies {
Binary file not shown.

src/main/java/com/github/scottmotte/sendgrid/Sendgrid.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,30 @@ public String send() {
4747
public String web() {
4848
HttpRequest request = HttpRequest.post("https://sendgrid.com/api/mail.send.json");
4949

50-
request.part(PARAM_API_USER, this.username);
51-
request.part(PARAM_API_KEY, this.password);
50+
if (this.username != null) {
51+
request.part(PARAM_API_USER, this.username);
52+
}
53+
if (this.password != null) {
54+
request.part(PARAM_API_KEY, this.password);
55+
}
5256
for (String to:this.getTos()) {
5357
request.part(PARAM_TOS, to);
5458
}
5559
for (String toname:this.getToNames()) {
5660
request.part(PARAM_TONAMES, toname);
5761
}
58-
request.part(PARAM_FROM, this.getFrom());
59-
request.part(PARAM_FROMNAME, this.getFromName());
62+
if (this.getFrom() != null) {
63+
request.part(PARAM_FROM, this.getFrom());
64+
}
65+
if (this.getFromName() != null) {
66+
request.part(PARAM_FROMNAME, this.getFromName());
67+
}
6068
if (this.getReplyTo() != null) {
6169
request.part(PARAM_REPLYTO, this.getReplyTo());
6270
}
63-
request.part(PARAM_SUBJECT, this.getSubject());
64-
71+
if (this.getSubject() != null) {
72+
request.part(PARAM_SUBJECT, this.getSubject());
73+
}
6574
if (this.getText() != null) {
6675
request.part(PARAM_TEXT, this.getText());
6776
}
@@ -71,11 +80,9 @@ public String web() {
7180
if (this.getBcc() != null) {
7281
request.part(PARAM_BCC, this.getBcc());
7382
}
74-
7583
for (File file:this.getFiles()) {
7684
request.part(String.format(PARAM_FILES, file.getName()), file);
7785
}
78-
7986
request.part(PARAM_HEADERS, this.getHeaders().toString());
8087

8188
return request.body();

0 commit comments

Comments
 (0)