apache/iceberg · error · UnsupportedOperationException
NOOP timer has no unit
Error message
NOOP timer has no unit
What it means
The NOOP Timer has no configured reporting time unit because it never stores measurements. unit() throws UnsupportedOperationException to signal that this timer is a no-op sink and cannot describe its units. Only real timer implementations carry a TimeUnit.
Source
Thrown at api/src/main/java/org/apache/iceberg/metrics/Timer.java:150
new Timer() {
@Override
public Timed start() {
return Timed.NOOP;
}
@Override
public long count() {
throw new UnsupportedOperationException("NOOP timer has no count");
}
@Override
public Duration totalDuration() {
throw new UnsupportedOperationException("NOOP timer has no duration");
}
@Override
public TimeUnit unit() {
throw new UnsupportedOperationException("NOOP timer has no unit");
}
@Override
public void record(long amount, TimeUnit unit) {}
@Override
public void time(Runnable runnable) {}
@Override
public <T> T timeCallable(Callable<T> callable) throws Exception {
return callable.call();
}
@Override
public <T> T time(Supplier<T> supplier) {
return supplier.get();
}
View on GitHub (pinned to 86d9c8fc54)
Solutions
- Use a concrete Timer implementation with a defined unit instead of Timer.NOOP when unit information is required.
- Branch on the NOOP instance and supply a default TimeUnit (e.g. TimeUnit.NANOSECONDS) for reporting purposes.
- Filter out NOOP timers before iterating timers in report-building code.
Example fix
// before TimeUnit unit = timer.unit(); // after TimeUnit unit = (timer == Timer.NOOP) ? TimeUnit.NANOSECONDS : timer.unit();
Defensive patterns
Strategy: type-guard
Validate before calling
boolean hasUnit = timer != Timer.NOOP;
Type guard
if (timer == Timer.NOOP) { return TimeUnit.NANOSECONDS; } return timer.unit(); Try / catch
try { return timer.unit(); } catch (UnsupportedOperationException e) { return TimeUnit.NANOSECONDS; } Prevention
- Default the unit at the reporting layer instead of querying NOOP timers
- Filter NOOP instances before serializing metrics
- Document that NOOP metrics are write-only
When it happens
Trigger: Calling Timer.NOOP.unit(), typically when serializing or reporting metrics and the code asks each timer for its unit regardless of implementation.
Common situations: Metric report/serialization code (e.g. producing commit reports) that queries unit() on every timer in a metrics structure while metrics are disabled; generic metric aggregation utilities.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- NOOP timer has no count
- NOOP timer has no duration
- NOOP counter has no value
- Count is not supported.
- Counter is not supported.
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/2d05fdcf086ebf11.
Report an issue: GitHub.