Skip to content

Commit 075a0f4

Browse files
committed
Annotate LocatorFactoryBean API with Spring @nonnull and @nullable annotations.
1 parent 60fcb0a commit 075a0f4

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

Diff for: spring-data-geode/src/main/java/org/springframework/data/gemfire/LocatorFactoryBean.java

+23-15
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@
3333
import org.springframework.data.gemfire.util.ArrayUtils;
3434
import org.springframework.data.gemfire.util.CollectionUtils;
3535
import org.springframework.lang.NonNull;
36+
import org.springframework.lang.Nullable;
3637
import org.springframework.util.Assert;
3738
import org.springframework.util.StringUtils;
3839

3940
/**
40-
* Spring {@link FactoryBean} used to configure and initialize (bootstrap) an Apache Geode or Pivotal GemFire
41-
* {@link Locator} using the {@link LocatorLauncher} class.
41+
* Spring {@link FactoryBean} used to configure, bootstrap and initialize an Apache Geode {@link Locator}
42+
* using the {@link LocatorLauncher} class.
4243
*
4344
* @author John Blum
4445
* @see java.util.Properties
@@ -48,6 +49,7 @@
4849
* @see org.springframework.beans.factory.InitializingBean
4950
* @see org.springframework.data.gemfire.config.annotation.LocatorConfigurer
5051
* @see org.springframework.data.gemfire.support.AbstractFactoryBeanSupport
52+
* @see org.springframework.data.gemfire.support.GemfireBeanFactoryLocator
5153
* @since 2.2.0
5254
*/
5355
@SuppressWarnings("unused")
@@ -156,7 +158,7 @@ protected void initializeBeanFactoryLocator() {
156158
}
157159
}
158160

159-
protected LocatorLauncher.Builder newLocatorLauncherBuilder() {
161+
protected @NonNull LocatorLauncher.Builder newLocatorLauncherBuilder() {
160162
return new LocatorLauncher.Builder();
161163
}
162164

@@ -168,11 +170,11 @@ protected LocatorLauncher postProcess(LocatorLauncher locatorLauncher) {
168170
return locatorLauncher;
169171
}
170172

171-
public Locator getLocator() {
173+
public @Nullable Locator getLocator() {
172174
return this.locator;
173175
}
174176

175-
public LocatorLauncher getLocatorLauncher() {
177+
public @Nullable LocatorLauncher getLocatorLauncher() {
176178
return this.locatorLauncher;
177179
}
178180

@@ -194,7 +196,7 @@ public LocatorLauncher getLocatorLauncher() {
194196
return locator != null ? locator.getClass() : Locator.class;
195197
}
196198

197-
public void setBindAddress(String bindAddress) {
199+
public void setBindAddress(@Nullable String bindAddress) {
198200
this.bindAddress = bindAddress;
199201
}
200202

@@ -208,7 +210,7 @@ public Optional<String> getBindAddress() {
208210
return this.compositeLocatorConfigurer;
209211
}
210212

211-
public void setGemFireProperties(Properties gemfireProperties) {
213+
public void setGemFireProperties(@Nullable Properties gemfireProperties) {
212214
this.gemfireProperties = gemfireProperties;
213215
}
214216

@@ -221,7 +223,7 @@ public void setGemFireProperties(Properties gemfireProperties) {
221223
return this.gemfireProperties;
222224
}
223225

224-
public void setHostnameForClients(String hostnameForClients) {
226+
public void setHostnameForClients(@Nullable String hostnameForClients) {
225227
this.hostnameForClients = hostnameForClients;
226228
}
227229

@@ -239,7 +241,7 @@ public void setLocatorConfigurers(List<LocatorConfigurer> locatorConfigurers) {
239241
Optional.ofNullable(locatorConfigurers).ifPresent(this.locatorConfigurers::addAll);
240242
}
241243

242-
public void setLocators(String locators) {
244+
public void setLocators(@Nullable String locators) {
243245
this.locators = locators;
244246
}
245247

@@ -249,15 +251,15 @@ public Optional<String> getLocators() {
249251
.filter(StringUtils::hasText);
250252
}
251253

252-
public void setLogLevel(String logLevel) {
254+
public void setLogLevel(@Nullable String logLevel) {
253255
this.logLevel = logLevel;
254256
}
255257

256-
public String getLogLevel() {
258+
public @NonNull String getLogLevel() {
257259
return StringUtils.hasText(this.logLevel) ? this.logLevel : DEFAULT_LOG_LEVEL;
258260
}
259261

260-
public void setName(String name) {
262+
public void setName(@Nullable String name) {
261263
this.name = name;
262264
}
263265

@@ -267,14 +269,20 @@ public Optional<String> getName() {
267269
.filter(StringUtils::hasText);
268270
}
269271

270-
public void setPort(Integer port) {
272+
public void setPort(@NonNull Integer port) {
273+
this.port = assertPort(nullSafePort(port));
274+
}
271275

276+
private int assertPort(@NonNull int port) {
272277
Assert.isTrue(port >= 0 && port < 65536, String.format("Network port [%d] is not valid", port));
278+
return port;
279+
}
273280

274-
this.port = port;
281+
private int nullSafePort(@Nullable Integer port) {
282+
return port != null ? port : DEFAULT_PORT;
275283
}
276284

277-
public Integer getPort() {
285+
public @NonNull Integer getPort() {
278286
return this.port;
279287
}
280288

0 commit comments

Comments
 (0)