Skip to content

Commit d78d803

Browse files
committed
Add nullability annotations to module/spring-boot-sendgrid
See gh-46587
1 parent 2d685c2 commit d78d803

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

module/spring-boot-sendgrid/src/main/java/org/springframework/boot/sendgrid/autoconfigure/SendGridAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public final class SendGridAutoConfiguration {
4747
@Bean
4848
@ConditionalOnMissingBean(SendGridAPI.class)
4949
SendGrid sendGrid(SendGridProperties properties) {
50-
if (properties.isProxyConfigured()) {
50+
if (properties.getProxy() != null && properties.getProxy().getHost() != null
51+
&& properties.getProxy().getPort() != null) {
5152
HttpHost proxy = new HttpHost(properties.getProxy().getHost(), properties.getProxy().getPort());
5253
return new SendGrid(properties.getApiKey(), new Client(HttpClientBuilder.create().setProxy(proxy).build()));
5354
}

module/spring-boot-sendgrid/src/main/java/org/springframework/boot/sendgrid/autoconfigure/SendGridProperties.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.boot.sendgrid.autoconfigure;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.boot.context.properties.ConfigurationProperties;
2022

2123
/**
@@ -31,58 +33,54 @@ public class SendGridProperties {
3133
/**
3234
* SendGrid API key.
3335
*/
34-
private String apiKey;
36+
private @Nullable String apiKey;
3537

3638
/**
3739
* Proxy configuration.
3840
*/
39-
private Proxy proxy;
41+
private @Nullable Proxy proxy;
4042

41-
public String getApiKey() {
43+
public @Nullable String getApiKey() {
4244
return this.apiKey;
4345
}
4446

45-
public void setApiKey(String apiKey) {
47+
public void setApiKey(@Nullable String apiKey) {
4648
this.apiKey = apiKey;
4749
}
4850

49-
public Proxy getProxy() {
51+
public @Nullable Proxy getProxy() {
5052
return this.proxy;
5153
}
5254

53-
public void setProxy(Proxy proxy) {
55+
public void setProxy(@Nullable Proxy proxy) {
5456
this.proxy = proxy;
5557
}
5658

57-
public boolean isProxyConfigured() {
58-
return this.proxy != null && this.proxy.getHost() != null && this.proxy.getPort() != null;
59-
}
60-
6159
public static class Proxy {
6260

6361
/**
6462
* SendGrid proxy host.
6563
*/
66-
private String host;
64+
private @Nullable String host;
6765

6866
/**
6967
* SendGrid proxy port.
7068
*/
71-
private Integer port;
69+
private @Nullable Integer port;
7270

73-
public String getHost() {
71+
public @Nullable String getHost() {
7472
return this.host;
7573
}
7674

77-
public void setHost(String host) {
75+
public void setHost(@Nullable String host) {
7876
this.host = host;
7977
}
8078

81-
public Integer getPort() {
79+
public @Nullable Integer getPort() {
8280
return this.port;
8381
}
8482

85-
public void setPort(Integer port) {
83+
public void setPort(@Nullable Integer port) {
8684
this.port = port;
8785
}
8886

module/spring-boot-sendgrid/src/main/java/org/springframework/boot/sendgrid/autoconfigure/package-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
/**
1818
* Auto-configuration for SendGrid.
1919
*/
20+
@NullMarked
2021
package org.springframework.boot.sendgrid.autoconfigure;
22+
23+
import org.jspecify.annotations.NullMarked;

0 commit comments

Comments
 (0)