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

Address thread safety issues with CelPolicy*RowMappers #501

Merged
merged 2 commits into from
Dec 20, 2023

Conversation

nscuro
Copy link
Member

@nscuro nscuro commented Dec 20, 2023

Description

Instances of the RowMappers are created once by JDBI and then re-used. The current mapper code however assumed an instance to be created per query, thus using a single Protobuf Builder, which is not thread-safe.

Create a new Builder instance for each invocation of RowMapper#map instead.

Addressed Issue

N/A

Additional Details

N/A

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
  • This PR implements an enhancement, and I have provided tests to verify that it works as intended
  • This PR introduces changes to the database model, and I have added corresponding update logic
  • This PR introduces new or alters existing behavior, and I have updated the documentation accordingly

Instances of the `RowMapper`s are created once by JDBI and then re-used. The current mapper code however assumed an instance to be created per query, thus using a single Protobuf `Builder`, which is not thread-safe.

Create a new `Builder` instance for each invocation of `RowMapper#map` instead.

Signed-off-by: nscuro <[email protected]>
@nscuro nscuro added the defect Something isn't working label Dec 20, 2023
@nscuro nscuro force-pushed the jdbi-rowmapper-threadsafety branch from c5034a2 to e7e9ff4 Compare December 20, 2023 11:59
Copy link
Collaborator

@sahibamittal sahibamittal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nscuro nscuro changed the title Address potential thread safety issues with CelPolicy*RowMappers Address thread safety issues with CelPolicy*RowMappers Dec 20, 2023
@nscuro nscuro merged commit 53b4e2f into main Dec 20, 2023
6 checks passed
@nscuro nscuro deleted the jdbi-rowmapper-threadsafety branch December 20, 2023 12:45
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 20, 2024
@nscuro nscuro added this to the 5.3.0 milestone Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
defect Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants