Skip to content

Conversation

@Pankraz76
Copy link
Contributor

@Pankraz76 Pankraz76 commented May 7, 2025

} else if (outputStream != null) {
new PluginDescriptorStaxWriter().write(outputStream, content);
} else {
try (OutputStream os = Files.newOutputStream(path)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ignore or use: Variable 'os' is never used

  • image
  • image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this looks like a critical bug and easy to prevent: https://checkstyle.sourceforge.io/checks/coding/unusedlocalvariable.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bug for bug:
image

Copy link
Contributor

Choose a reason for hiding this comment

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

You wanna try adding the rule check to the PR ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its a bug in checkstyle we already have this checker in place:

@romani

Copy link

Choose a reason for hiding this comment

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

What version of checkstyle is in use?
Please share link to config also

Copy link
Contributor Author

@Pankraz76 Pankraz76 May 8, 2025

Choose a reason for hiding this comment

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

Please share link to config also

config is mystery ATM as it comes from cloud.

Will update, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Congo is inherited from parent, but there is a way to override it and complement with the rules needed. You need to analyze how check style is configured in the parent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have this bug reproducible and tested already in

So its nice to have this info, but not mandatory anymore.

@Pankraz76
Copy link
Contributor Author

[INFO] BUILD SUCCESS

@Pankraz76 Pankraz76 marked this pull request as ready for review May 7, 2025 14:48
@Pankraz76 Pankraz76 changed the title Pull #3003: fix DefaultPluginXmlFactory#write Pull #3003: fix unused stream in DefaultPluginXmlFactory#write May 7, 2025
@Pankraz76 Pankraz76 requested a review from pzygielo May 7, 2025 14:55
Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

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

Nice catch !

@gnodet gnodet changed the title Pull #3003: fix unused stream in DefaultPluginXmlFactory#write Fix unused stream in DefaultPluginXmlFactory#write May 7, 2025
@Pankraz76
Copy link
Contributor Author

ty, will add tc as well.

}

/**
* Simply converts the given content to an XML string.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

'simply' might sound dismissive or oversimplify what readers consider a complex task

image

}

/**
* Simply parse the given xml string.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

less is more - kiss.

nonNull(request, "request");
Path path = request.getPath();
URL url = request.getURL();
Reader reader = request.getReader();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this SOC, we get better visibility into the system and can avoid unnecessary complexity in the code. The current implementation is already clean and follows a functional OOP style, but it's not the final version. There's still room to extract dedicated abstraction layers to support more specialized responsibilities.

However, this approach currently mimics fields of a class, which introduces coupling and reduces cohesion. It leans into feature envy and bypasses SOLID design principles and established architectural patterns. We should aim to refactor accordingly.

@Pankraz76 Pankraz76 requested a review from gnodet May 8, 2025 10:57
@Pankraz76 Pankraz76 changed the title Fix unused stream in DefaultPluginXmlFactory#write Fix unused stream in DefaultPluginXmlFactory#write May 8, 2025
Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

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

Removed too much.
Please don't refactor too much without care.

@Pankraz76
Copy link
Contributor Author

Removed too much. Please don't refactor too much without care.

yes

  • SOC to myself and
  • need to go right, to go fast by Uncle Bob.

test first this changes already and things get simpler

@gnodet
Copy link
Contributor

gnodet commented May 8, 2025

Removed too much. Please don't refactor too much without care.

yes

  • SOC to myself and

  • need to go right, to go fast by Uncle Bob.

test first this changes already and things get simpler

Not sure what you mean, but you removed support for URLs for no good reason. Your first commit what correct, now the PRs is not acceptable.

@Pankraz76
Copy link
Contributor Author

Pankraz76 commented May 9, 2025

imho, this branch can never happen:
because of early exit check before its to much defensive over here resulting in unreachable code.

image image

@Pankraz76
Copy link
Contributor Author

and its DRY anyway so it should resolve:
image

@Pankraz76 Pankraz76 changed the title Fix unused stream in DefaultPluginXmlFactory#write Fix dead code DefaultPluginXmlFactory#write May 9, 2025
@Pankraz76 Pankraz76 changed the title Fix dead code DefaultPluginXmlFactory#write Pull #3003: Fix dead code DefaultPluginXmlFactory#write May 9, 2025
@Pankraz76 Pankraz76 changed the title Pull #3003: Fix dead code DefaultPluginXmlFactory#write Pull #3003: Fix dead code in DefaultPluginXmlFactory#write May 9, 2025
@Pankraz76 Pankraz76 changed the title Pull #3003: Fix dead code in DefaultPluginXmlFactory#write Fix dead code in DefaultPluginXmlFactory#write May 9, 2025
@Pankraz76 Pankraz76 changed the title Fix dead code in DefaultPluginXmlFactory#write Fix unused stream in DefaultPluginXmlFactory#write May 9, 2025
@Pankraz76 Pankraz76 changed the title Fix unused stream in DefaultPluginXmlFactory#write Fix unused stream os in DefaultPluginXmlFactory#write May 9, 2025
Pankraz76 pushed a commit to Pankraz76/maven that referenced this pull request May 9, 2025
@Pankraz76
Copy link
Contributor Author

Not sure what you mean, but you removed support for URLs for no good reason. Your first commit what correct, now the PRs is not acceptable.

yes im sorry. lets SOC this merge and check on follow up to ship this fix and then improve test and everything else dedicated. Thanks for cooperation. Im learn a lot here.

Pankraz76 pushed a commit to Pankraz76/maven that referenced this pull request May 9, 2025
@Pankraz76 Pankraz76 force-pushed the fix-write branch 2 times, most recently from 86735dd to 83cfb4b Compare May 9, 2025 12:00
Pankraz76 pushed a commit to Pankraz76/maven that referenced this pull request May 9, 2025
Pankraz76 pushed a commit to Pankraz76/maven that referenced this pull request May 9, 2025
@Pankraz76
Copy link
Contributor Author

why is flaky build sometimes, not working on master too please?

image image

@Pankraz76 Pankraz76 changed the title Fix unused stream os in DefaultPluginXmlFactory#write Fix unused stream in DefaultPluginXmlFactory#write May 9, 2025
@Pankraz76 Pankraz76 requested a review from gnodet May 9, 2025 12:30
Pankraz76 pushed a commit to Pankraz76/maven that referenced this pull request May 9, 2025
Pankraz76 pushed a commit to Pankraz76/maven that referenced this pull request May 9, 2025
Pankraz76 pushed a commit to Pankraz76/maven that referenced this pull request May 9, 2025
@@ -0,0 +1,255 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
Copy link
Contributor Author

@Pankraz76 Pankraz76 May 9, 2025

Choose a reason for hiding this comment

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

@Pankraz76
Copy link
Contributor Author

Your first commit what correct

sorry for high pace. Now bug and test with minimal fix ready to merge and follow up to dig deeper.

@gnodet
Copy link
Contributor

gnodet commented May 11, 2025

You should not raise multiple PRs for the same thing, it becomes a mess and we have no idea what to review. Keep a single PR for one fix and update it.

@Pankraz76
Copy link
Contributor Author

Yes, wanted to provide quick fix upfront.

When merging this the other PR testing everything, therefore having bigger scope could be supplemented.

@Pankraz76 Pankraz76 closed this May 11, 2025
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.

4 participants