Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-2795: fix potential NPE in GroupMetadataManager.addGroup #488

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions core/src/main/scala/kafka/coordinator/GroupMetadataManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ class GroupMetadataManager(val brokerId: Int,
/* lock for expiring stale offsets, it should be always called BEFORE the group lock if needed */
private val offsetExpireLock = new ReentrantReadWriteLock()

/* lock for removing offsets of a range partition, it should be always called BEFORE the group lock if needed */
private val offsetRemoveLock = new ReentrantReadWriteLock()

/* shutting down flag */
private val shuttingDown = new AtomicBoolean(false)

Expand Down Expand Up @@ -116,12 +113,12 @@ class GroupMetadataManager(val brokerId: Int,
* Add a group or get the group associated with the given groupId if it already exists
*/
def addGroup(groupId: String, protocolType: String): GroupMetadata = {
addGroup(groupId, new GroupMetadata(groupId, protocolType))
}

private def addGroup(groupId: String, group: GroupMetadata): GroupMetadata = {
groupsCache.putIfNotExists(groupId, group)
groupsCache.get(groupId)
val newGroup = new GroupMetadata(groupId, protocolType)
val currentGroup = groupsCache.putIfNotExists(groupId, newGroup)
if (currentGroup != null)
currentGroup
else
newGroup
}

/**
Expand Down