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

Don't panic when defer a cache that has failed to init #73

Merged
merged 2 commits into from
Mar 29, 2021

Conversation

thomaspoignant
Copy link
Owner

Description

If you the ffclient.Init method return an error and you don't exit at that moment, the ffclient.Close function can panic.

Example:

	err := ffclient.Init(ffclient.Config{
		PollInterval: 3,
		Retriever: &ffclient.FileRetriever{
			Path: "testdata/flag-config2.toml",
		},
		FileFormat: "toml",
	})
	defer ffclient.Close()

This PR avoids panic while calling the Close method if no cache initialized.

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking changes (change that is not backward-comptible and/or changes current functionality)

Checklist

  • I have tested this code
  • I have added unit test to cover this code
  • I have updated the Readme
  • I have followed the contributing guide

@thomaspoignant thomaspoignant changed the title Don't when defer a cache that has failed to init Don't panic when defer a cache that has failed to init Mar 29, 2021
@thomaspoignant thomaspoignant added the bug Something isn't working label Mar 29, 2021
@sonarcloud
Copy link

sonarcloud bot commented Mar 29, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@thomaspoignant thomaspoignant merged commit 574f9a6 into main Mar 29, 2021
@thomaspoignant thomaspoignant deleted the fix/dont-panic-when-close-cache branch March 29, 2021 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant