@@ -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,56 @@ 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 a new connection is fully established.
99+ * <p>
100+ * A timeout value of zero is interpreted as an infinite timeout.
101+ * </p>
102+ *
103+ * @return the timeout until a new connection is fully established, defaults to 3 minutes.
84104 * @see Builder#setConnectTimeout(Timeout)
85105 */
86106 public Timeout getConnectTimeout () {
87107 return connectTimeout ;
88108 }
89109
90110 /**
111+ * Gets the maximum period of idleness for a connection.
112+ * <p>
113+ * Implementations can use this value to discard connections that have been idle for too long.
114+ * </p>
115+ *
116+ * @return the maximum period of idleness for a connection, defaults to null.
91117 * @see Builder#setIdleTimeout(Timeout)
92118 */
93119 public Timeout getIdleTimeout () {
94120 return idleTimeout ;
95121 }
96122
97123 /**
124+ * Gets the period of inactivity after which persistent connections must be re-validated.
125+ *
126+ * @return the period of inactivity after which persistent connections must be re-validated, defaults to null.
98127 * @see Builder#setValidateAfterInactivity(TimeValue)
99128 */
100129 public TimeValue getValidateAfterInactivity () {
101130 return validateAfterInactivity ;
102131 }
103132
104133 /**
134+ * Gets the total span of time connections can be kept alive or execute requests.
135+ *
136+ * @return the total span of time connections can be kept alive or execute requests, defaults to null.
105137 * @see Builder#setTimeToLive(TimeValue) (TimeValue)
106138 */
107139 public TimeValue getTimeToLive () {
@@ -126,10 +158,21 @@ public String toString() {
126158 return builder .toString ();
127159 }
128160
161+ /**
162+ * Creates a new builder for {@link ConnectionConfig}.
163+ *
164+ * @return a new builder for {@link ConnectionConfig}.
165+ */
129166 public static ConnectionConfig .Builder custom () {
130167 return new Builder ();
131168 }
132169
170+ /**
171+ * Creates a new builder for {@link ConnectionConfig} based on an existing instance.
172+ *
173+ * @param config the instance to copy.
174+ * @return a new builder for {@link ConnectionConfig}.
175+ */
133176 public static ConnectionConfig .Builder copy (final ConnectionConfig config ) {
134177 return new Builder ()
135178 .setConnectTimeout (config .getConnectTimeout ())
@@ -138,6 +181,9 @@ public static ConnectionConfig.Builder copy(final ConnectionConfig config) {
138181 .setTimeToLive (config .getTimeToLive ());
139182 }
140183
184+ /**
185+ * Builder for {@link ConnectionConfig}.
186+ */
141187 public static class Builder {
142188
143189 private Timeout socketTimeout ;
@@ -152,6 +198,10 @@ public static class Builder {
152198 }
153199
154200 /**
201+ * Sets the default socket timeout value for I/O operations on connections created by this configuration.
202+ *
203+ * @param soTimeout The default socket timeout value for I/O operations.
204+ * @param timeUnit The time unit of the soTimeout parameter.
155205 * @return this instance.
156206 * @see #setSocketTimeout(Timeout)
157207 */
@@ -161,7 +211,7 @@ public Builder setSocketTimeout(final int soTimeout, final TimeUnit timeUnit) {
161211 }
162212
163213 /**
164- * Determines the default socket timeout value for I/O operations on
214+ * Sets the default socket timeout value for I/O operations on
165215 * connections created by this configuration.
166216 * A timeout value of zero is interpreted as an infinite timeout.
167217 * <p>
@@ -174,6 +224,7 @@ public Builder setSocketTimeout(final int soTimeout, final TimeUnit timeUnit) {
174224 * Default: {@code null} (undefined)
175225 * </p>
176226 *
227+ * @param soTimeout The default socket timeout value for I/O operations.
177228 * @return this instance.
178229 */
179230 public Builder setSocketTimeout (final Timeout soTimeout ) {
@@ -182,14 +233,15 @@ public Builder setSocketTimeout(final Timeout soTimeout) {
182233 }
183234
184235 /**
185- * Determines the timeout until a new connection is fully established.
236+ * Sets the timeout until a new connection is fully established.
186237 * <p>
187238 * A timeout value of zero is interpreted as an infinite timeout.
188239 * </p>
189240 * <p>
190241 * Default: 3 minutes
191242 * </p>
192243 *
244+ * @param connectTimeout The timeout until a new connection is fully established.
193245 * @return this instance.
194246 */
195247 public Builder setConnectTimeout (final Timeout connectTimeout ) {
@@ -198,6 +250,10 @@ public Builder setConnectTimeout(final Timeout connectTimeout) {
198250 }
199251
200252 /**
253+ * Sets the timeout until a new connection is fully established.
254+ *
255+ * @param connectTimeout The timeout until a new connection is fully established.
256+ * @param timeUnit The time unit of the timeout parameter.
201257 * @return this instance.
202258 * @see #setConnectTimeout(Timeout)
203259 */
@@ -217,6 +273,7 @@ public Builder setConnectTimeout(final long connectTimeout, final TimeUnit timeU
217273 * Default: {@code null} (undefined)
218274 * </p>
219275 *
276+ * @param idleTimeout The maximum period of idleness for a connection.
220277 * @return this instance.
221278 *
222279 * @since 5.6
@@ -227,6 +284,13 @@ public Builder setIdleTimeout(final Timeout idleTimeout) {
227284 }
228285
229286 /**
287+ * Sets the maximum period of idleness for a connection.
288+ * <p>
289+ * Connections that are idle for longer than {@code idleTimeout} are no longer eligible for reuse.
290+ * </p>
291+ *
292+ * @param idleTimeout The maximum period of idleness for a connection.
293+ * @param timeUnit
230294 * @return this instance.
231295 * @see #setIdleTimeout(Timeout)
232296 */
@@ -236,13 +300,14 @@ public Builder setIdleTimeout(final long idleTimeout, final TimeUnit timeUnit) {
236300 }
237301
238302 /**
239- * Defines period of inactivity after which persistent connections must
303+ * Sets the period of inactivity after which persistent connections must
240304 * be re-validated prior to being leased to the consumer. Negative values passed
241305 * to this method disable connection validation.
242306 * <p>
243307 * Default: {@code null} (undefined)
244308 * </p>
245309 *
310+ * @param validateAfterInactivity The period of inactivity after which persistent connections must be re-validated.
246311 * @return this instance.
247312 */
248313 public Builder setValidateAfterInactivity (final TimeValue validateAfterInactivity ) {
@@ -251,6 +316,10 @@ public Builder setValidateAfterInactivity(final TimeValue validateAfterInactivit
251316 }
252317
253318 /**
319+ * Sets the period of inactivity after which persistent connections must be re-validated prior to being leased to the consumer.
320+ *
321+ * @param validateAfterInactivity The period of inactivity after which persistent connections must be re-validated.
322+ * @param timeUnit The time unit of the validateAfterInactivity parameter.
254323 * @return this instance.
255324 * @see #setValidateAfterInactivity(TimeValue)
256325 */
@@ -265,6 +334,7 @@ public Builder setValidateAfterInactivity(final long validateAfterInactivity, fi
265334 * Default: {@code null} (undefined)
266335 * </p>
267336 *
337+ * @param timeToLive The total span of time connections can be kept alive or execute requests.
268338 * @return this instance.
269339 */
270340 public Builder setTimeToLive (final TimeValue timeToLive ) {
@@ -273,6 +343,10 @@ public Builder setTimeToLive(final TimeValue timeToLive) {
273343 }
274344
275345 /**
346+ * Sets the total span of time connections can be kept alive or execute requests.
347+ *
348+ * @param timeToLive The total span of time connections can be kept alive or execute requests.
349+ * @param timeUnit The time unit of the timeToLive parameter.
276350 * @return this instance.
277351 * @see #setTimeToLive(TimeValue)
278352 */
@@ -281,6 +355,11 @@ public Builder setTimeToLive(final long timeToLive, final TimeUnit timeUnit) {
281355 return this ;
282356 }
283357
358+ /**
359+ * Builds a new {@link ConnectionConfig} instance based on the values provided to the setters methods.
360+ *
361+ * @return a new {@link ConnectionConfig} instance.
362+ */
284363 public ConnectionConfig build () {
285364 return new ConnectionConfig (
286365 connectTimeout != null ? connectTimeout : DEFAULT_CONNECT_TIMEOUT ,
0 commit comments