-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
feat(avro)/refactor(core): unify *_POST_PROCESS_FILE
behaviour and reuse code
#19761
feat(avro)/refactor(core): unify *_POST_PROCESS_FILE
behaviour and reuse code
#19761
Conversation
@@ -8088,6 +8092,32 @@ public void postProcessFile(File file, String fileType) { | |||
LOGGER.debug("Post processing file {} ({})", file, fileType); | |||
} | |||
|
|||
protected void executePostProcessor(String[] commandArr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were two different variants of this code. The majority without showing the error output in case the execution was non-zero. I unified them here, taking error output into account.
@@ -890,6 +888,7 @@ public String escapeUnsafeCharacters(String input) { | |||
|
|||
@Override | |||
public void postProcessFile(File file, String fileType) { | |||
super.postProcessFile(file, fileType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few were missing super calls. The super class only has a logger statement in it currently.
@@ -155,11 +154,6 @@ public String getHelp() { | |||
public void processOpts() { | |||
super.processOpts(); | |||
|
|||
if (StringUtils.isEmpty(System.getenv("DART_POST_PROCESS_FILE"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was already available in AbstractDartCodegen
which this class inherits from.
@@ -178,11 +178,6 @@ public void processOpts() { | |||
// map to Dot instead of Period | |||
specialCharReplacements.put(".", "Dot"); | |||
|
|||
if (StringUtils.isEmpty(System.getenv("PYTHON_POST_PROCESS_FILE"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was already available in AbstractPythonCodegen
which this class inherits from.
try (InputStreamReader inputStreamReader = new InputStreamReader(p.getErrorStream(), StandardCharsets.UTF_8); | ||
BufferedReader br = new BufferedReader(inputStreamReader)) { | ||
StringBuilder sb = new StringBuilder(); | ||
String line; | ||
while ((line = br.readLine()) != null) { | ||
sb.append(line); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
majority of implementations didn't have this very helpful part
*_POST_PROCESS_FILE
bahviour and code*_POST_PROCESS_FILE
behaviour and reuse code
let me review first and reach out to them if needed. thanks for the PR |
lgtm. thanks for the refactoring |
Thanks for merging. There's a generator scaffold somewhere, should we update it there too or is it quite individual for new generators to get a post processor? |
feel free to update it. thanks (I wasn't the one creating it. To create a new generator, I usually ask users to clone an existing generator to start with) |
This PR does three things:
AVRO_POST_PROCESS_FILE
env var that is respected when file post processing is enabledDefaultCodeGen
to be reused<FILETYPE>_POST_PROCESS_FILE
flag is passed@wing328 Given that this PR touches so many generators but only refactors, doesn't change main behaviour, do I need reviews from each generator ownership team?
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming7.x.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)