pinpoint-apm/pinpoint · error · HBaseAccessException

Connection already closed

Error message

Connection already closed

What it means

HbaseAdminFactory.getAdmin() checks the wrapped HBase Connection's isClosed() state before requesting an Admin. If the shared connection has already been closed, it throws HBaseAccessException('Connection already closed') rather than letting the client library fail with a less clear IOException deep inside connection.getAdmin().

Source

Thrown at commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/HbaseAdminFactory.java:39

import java.io.IOException;
import java.util.Objects;

/**
 * @author HyunGil Jeong
 */
public class HbaseAdminFactory implements AdminFactory {

    private final Connection connection;

    public HbaseAdminFactory(Connection connection) {
        this.connection = Objects.requireNonNull(connection, "connection");
    }

    @Override
    public Admin getAdmin() {
        if (connection.isClosed()) {
            throw new HBaseAccessException("Connection already closed");
        }
        try {
            return connection.getAdmin();
        } catch (IOException e) {
            throw new HbaseSystemException(e);
        }
    }

    @Override
    public void releaseAdmin(Admin admin) {
        if (admin == null) {
            return;
        }
        try {
            admin.close();
        } catch (IOException e) {
            throw new HbaseSystemException(e);
        }

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Ensure the connection lifecycle outlives all getAdmin() calls — close the connection only at application shutdown, after admin usage stops
  2. Recreate/reopen the HBase Connection and rebuild the HbaseAdminFactory before calling getAdmin() again
  3. Catch HBaseAccessException and treat it as a fatal lifecycle error rather than retrying on the same closed connection

Example fix

// before
admin = hbaseAdminFactory.getAdmin(); // connection already closed
// after
if (!connection.isClosed()) {
    admin = hbaseAdminFactory.getAdmin();
} else {
    connection = connectionFactory.createConnection(conf);
    admin = hbaseAdminFactory.getAdmin();
}
Defensive patterns

Strategy: try-catch

Validate before calling

public boolean canGetAdmin(HbaseAdminFactory factory, Connection connection) {
    return connection != null && !connection.isClosed();
}

Try / catch

try {
    Admin admin = hbaseAdminFactory.getAdmin();
} catch (HBaseAccessException e) {
    log.error("HBase connection already closed: {}", e.getMessage());
    // reopen connection or abort admin operation
}

Prevention

When it happens

Trigger: Calling getAdmin() after the owning HbaseConnection (or application shutdown hook) closed the underlying Connection; using a factory bean whose connection was closed due to a prior lifecycle error; retrieving an admin during/after application shutdown.

Common situations: Admin operations (table create/delete, namespace management) executed after Spring context closed the HBase connection bean; a component holding a stale HbaseAdminFactory reference across a reconnect/restart cycle; double-close of the connection then continued admin use.

Related errors


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/8b57b373e8d5ab19. Report an issue: GitHub.