Skip to content

[BUG]: Semaphore Release Bug when an error occurs before GetConnection in JvmBridge #1060

Open
@Macromullet

Description

@Macromullet

Describe the bug
In JvmBridge, a semaphore is used to restrict the number of active sockets. The semaphore is waited for in GetConnection() and released in the finally block. Unfortunately there are calls before GetConnection() where the semaphore is acquired that are not guaranteed to always run successfully. In situations where there is an error before GetConnection(), the semaphore is never attempted to Wait() and the subsequent finally Release() yields an error that the semaphore count went over the max allowed.

Steps to repro (easy):
The easiest way to make this happen is to add a throw new Exception("Test") block before the GetConnection() call.

Steps to reproduce the behavior (how I found it):
I tried to make a dataFrame using the GenericRow[] and passed DateTime.Now as one of the objects. PayloadHelper.BuildPayload didn't like that and errored. This caused the semaphore counts to get out of whack.

Expected behavior
Semaphores should always have perfect acquire/release guarantees.

I'll attempt a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions