apache/pulsar · error · TypeConversionException

e.getMessage()

Error message

e.getMessage()

What it means

ByteUnitToIntegerConverter.convert wraps the underlying IllegalArgumentException from validateSizeString into picocli's TypeConversionException, forwarding the original message (hence 'e.getMessage()') when the CLI value is not a valid byte size.

Source

Thrown at pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/converters/picocli/ByteUnitToIntegerConverter.java:32

 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.pulsar.cli.converters.picocli;

import static org.apache.pulsar.cli.converters.ByteUnitUtil.validateSizeString;
import picocli.CommandLine.ITypeConverter;
import picocli.CommandLine.TypeConversionException;

public class ByteUnitToIntegerConverter implements ITypeConverter<Integer> {
    @Override
    public Integer convert(String value) throws Exception {
        try {
            long l = validateSizeString(value);
            return Math.toIntExact(l);
        } catch (Exception e) {
            throw new TypeConversionException(e.getMessage());
        }
    }
}

View on GitHub (pinned to 820761864e)

Solutions

  1. Fix the size argument format per the converter message (e.g., 10M, 1G)
  2. Ensure the value fits in an int after unit expansion
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/converters/picocli/ByteUnitToIntegerConverter.java:32 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/a85b5ca87ad07bc7. Report an issue: GitHub.