@@ -44,6 +44,16 @@ public class ConnectionConfig implements Cloneable {
4444
4545 private static final Timeout DEFAULT_CONNECT_TIMEOUT = Timeout .ofMinutes (3 );
4646
47+ /**
48+ * The default connection configuration.
49+ * <ul>
50+ * <li>Timeout connectTimeout: 3 minutes</li>
51+ * <li>Timeout socketTimeout: {@code null} (undefined)</li>
52+ * <li>Timeout idleTimeout: {@code null} (undefined)</li>
53+ * <li>TimeValue validateAfterInactivity: {@code null} (undefined)</li>
54+ * <li>TimeValue timeToLive: {@code null} (undefined)</li>
55+ * </ul>
56+ */
4757 public static final ConnectionConfig DEFAULT = new Builder ().build ();
4858
4959 private final Timeout connectTimeout ;
@@ -74,34 +84,60 @@ protected ConnectionConfig() {
7484 }
7585
7686 /**
87+ * Gets the default socket timeout value for I/O operations on connections created by this configuration.
88+ * A timeout value of zero is interpreted as an infinite timeout.
89+ *
90+ * @return the default socket timeout value, defaults to null.
7791 * @see Builder#setSocketTimeout(Timeout)
7892 */
7993 public Timeout getSocketTimeout () {
8094 return socketTimeout ;
8195 }
8296
8397 /**
98+ * Gets the timeout until the target endpoint acknowledges accepting the connection request.
99+ * <p>
100+ * Note that isn't the same time as the new connection being fully established. An HTTPS connection cannot be considered fully established until the TLS
101+ * handshake has been successfully completed.
102+ * </p>
103+ * <p>
104+ * A timeout value of zero is interpreted as an infinite timeout.
105+ * </p>
106+ *
107+ * @return the timeout until the target endpoint acknowledges accepting the connection request, defaults to 3 minutes.
84108 * @see Builder#setConnectTimeout(Timeout)
85109 */
86110 public Timeout getConnectTimeout () {
87111 return connectTimeout ;
88112 }
89113
90114 /**
115+ * Gets the maximum period of idleness for a connection.
116+ * <p>
117+ * Implementations can use this value to discard connections that have been idle for too long.
118+ * </p>
119+ *
120+ * @return the maximum period of idleness for a connection, defaults to null.
91121 * @see Builder#setIdleTimeout(Timeout)
92122 */
93123 public Timeout getIdleTimeout () {
94124 return idleTimeout ;
95125 }
96126
97127 /**
128+ * Gets the period of inactivity after which persistent connections must be re-validated.
129+ *
130+ * @return the period of inactivity after which persistent connections must be re-validated, defaults to null.
98131 * @see Builder#setValidateAfterInactivity(TimeValue)
99132 */
100133 public TimeValue getValidateAfterInactivity () {
101134 return validateAfterInactivity ;
102135 }
103136
104137 /**
138+ * Gets the total span of time connections can be kept alive or execute requests.
139+ *
140+ * @return the total span of time connections can be kept alive or execute requests, defaults to null.
105141 * @see Builder#setTimeToLive(TimeValue) (TimeValue)
106142 */
107143 public TimeValue getTimeToLive () {
@@ -126,10 +162,21 @@ public String toString() {
126162 return builder .toString ();
127163 }
128164
165+ /**
166+ * Creates a new builder for {@link ConnectionConfig}.
167+ *
168+ * @return a new builder for {@link ConnectionConfig}.
169+ */
129170 public static ConnectionConfig .Builder custom () {
130171 return new Builder ();
131172 }
132173
174+ /**
175+ * Creates a new builder for {@link ConnectionConfig} based on an existing instance.
176+ *
177+ * @param config the instance to copy.
178+ * @return a new builder for {@link ConnectionConfig}.
179+ */
133180 public static ConnectionConfig .Builder copy (final ConnectionConfig config ) {
134181 return new Builder ()
135182 .setConnectTimeout (config .getConnectTimeout ())
@@ -138,6 +185,9 @@ public static ConnectionConfig.Builder copy(final ConnectionConfig config) {
138185 .setTimeToLive (config .getTimeToLive ());
139186 }
140187
188+ /**
189+ * Builder for {@link ConnectionConfig}.
190+ */
141191 public static class Builder {
142192
143193 private Timeout socketTimeout ;
@@ -152,6 +202,10 @@ public static class Builder {
152202 }
153203
154204 /**
205+ * Sets the default socket timeout value for I/O operations on connections created by this configuration.
206+ *
207+ * @param soTimeout The default socket timeout value for I/O operations.
208+ * @param timeUnit The time unit of the soTimeout parameter.
155209 * @return this instance.
156210 * @see #setSocketTimeout(Timeout)
157211 */
@@ -161,7 +215,7 @@ public Builder setSocketTimeout(final int soTimeout, final TimeUnit timeUnit) {
161215 }
162216
163217 /**
164- * Determines the default socket timeout value for I/O operations on
218+ * Sets the default socket timeout value for I/O operations on
165219 * connections created by this configuration.
166220 * A timeout value of zero is interpreted as an infinite timeout.
167221 * <p>
@@ -174,6 +228,7 @@ public Builder setSocketTimeout(final int soTimeout, final TimeUnit timeUnit) {
174228 * Default: {@code null} (undefined)
175229 * </p>
176230 *
231+ * @param soTimeout The default socket timeout value for I/O operations.
177232 * @return this instance.
178233 */
179234 public Builder setSocketTimeout (final Timeout soTimeout ) {
@@ -182,14 +237,15 @@ public Builder setSocketTimeout(final Timeout soTimeout) {
182237 }
183238
184239 /**
185- * Determines the timeout until a new connection is fully established.
240+ * Sets the timeout until a new connection is fully established.
186241 * <p>
187242 * A timeout value of zero is interpreted as an infinite timeout.
188243 * </p>
189244 * <p>
190245 * Default: 3 minutes
191246 * </p>
192247 *
248+ * @param connectTimeout The timeout until a new connection is fully established.
193249 * @return this instance.
194250 */
195251 public Builder setConnectTimeout (final Timeout connectTimeout ) {
@@ -198,6 +254,10 @@ public Builder setConnectTimeout(final Timeout connectTimeout) {
198254 }
199255
200256 /**
257+ * Sets the timeout until a new connection is fully established.
258+ *
259+ * @param connectTimeout The timeout until a new connection is fully established.
260+ * @param timeUnit The time unit of the timeout parameter.
201261 * @return this instance.
202262 * @see #setConnectTimeout(Timeout)
203263 */
@@ -217,6 +277,7 @@ public Builder setConnectTimeout(final long connectTimeout, final TimeUnit timeU
217277 * Default: {@code null} (undefined)
218278 * </p>
219279 *
280+ * @param idleTimeout The maximum period of idleness for a connection.
220281 * @return this instance.
221282 *
222283 * @since 5.6
@@ -227,6 +288,13 @@ public Builder setIdleTimeout(final Timeout idleTimeout) {
227288 }
228289
229290 /**
291+ * Sets the maximum period of idleness for a connection.
292+ * <p>
293+ * Connections that are idle for longer than {@code idleTimeout} are no longer eligible for reuse.
294+ * </p>
295+ *
296+ * @param idleTimeout The maximum period of idleness for a connection.
297+ * @param timeUnit
230298 * @return this instance.
231299 * @see #setIdleTimeout(Timeout)
232300 */
@@ -236,13 +304,14 @@ public Builder setIdleTimeout(final long idleTimeout, final TimeUnit timeUnit) {
236304 }
237305
238306 /**
239- * Defines period of inactivity after which persistent connections must
307+ * Sets the period of inactivity after which persistent connections must
240308 * be re-validated prior to being leased to the consumer. Negative values passed
241309 * to this method disable connection validation.
242310 * <p>
243311 * Default: {@code null} (undefined)
244312 * </p>
245313 *
314+ * @param validateAfterInactivity The period of inactivity after which persistent connections must be re-validated.
246315 * @return this instance.
247316 */
248317 public Builder setValidateAfterInactivity (final TimeValue validateAfterInactivity ) {
@@ -251,6 +320,10 @@ public Builder setValidateAfterInactivity(final TimeValue validateAfterInactivit
251320 }
252321
253322 /**
323+ * Sets the period of inactivity after which persistent connections must be re-validated prior to being leased to the consumer.
324+ *
325+ * @param validateAfterInactivity The period of inactivity after which persistent connections must be re-validated.
326+ * @param timeUnit The time unit of the validateAfterInactivity parameter.
254327 * @return this instance.
255328 * @see #setValidateAfterInactivity(TimeValue)
256329 */
@@ -265,6 +338,7 @@ public Builder setValidateAfterInactivity(final long validateAfterInactivity, fi
265338 * Default: {@code null} (undefined)
266339 * </p>
267340 *
341+ * @param timeToLive The total span of time connections can be kept alive or execute requests.
268342 * @return this instance.
269343 */
270344 public Builder setTimeToLive (final TimeValue timeToLive ) {
@@ -273,6 +347,10 @@ public Builder setTimeToLive(final TimeValue timeToLive) {
273347 }
274348
275349 /**
350+ * Sets the total span of time connections can be kept alive or execute requests.
351+ *
352+ * @param timeToLive The total span of time connections can be kept alive or execute requests.
353+ * @param timeUnit The time unit of the timeToLive parameter.
276354 * @return this instance.
277355 * @see #setTimeToLive(TimeValue)
278356 */
@@ -281,6 +359,11 @@ public Builder setTimeToLive(final long timeToLive, final TimeUnit timeUnit) {
281359 return this ;
282360 }
283361
362+ /**
363+ * Builds a new {@link ConnectionConfig} instance based on the values provided to the setters methods.
364+ *
365+ * @return a new {@link ConnectionConfig} instance.
366+ */
284367 public ConnectionConfig build () {
285368 return new ConnectionConfig (
286369 connectTimeout != null ? connectTimeout : DEFAULT_CONNECT_TIMEOUT ,
0 commit comments