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

Add warning for duplicate instance name #484

Merged
merged 1 commit into from
Nov 1, 2023

Conversation

rayz
Copy link
Contributor

@rayz rayz commented Oct 11, 2023

We currently attempt to instantiate all instances even if an instance with the same name has already been seen.

This pr adds a warn log

@rayz rayz force-pushed the raymond.zhao/AMLII-1111-warn-duplicate-instance-name branch from a8a11de to 99f96b2 Compare October 11, 2023 20:13
@rayz rayz marked this pull request as ready for review October 11, 2023 20:18
@rayz rayz requested a review from a team as a code owner October 11, 2023 20:18
@rayz rayz requested a review from carlosroman October 12, 2023 14:05
@@ -828,6 +830,8 @@ public void init(final boolean forceNewConnection) {
this.brokenInstanceMap.clear();

final List<Instance> newInstances = new ArrayList<>();
// used to track instance names already seen
Set<String> instanceNames = new HashSet<String>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Set<String> instanceNames = new HashSet<String>();
Set<String> instanceNamesSeen = new HashSet<String>();

This is a good example of a comment that would be better expressed in the naming of the variable IMO

final String instanceName = (String) configInstance.get("name");
if (instanceName != null) {
if (instanceNames.contains(instanceName)) {
log.warn("Instance with name: {} already exists", instanceName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
log.warn("Instance with name: {} already exists", instanceName);
log.warn("Found multiple instances with name: '{}'. Instance names should be unique, update the 'name' field on your instances to be unique.", instanceName);

My thought here is to have some call-to-action so that someone looking at this warning log will know what needs to happen to address this error.

(and make it the same for the json configs below)

@rayz rayz force-pushed the raymond.zhao/AMLII-1111-warn-duplicate-instance-name branch from 96eba4f to fbf9c49 Compare October 16, 2023 14:44
@rayz rayz force-pushed the raymond.zhao/AMLII-1111-warn-duplicate-instance-name branch from fbf9c49 to 5227dba Compare October 24, 2023 15:36
@rayz rayz merged commit 07c3f70 into master Nov 1, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants