Skip to content

Conversation

@akrambek
Copy link
Contributor

Description

Zilla is validating env vars before replacing them

Fixes #795

try
{
final JsonObject annotatedSchemaObject = (JsonObject) annotateJsonObject(schemaObject);
final JsonObject annotatedSchemaObject = jsonAnnotator.apply(schemaObject);
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
final JsonObject annotatedSchemaObject = jsonAnnotator.apply(schemaObject);
final EngineConfigAnnotator annotator = new EngineConfigAnnotator();
final JsonObject annotatedSchemaObject = annotator.annotate(schemaObject);

Given the state needed by internals of annotator, suggest we just instantiate this here on stack and call the annotate method directly instead of having a field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I was thinking but then thought that you have resaon

this.schemaIndexes = new LinkedList<>();
}

public JsonObject annotateJson(
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
public JsonObject annotateJson(
public JsonObject annotate(


import org.agrona.collections.MutableInteger;

public final class EngineConfigAnnotator
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add EngineConfigAnnotatorTest to verify some of the important scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good just wanted to check if that what you mean

{
private final LinkedList<String> schemaKeys;
private final LinkedList<Integer> schemaIndexes;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used implementation because I need an interface from both the deque and the list. Let me know if this is wrong

Comment on lines 60 to 61
private final EngineConfigAnnotator annotator;

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this field.

this.expressions = expressions;
this.schemaTypes = schemaTypes;
this.logger = logger;
this.annotator = new EngineConfigAnnotator();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this assignment.

try
{
final JsonObject annotatedSchemaObject = (JsonObject) annotateJsonObject(schemaObject);
final JsonObject annotatedSchemaObject = annotator.annotate(schemaObject);
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
final JsonObject annotatedSchemaObject = annotator.annotate(schemaObject);
final EngineConfigAnnotator() annotator = new EngineConfigAnnotator();;
final JsonObject annotatedSchemaObject = annotator.annotate(schemaObject);

This should be local because it has internal parse state, no need to carry any potential side effects of previous read to next read.

@jfallows jfallows merged commit 8ef7aa4 into aklivity:develop Feb 14, 2024
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.

Zilla is validating env vars before replacing them.

2 participants