From 70d732f36150c87fc8560e795fbc62593d507c14 Mon Sep 17 00:00:00 2001 From: Robert Macaulay Date: Mon, 25 Nov 2019 01:36:01 -0600 Subject: [PATCH] Reduce exception construction (#538) Create an exception lazily only when necessary. --- .../hotels/styx/client/connectionpool/SimpleConnectionPool.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/client/src/main/java/com/hotels/styx/client/connectionpool/SimpleConnectionPool.java b/components/client/src/main/java/com/hotels/styx/client/connectionpool/SimpleConnectionPool.java index 4239249039..314ebfbbcd 100644 --- a/components/client/src/main/java/com/hotels/styx/client/connectionpool/SimpleConnectionPool.java +++ b/components/client/src/main/java/com/hotels/styx/client/connectionpool/SimpleConnectionPool.java @@ -91,7 +91,7 @@ public Publisher borrowConnection() { } }).timeout( Duration.ofMillis(poolSettings.pendingConnectionTimeoutMillis()), - Mono.error(new MaxPendingConnectionTimeoutException(origin, connectionSettings.connectTimeoutMillis()))); + Mono.error(() -> new MaxPendingConnectionTimeoutException(origin, connectionSettings.connectTimeoutMillis()))); } private void newConnection() {