From 47e99157a1f3b2541b2044b1623520d26a621c57 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Wed, 28 Oct 2026 13:32:09 +0100 Subject: [PATCH] Javadoc: Note that parsed option values are converted on every call getParsedOptionValue() and getParsedOptionValues() run the option's Converter each time they are called and don't cache the result. That doesn't matter for numbers or strings, but with a converter that has side effects, like the default FileInputStream one, every call opens a new stream. Mention it in the CommandLine class Javadoc. Co-Authored-By: Claude Opus 5.5 --- src/main/java/org/apache/commons/cli/CommandLine.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/apache/commons/cli/CommandLine.java b/src/main/java/org/apache/commons/cli/CommandLine.java index 2942d5f92..5498e3fec 100644 --- a/src/main/java/org/apache/commons/cli/CommandLine.java +++ b/src/main/java/org/apache/commons/cli/CommandLine.java @@ -37,6 +37,11 @@ Licensed to the Apache Software Foundation (ASF) under one or more *

* Additionally, any left-over or unrecognized arguments, are available for further processing. *

+ *

+ * The {@code getParsedOptionValue} and {@code getParsedOptionValues} methods apply the option's {@link Converter} on every call and do not cache the result, + * so a converter with side effects repeats them on each call. For example, the default converter for {@code FileInputStream} options opens a new stream + * every time. + *

*/ public class CommandLine implements Serializable {