apache/pulsar · error · UnsupportedOperationException
not implemented
Error message
not implemented
What it means
BaseContext.getPulsarClient() is a default method that throws UnsupportedOperationException('not implemented'). The base context does not have a PulsarClient; only concrete contexts that receive one (e.g. Java function instances) override this.
Source
Thrown at pulsar-functions/api-java/src/main/java/org/apache/pulsar/functions/api/BaseContext.java:205
CompletableFuture<Long> getCounterAsync(String key);
/**
* Record a user defined metric.
* @param metricName The name of the metric
* @param value The value of the metric
*/
void recordMetric(String metricName, double value);
/**
* Get the pre-configured pulsar client.
*
* You can use this client to access Pulsar cluster.
* The Function will be responsible for disposing this client.
*
* @return the instance of pulsar client
*/
default PulsarClient getPulsarClient() {
throw new UnsupportedOperationException("not implemented");
}
/**
* Get the pre-configured pulsar client builder.
*
* You can use this Builder to setup client to connect to the Pulsar cluster.
* But you need to close client properly after using it.
*
* @return the instance of pulsar client builder.
*/
default ClientBuilder getPulsarClientBuilder() {
throw new UnsupportedOperationException("not implemented");
}
/**
* Terminate the function instance with a fatal exception.
*
* @param t the fatal exception to be raisedView on GitHub (pinned to 820761864e)
Solutions
- Use getPulsarClientBuilder() to build your own client when the runtime doesn't supply one
- Catch UnsupportedOperationException and create a PulsarClient manually from config
- Run the code inside the Java function instance runtime where the client is injected
- In tests, use a Context stub that overrides getPulsarClient (e.g. via Mockito spy or a test Context implementation)
Example fix
// before
PulsarClient client = context.getPulsarClient(); // throws
// after
try {
client = context.getPulsarClient();
} catch (UnsupportedOperationException e) {
client = context.getPulsarClientBuilder().serviceUrl(url).build();
} Defensive patterns
Strategy: try-catch
Validate before calling
// No pre-check; capability is discovered at call time.
Try / catch
PulsarClient client;
try {
client = ctx.getPulsarClient();
} catch (UnsupportedOperationException e) {
client = PulsarClient.builder().serviceUrl(serviceUrl).build();
} Prevention
- Use getPulsarClient() only inside Java function runtimes that inject a client
- In shared code, always have a fallback builder path
- For unit tests, stub Context with an overriding getPulsarClient
When it happens
Trigger: Calling context.getPulsarClient() from code running with a Context implementation that has not been given a PulsarClient — e.g. a sink/source connector context or unit-test Context stub.
Common situations: Shared utility code used both in sinks and functions, mocks/stubs of Context in unit tests that don't override getPulsarClient, or older runtime versions where the client was not injected.
Related errors
- Receiver queue size can't be changed in ZeroQueueConsumerImp
- Component cannot get state store
- Not implemented
- Error creating client for HealthChecker
- Expire message by timestamp is not supported for non-persist
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/7310ba8f7a7ad2b9.
Report an issue: GitHub.