@@ -206,11 +206,31 @@ public Builder basePath(String basePath) {
206206 return this ;
207207 }
208208
209+ /**
210+ * Sets a custom Hadoop Configuration.
211+ *
212+ * <p>Use this to override default Hadoop settings or provide configuration
213+ * for HA NameNodes, Kerberos authentication, etc.</p>
214+ *
215+ * <p>If not set, creates a new Configuration() which loads from classpath.</p>
216+ *
217+ * @param configuration Hadoop Configuration (null to use default)
218+ * @return this builder
219+ */
209220 public Builder configuration (Configuration configuration ) {
210221 this .configuration = configuration ;
211222 return this ;
212223 }
213224
225+ /**
226+ * Sets the maximum allowed class file size.
227+ *
228+ * <p>Prevents OOM attacks by rejecting files larger than this limit.</p>
229+ *
230+ * @param maxBytes Maximum size in bytes (default: 10MB)
231+ * @return this builder
232+ * @throws IllegalArgumentException if maxBytes <= 0
233+ */
214234 public Builder maxClassSize (long maxBytes ) {
215235 if (maxBytes <= 0 ) {
216236 throw new IllegalArgumentException ("maxClassSize must be positive" );
@@ -219,6 +239,15 @@ public Builder maxClassSize(long maxBytes) {
219239 return this ;
220240 }
221241
242+ /**
243+ * Sets the socket timeout for HDFS read operations.
244+ *
245+ * <p>Prevents hanging indefinitely when reading class files from HDFS.</p>
246+ *
247+ * @param timeoutMs Timeout in milliseconds (default: 30000ms = 30 seconds, 0 = infinite)
248+ * @return this builder
249+ * @throws IllegalArgumentException if timeoutMs < 0
250+ */
222251 public Builder socketTimeout (int timeoutMs ) {
223252 if (timeoutMs < 0 ) {
224253 throw new IllegalArgumentException ("socketTimeout must be >= 0" );
@@ -227,6 +256,15 @@ public Builder socketTimeout(int timeoutMs) {
227256 return this ;
228257 }
229258
259+ /**
260+ * Sets the connection timeout for HDFS NameNode connections.
261+ *
262+ * <p>Prevents hanging indefinitely when connecting to HDFS.</p>
263+ *
264+ * @param timeoutMs Timeout in milliseconds (default: 10000ms = 10 seconds, 0 = infinite)
265+ * @return this builder
266+ * @throws IllegalArgumentException if timeoutMs < 0
267+ */
230268 public Builder connectTimeout (int timeoutMs ) {
231269 if (timeoutMs < 0 ) {
232270 throw new IllegalArgumentException ("connectTimeout must be >= 0" );
@@ -235,6 +273,14 @@ public Builder connectTimeout(int timeoutMs) {
235273 return this ;
236274 }
237275
276+ /**
277+ * Builds the HdfsClassSource with configured settings.
278+ *
279+ * <p>Establishes connection to HDFS FileSystem.</p>
280+ *
281+ * @return A new HdfsClassSource instance
282+ * @throws IOException if HDFS connection fails
283+ */
238284 public HdfsClassSource build () throws IOException {
239285 Configuration conf = configuration != null ? configuration : new Configuration ();
240286
0 commit comments