-
Notifications
You must be signed in to change notification settings - Fork 519
Harden handleError() against secondary exceptions #7387
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -157,13 +157,15 @@ public Docker visitArg(Docker.Arg arg, PrintOutputCapture<P> p) { | |||
| public Docker visitEnv(Docker.Env env, PrintOutputCapture<P> p) { | ||||
| beforeSyntax(env, p); | ||||
| p.append(env.getKeyword()); | ||||
| for (Docker.Env.EnvPair pair : env.getPairs()) { | ||||
| visitSpace(pair.getPrefix(), p); | ||||
| visit(pair.getKey(), p); | ||||
| if (pair.isHasEquals()) { | ||||
| p.append("="); | ||||
| if (env.getPairs() != null) { | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think Merlin would have fixed this in his AST write PR. Not sure if we'd need this still then, as I would not expect the field to be null ever, but haven't checked (on mobile on plane)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/openrewrite/rewrite/blob/main/rewrite-docker/src/main/java/org/openrewrite/docker/DockerVisitor.java#L133 is null safe, but this one is not. I will let you decide if we want to have this "defensive" fix in or not :)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I now see neither field had a safe default, so yes then this makes sense, thanks.
Might even want to mark those as nullable then, unless I misunderstood. Still reading from a small screen. |
||||
| for (Docker.Env.EnvPair pair : env.getPairs()) { | ||||
| visitSpace(pair.getPrefix(), p); | ||||
| visit(pair.getKey(), p); | ||||
| if (pair.isHasEquals()) { | ||||
| p.append("="); | ||||
| } | ||||
| visit(pair.getValue(), p); | ||||
| } | ||||
| visit(pair.getValue(), p); | ||||
| } | ||||
| afterSyntax(env, p); | ||||
| return env; | ||||
|
|
@@ -173,13 +175,15 @@ public Docker visitEnv(Docker.Env env, PrintOutputCapture<P> p) { | |||
| public Docker visitLabel(Docker.Label label, PrintOutputCapture<P> p) { | ||||
| beforeSyntax(label, p); | ||||
| p.append(label.getKeyword()); | ||||
| for (Docker.Label.LabelPair pair : label.getPairs()) { | ||||
| visitSpace(pair.getPrefix(), p); | ||||
| visit(pair.getKey(), p); | ||||
| if (pair.isHasEquals()) { | ||||
| p.append("="); | ||||
| if (label.getPairs() != null) { | ||||
| for (Docker.Label.LabelPair pair : label.getPairs()) { | ||||
| visitSpace(pair.getPrefix(), p); | ||||
| visit(pair.getKey(), p); | ||||
| if (pair.isHasEquals()) { | ||||
| p.append("="); | ||||
| } | ||||
| visit(pair.getValue(), p); | ||||
| } | ||||
| visit(pair.getValue(), p); | ||||
| } | ||||
| afterSyntax(label, p); | ||||
| return label; | ||||
|
|
||||
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.
Good catch!