@@ -79,6 +79,8 @@ public class HTTPServerConfiguration implements Configurable<HTTPServerConfigura
7979
8080 private Duration shutdownDuration = Duration .ofSeconds (10 );
8181
82+ private HTTPUnexpectedExceptionHandler unexpectedExceptionHandler = new DefaultHTTPUnexpectedExceptionHandler ();
83+
8284 private Duration writeThroughputCalculationDelayDuration = Duration .ofSeconds (5 );
8385
8486 /**
@@ -275,6 +277,13 @@ public Duration getShutdownDuration() {
275277 return shutdownDuration ;
276278 }
277279
280+ /**
281+ * @return The HTTP unexpected exception handler for this server. Never null.
282+ */
283+ public HTTPUnexpectedExceptionHandler getUnexpectedExceptionHandler () {
284+ return unexpectedExceptionHandler ;
285+ }
286+
278287 /**
279288 * @return the duration that will be used to delay the calculation and enforcement of the minimum write throughput.
280289 */
@@ -334,7 +343,7 @@ public HTTPServerConfiguration withContextPath(String contextPath) {
334343 */
335344 @ Override
336345 public HTTPServerConfiguration withExpectValidator (ExpectValidator validator ) {
337- Objects .requireNonNull (handler , "You cannot set ExpectValidator to null" );
346+ Objects .requireNonNull (validator , "You cannot set the expect validator to null" );
338347 this .expectValidator = validator ;
339348 return this ;
340349 }
@@ -344,7 +353,7 @@ public HTTPServerConfiguration withExpectValidator(ExpectValidator validator) {
344353 */
345354 @ Override
346355 public HTTPServerConfiguration withHandler (HTTPHandler handler ) {
347- Objects .requireNonNull (handler , "You cannot set HTTPHandler to null" );
356+ Objects .requireNonNull (handler , "You cannot set the handler to null" );
348357 this .handler = handler ;
349358 return this ;
350359 }
@@ -354,7 +363,7 @@ public HTTPServerConfiguration withHandler(HTTPHandler handler) {
354363 */
355364 @ Override
356365 public HTTPServerConfiguration withInitialReadTimeout (Duration duration ) {
357- Objects .requireNonNull (duration , "You cannot set the client timeout to null" );
366+ Objects .requireNonNull (duration , "You cannot set the client read timeout duration to null" );
358367 if (duration .isZero () || duration .isNegative ()) {
359368 throw new IllegalArgumentException ("The client timeout duration must be greater than 0" );
360369 }
@@ -379,7 +388,6 @@ public HTTPServerConfiguration withInstrumenter(Instrumenter instrumenter) {
379388 @ Override
380389 public HTTPServerConfiguration withKeepAliveTimeoutDuration (Duration duration ) {
381390 Objects .requireNonNull (duration , "You cannot set the keep-alive timeout duration to null" );
382-
383391 if (duration .isZero () || duration .isNegative ()) {
384392 throw new IllegalArgumentException ("The keep-alive timeout duration must be grater than 0" );
385393 }
@@ -393,7 +401,7 @@ public HTTPServerConfiguration withKeepAliveTimeoutDuration(Duration duration) {
393401 */
394402 @ Override
395403 public HTTPServerConfiguration withListener (HTTPListenerConfiguration listener ) {
396- Objects .requireNonNull (listener , "You cannot set HTTPListenerConfiguration to null" );
404+ Objects .requireNonNull (listener , "You cannot add a null HTTPListenerConfiguration " );
397405 this .listeners .add (listener );
398406 return this ;
399407 }
@@ -403,7 +411,7 @@ public HTTPServerConfiguration withListener(HTTPListenerConfiguration listener)
403411 */
404412 @ Override
405413 public HTTPServerConfiguration withLoggerFactory (LoggerFactory loggerFactory ) {
406- Objects .requireNonNull (loggerFactory , "You cannot set LoggerFactory to null" );
414+ Objects .requireNonNull (loggerFactory , "You cannot set the logger factory to null" );
407415 this .loggerFactory = loggerFactory ;
408416 return this ;
409417 }
@@ -497,7 +505,6 @@ public HTTPServerConfiguration withMultipartBufferSize(int multipartBufferSize)
497505 @ Override
498506 public HTTPServerConfiguration withMultipartConfiguration (MultipartConfiguration multipartStreamConfiguration ) {
499507 Objects .requireNonNull (multipartStreamConfiguration , "You cannot set the multipart stream configuration to null" );
500-
501508 this .multipartStreamConfiguration = multipartStreamConfiguration ;
502509 return this ;
503510 }
@@ -508,7 +515,6 @@ public HTTPServerConfiguration withMultipartConfiguration(MultipartConfiguration
508515 @ Override
509516 public HTTPServerConfiguration withProcessingTimeoutDuration (Duration duration ) {
510517 Objects .requireNonNull (duration , "You cannot set the processing timeout duration to null" );
511-
512518 if (duration .isZero () || duration .isNegative ()) {
513519 throw new IllegalArgumentException ("The processing timeout duration must be grater than 0" );
514520 }
@@ -523,7 +529,6 @@ public HTTPServerConfiguration withProcessingTimeoutDuration(Duration duration)
523529 @ Override
524530 public HTTPServerConfiguration withReadThroughputCalculationDelayDuration (Duration duration ) {
525531 Objects .requireNonNull (duration , "You cannot set the read throughput delay duration to null" );
526-
527532 if (duration .isZero () || duration .isNegative ()) {
528533 throw new IllegalArgumentException ("The read throughput delay duration must be grater than 0" );
529534 }
@@ -564,7 +569,6 @@ public HTTPServerConfiguration withResponseBufferSize(int responseBufferSize) {
564569 @ Override
565570 public HTTPServerConfiguration withShutdownDuration (Duration duration ) {
566571 Objects .requireNonNull (duration , "You cannot set the shutdown duration to null" );
567-
568572 if (duration .isZero () || duration .isNegative ()) {
569573 throw new IllegalArgumentException ("The shutdown duration must be grater than 0" );
570574 }
@@ -573,13 +577,22 @@ public HTTPServerConfiguration withShutdownDuration(Duration duration) {
573577 return this ;
574578 }
575579
580+ /**
581+ * {@inheritDoc}
582+ */
583+ @ Override
584+ public HTTPServerConfiguration withUnexpectedExceptionHandler (HTTPUnexpectedExceptionHandler unexpectedExceptionHandler ) {
585+ Objects .requireNonNull (unexpectedExceptionHandler , "You cannot set the unexpected exception handler to null" );
586+ this .unexpectedExceptionHandler = unexpectedExceptionHandler ;
587+ return this ;
588+ }
589+
576590 /**
577591 * {@inheritDoc}
578592 */
579593 @ Override
580594 public HTTPServerConfiguration withWriteThroughputCalculationDelayDuration (Duration duration ) {
581595 Objects .requireNonNull (duration , "You cannot set the write throughput delay duration to null" );
582-
583596 if (duration .isZero () || duration .isNegative ()) {
584597 throw new IllegalArgumentException ("The write throughput delay duration must be grater than 0" );
585598 }
0 commit comments