Skip to content

Handle nil client parameter in #check_in#37

Merged
ianoxley merged 2 commits intomasterfrom
check_in_nil
Mar 8, 2021
Merged

Handle nil client parameter in #check_in#37
ianoxley merged 2 commits intomasterfrom
check_in_nil

Conversation

@ianoxley
Copy link
Contributor

@ianoxley ianoxley commented Mar 5, 2021

When testing what happens when the connection pool is depleted, it was possible to inadvertently pass nil to #check_in. This caused an undefined method close for nil:NilClass error.

To guard against this:

  • Use the safe navigation operator when closing the connection when connection pooling is disabled
  • Add a new connection to the connection pool if client is nil when connection pooling is enabled.

ianoxley added 2 commits March 5, 2021 17:35
If the database connection pool is depleted it could be possible to
inadvertently pass `nil` to `#check_in`.

To guard against this:

- Use the safe navigation operator when calling `#close` when connection
  pooling is disabled
- Create a new connection if client is nil when connection pooling is
  enabled
@ianoxley ianoxley added the bug Something isn't working label Mar 5, 2021
@ianoxley ianoxley self-assigned this Mar 5, 2021
@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit 565c50e and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 100.0% (0.0% change).

View more on Code Climate.

@ianoxley ianoxley merged commit 2d02cd4 into master Mar 8, 2021
@ianoxley ianoxley deleted the check_in_nil branch March 8, 2021 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Development

Successfully merging this pull request may close these issues.

2 participants