Skip to content

Commit 5982315

Browse files
committed
Avoid possible NPEs
1 parent 4992482 commit 5982315

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

java/org/apache/tomcat/util/net/SocketProperties.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -307,95 +307,95 @@ public boolean getDirectSslBuffer() {
307307
* @return the OOBINLINE value
308308
*/
309309
public boolean getOoBInline() {
310-
return ooBInline.booleanValue();
310+
return ooBInline == null ? false : ooBInline.booleanValue();
311311
}
312312

313313
/**
314314
* Returns the performance preference for bandwidth.
315315
* @return the bandwidth preference value
316316
*/
317317
public int getPerformanceBandwidth() {
318-
return performanceBandwidth.intValue();
318+
return performanceBandwidth == null ? 0 : performanceBandwidth.intValue();
319319
}
320320

321321
/**
322322
* Returns the performance preference for connection time.
323323
* @return the connection time preference value
324324
*/
325325
public int getPerformanceConnectionTime() {
326-
return performanceConnectionTime.intValue();
326+
return performanceConnectionTime == null ? 0 : performanceConnectionTime.intValue();
327327
}
328328

329329
/**
330330
* Returns the performance preference for latency.
331331
* @return the latency preference value
332332
*/
333333
public int getPerformanceLatency() {
334-
return performanceLatency.intValue();
334+
return performanceLatency == null ? 0 : performanceLatency.intValue();
335335
}
336336

337337
/**
338338
* Returns the socket receive buffer size in bytes.
339339
* @return the receive buffer size
340340
*/
341341
public int getRxBufSize() {
342-
return rxBufSize.intValue();
342+
return rxBufSize == null ? 0 : rxBufSize.intValue();
343343
}
344344

345345
/**
346346
* Returns the SO_KEEPALIVE socket option value.
347347
* @return the keep-alive value
348348
*/
349349
public boolean getSoKeepAlive() {
350-
return soKeepAlive.booleanValue();
350+
return soKeepAlive == null ? false : soKeepAlive.booleanValue();
351351
}
352352

353353
/**
354354
* Returns whether SO_LINGER is enabled.
355355
* @return {@code true} if SO_LINGER is enabled
356356
*/
357357
public boolean getSoLingerOn() {
358-
return soLingerOn.booleanValue();
358+
return soLingerOn == null ? false : soLingerOn.booleanValue();
359359
}
360360

361361
/**
362362
* Returns the SO_LINGER timeout value in seconds.
363363
* @return the linger timeout value
364364
*/
365365
public int getSoLingerTime() {
366-
return soLingerTime.intValue();
366+
return soLingerTime == null ? 0 : soLingerTime.intValue();
367367
}
368368

369369
/**
370370
* Returns the SO_REUSEADDR socket option value.
371371
* @return the reuse address value
372372
*/
373373
public boolean getSoReuseAddress() {
374-
return soReuseAddress.booleanValue();
374+
return soReuseAddress == null ? false : soReuseAddress.booleanValue();
375375
}
376376

377377
/**
378378
* Returns the SO_TIMEOUT value in milliseconds.
379379
* @return the socket timeout value
380380
*/
381381
public int getSoTimeout() {
382-
return soTimeout.intValue();
382+
return soTimeout == null ? 0 : soTimeout.intValue();
383383
}
384384

385385
/**
386386
* Returns the TCP_NODELAY socket option value.
387387
* @return the TCP no delay value
388388
*/
389389
public boolean getTcpNoDelay() {
390-
return tcpNoDelay.booleanValue();
390+
return tcpNoDelay == null ? false : tcpNoDelay.booleanValue();
391391
}
392392

393393
/**
394394
* Returns the socket send buffer size in bytes.
395395
* @return the send buffer size
396396
*/
397397
public int getTxBufSize() {
398-
return txBufSize.intValue();
398+
return txBufSize == null ? 0 : txBufSize.intValue();
399399
}
400400

401401
/**

0 commit comments

Comments
 (0)