Hive: NPE in MetastoreLock.findLock() when ShowLocksResponse has no locks

Open
#19,234 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@pratham76 is already working on this.

Since Dec 1, 2026.

  • #19235 by @pratham76 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
java
Domain
backend, databases

Research direction

Start in MetastoreLock.findLock() at MetastoreLock.java:375, where ShowLocksResponse.getLocks() is iterated, and read the createLock() call path around lines 302–314. Check how the code handles a response with no locks while preserving the original TException. Done means this case no longer throws an NPE; an open linked pull request (#19235) already addresses the issue.

Written by the indexing model from the issue text.

Description

When lock() fails, MetastoreLock.createLock() calls findLock(), which iterates
ShowLocksResponse.getLocks() without a null check. locks is optional, and some metastores
return a response without it set. The resulting NPE hides the original TException from
lock().

java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because the return value of "org.apache.hadoop.hive.metastore.api.ShowLocksResponse.getLocks()" is null
	at org.apache.iceberg.hive.MetastoreLock.findLock(MetastoreLock.java:375)
	at org.apache.iceberg.hive.MetastoreLock.lambda$createLock$...(MetastoreLock.java:314)
	...
	at org.apache.iceberg.hive.MetastoreLock.createLock(MetastoreLock.java:302)
	at org.apache.iceberg.hive.MetastoreLock.acquireLock(MetastoreLock.java:185)
	at org.apache.iceberg.hive.MetastoreLock.lock(MetastoreLock.java:146)
	at org.apache.iceberg.hive.HiveTableOperations.doCommit(HiveTableOperations.java:272)
	...

Affects 1.11.0, 1.12.0 and main.

Dominant language
Java
Stars
9.5k
Forks
3.7k
Avg merge
2d 2h
Merged PRs (30d)
170

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/iceberg

All issues in apache/iceberg

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.