Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void write(XmlWriterRequest<Model> request) throws XmlWriterException {
Writer writer = request.getWriter();
Function<Object, String> inputLocationFormatter = request.getInputLocationFormatter();
if (writer == null && outputStream == null && path == null) {
throw new IllegalArgumentException("writer, outputStream or path must be non null");
Copy link
Contributor Author

@Pankraz76 Pankraz76 May 11, 2025

Choose a reason for hiding this comment

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

this might smell, as throwing IAE but having NPE.

#2277 (comment)

throw new IllegalArgumentException("writer, output stream, or path must be non-null");
Copy link
Contributor Author

@Pankraz76 Pankraz76 May 10, 2025

Choose a reason for hiding this comment

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

Suggested change
throw new IllegalArgumentException("writer, output stream, or path must be non-null");
throw new IllegalArgumentException("writer, output stream, or path must be non-null.");

missing dot. (everywhere or nowhere)
image

Copy link
Contributor

Choose a reason for hiding this comment

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

That's wrong and unrelated to this 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.

Suggested change
throw new IllegalArgumentException("writer, output stream, or path must be non-null");
throw new IllegalArgumentException("writer, output stream, or path must be non null");

you mean the hyphen - ?

Copy link
Contributor

@gnodet gnodet May 11, 2025

Choose a reason for hiding this comment

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

No, outputStream is the parameter name, it's not output stream.
If those were common nouns, they would require an article.

Copy link
Contributor Author

@Pankraz76 Pankraz76 May 11, 2025

Choose a reason for hiding this comment

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

yes true. Making it generic would take random impl. details away. What if tomorrow foo resources is new input?
This is noise feeling fluffy and takes away from whats real business case.

We need some valid input - thats all.

Suggested change
throw new IllegalArgumentException("writer, output stream, or path must be non-null");
throw new IllegalArgumentException("No valid input source given.");

Copy link
Contributor

Choose a reason for hiding this comment

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

But that's not helpful to the user. What does 'valid' means ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we could tell, as it is.

Suggested change
throw new IllegalArgumentException("writer, output stream, or path must be non-null");
throw new IllegalArgumentException("Given input source is null.");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Considering OOP leveraging domain logic its kind of clear from the context now as the code should speak for itself:

ReadRequest/WriteRequest
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.

We should focus on communicating the actual business case rather than exposing low-level implementation details, which are likely to change.

At this stage, it’s more a matter of preference, since the code now clearly delineates each concern. Code and logging are 2 different worlds.

}
try {
MavenStaxWriter w = new MavenStaxWriter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void write(XmlWriterRequest<PluginDescriptor> request) throws XmlWriterEx
OutputStream outputStream = request.getOutputStream();
Writer writer = request.getWriter();
if (writer == null && outputStream == null && path == null) {
throw new IllegalArgumentException("writer, outputStream or path must be non null");
throw new IllegalArgumentException("writer, output stream, or path must be non-null");
}
try {
if (writer != null) {
Expand Down
Loading