Skip to content

use try-with-resources statement in ResourceRegionHttpMessageConverter#35051

Closed
Pankraz76 wants to merge 1 commit intospring-projects:mainfrom
Pankraz76:fix-ResourceRegionHttpMessageConverter
Closed

use try-with-resources statement in ResourceRegionHttpMessageConverter#35051
Pankraz76 wants to merge 1 commit intospring-projects:mainfrom
Pankraz76:fix-ResourceRegionHttpMessageConverter

Conversation

@Pankraz76
Copy link

@Pankraz76 Pankraz76 commented Jun 13, 2025

before:

100% (1/1) 66% (10/15) 81% (72/88) 57% (23/40)

now:

100% (1/1) 80% (12/15) 86% (76/88) 65% (26/40)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 13, 2025
@Pankraz76 Pankraz76 force-pushed the fix-ResourceRegionHttpMessageConverter branch from 39e24fc to 746ba02 Compare June 13, 2025 14:55
Copy link
Author

@Pankraz76 Pankraz76 left a comment

Choose a reason for hiding this comment

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

history is mystery.

}
finally {
try {
in.close();
Copy link
Author

Choose a reason for hiding this comment

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

these is no special handling at all.
we still ignore IO.

Copy link
Author

Choose a reason for hiding this comment

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


InputStream in = region.getResource().getInputStream();
// We cannot use try-with-resources here for the InputStream, since we have
// custom handling of the close() method in a finally-block.
Copy link
Author

Choose a reason for hiding this comment

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

these is no special handling at all.
we still ignore IO.

@Pankraz76 Pankraz76 marked this pull request as ready for review June 13, 2025 14:56
@Pankraz76 Pankraz76 force-pushed the fix-ResourceRegionHttpMessageConverter branch from 746ba02 to 4373d57 Compare June 13, 2025 20:57
@Pankraz76 Pankraz76 force-pushed the fix-ResourceRegionHttpMessageConverter branch from 4373d57 to b317def Compare June 13, 2025 21:08
println(out);
println(out);
// Printing content
StreamUtils.copyRange(in, out, start, end);
Copy link
Author

Choose a reason for hiding this comment

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

details just one hover away:
image

println(out);
}
long resourceLength = region.getResource().contentLength();
end = Math.min(end, resourceLength - inputStreamPosition - 1);
Copy link
Author

Choose a reason for hiding this comment

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

min,max,modulo its all used very often from Math of course, as this is the happy path all around.

println(out);
// Printing content
StreamUtils.copyRange(in, out, start, end);
copyRange(in, out, start, end);
Copy link
Author

Choose a reason for hiding this comment

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

its random impl. detail where this comes from we want to copyRange who how or what seems different concern.

// custom handling of the close() method in a finally-block.
try {
StreamUtils.copyRange(in, outputMessage.getBody(), start, end);
try (var in = region.getResource().getInputStream()) {
Copy link
Author

@Pankraz76 Pankraz76 Jun 13, 2025

Choose a reason for hiding this comment

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

could see type as random impl. detail, as well.

image

Signed-off-by: Vincent Potucek <vpotucek@me.com>
@Pankraz76 Pankraz76 force-pushed the fix-ResourceRegionHttpMessageConverter branch from b317def to af07e87 Compare June 14, 2025 09:10
@bclozel
Copy link
Member

bclozel commented Jun 14, 2025

Sorry but we cannot process PRs like this. Its title says one thing but the content is all over the place, mixing stylistic changes, new attempts at introducing try-with-resources (and some changing the behavior again), a dozen comments and screenshots.

Please be more considerate of our time and stop submitting similar PRs.

@bclozel bclozel closed this Jun 14, 2025
@bclozel bclozel added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 14, 2025
@Pankraz76
Copy link
Author

yes im sorry. will give test for the catch as im interested now. dont understand so tests will help.

can we merge test then at least to improve cover?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments