Skip to content

Fix [MDEP-931] Replace PrintWriter with Writer in AbstractSerializing Visitor and subclasses #530

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ndacyayisenga-droid
Copy link
Contributor

@Ndacyayisenga-droid Ndacyayisenga-droid commented May 20, 2025

Following this checklist to help us incorporate your
contribution quickly and easily:

Fixes https://issues.apache.org/jira/browse/MDEP-931

cc @elharo

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

List<DependencyNode> children = node.getChildren();
for (DependencyNode child : children) {
writer.write("\t\"" + node.toNodeString() + "\" -> \"" + child.toNodeString() + "\" ; "
+ System.lineSeparator());
Copy link
Contributor

Choose a reason for hiding this comment

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

Output should be platform independent. That is, use \n

writer.flush();
return true;
} catch (IOException e) {
throw new RuntimeException("Failed to write to DOT output", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

UncheckedIOException but really we need to figure out how to not thrown an exception at all here, or perhaps change the method signature. Possibly we need to put everything in a StringWriter first and then write the string later.

}
return true;
} catch (IOException e) {
throw new RuntimeException("Failed to write to DOT output", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

writer.flush();
return true;
} catch (IOException e) {
throw new RuntimeException("Failed to write GraphML node", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

}
return true;
} catch (IOException e) {
throw new RuntimeException("Failed to write GraphML edge or footer", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

writer.write(sb.toString());
writer.flush();
} catch (IOException e) {
throw new RuntimeException("Failed to write JSON output", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

try {
if (node.getParent() == null || node.getParent() == node) {
// dump edges on last node endVisit
writer.write("#" + System.lineSeparator());
Copy link
Contributor

Choose a reason for hiding this comment

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

\n

}
writer.flush();
} else {
DependencyNode p = node.getParent();
Copy link
Contributor

Choose a reason for hiding this comment

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

p --> parent

writer.write("#" + System.lineSeparator());
for (EdgeAppender edge : edges) {
writer.write(edge.toString());
writer.write(System.lineSeparator());
Copy link
Contributor

Choose a reason for hiding this comment

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

\n

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.

2 participants