apache/pulsar · error · IllegalArgumentException
time cannot be empty
Error message
time cannot be empty
What it means
Null/empty guard at the top of RelativeTimeUtil.parseRelativeTimeInSeconds: the relativeTime argument is blank (null or empty), so no duration string exists to parse; callers passing an unset CLI option for a relative time (e.g. ttl or retention) hit this validation.
Source
Thrown at pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/converters/RelativeTimeUtil.java:30
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "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;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.concurrent.TimeUnit;
import lombok.experimental.UtilityClass;
@UtilityClass
public class RelativeTimeUtil {
public static long parseRelativeTimeInSeconds(String relativeTime) {
if (relativeTime.isEmpty()) {
throw new IllegalArgumentException("time cannot be empty");
}
int lastIndex = relativeTime.length() - 1;
char lastChar = relativeTime.charAt(lastIndex);
final char timeUnit;
if (!Character.isAlphabetic(lastChar)) {
// No unit specified, assume seconds
timeUnit = 's';
lastIndex = relativeTime.length();
} else {
timeUnit = Character.toLowerCase(lastChar);
}
long duration = Long.parseLong(relativeTime.substring(0, lastIndex));
switch (timeUnit) {
case 's':View on GitHub (pinned to 820761864e)
Solutions
- Provide a non-empty duration like '30s', '5m', '2h', '7d'
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/converters/RelativeTimeUtil.java:30 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/5f73eb5b64b520cf.
Report an issue: GitHub.