use try-with-resources statement in ResourceRegionHttpMessageConverter#35051
use try-with-resources statement in ResourceRegionHttpMessageConverter#35051Pankraz76 wants to merge 1 commit intospring-projects:mainfrom
try-with-resources statement in ResourceRegionHttpMessageConverter#35051Conversation
39e24fc to
746ba02
Compare
| } | ||
| finally { | ||
| try { | ||
| in.close(); |
There was a problem hiding this comment.
these is no special handling at all.
we still ignore IO.
|
|
||
| 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. |
There was a problem hiding this comment.
these is no special handling at all.
we still ignore IO.
746ba02 to
4373d57
Compare
...ebsocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java
Show resolved
Hide resolved
4373d57 to
b317def
Compare
| println(out); | ||
| println(out); | ||
| // Printing content | ||
| StreamUtils.copyRange(in, out, start, end); |
| println(out); | ||
| } | ||
| long resourceLength = region.getResource().contentLength(); | ||
| end = Math.min(end, resourceLength - inputStreamPosition - 1); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
its random impl. detail where this comes from we want to copyRange who how or what seems different concern.
...web/src/main/java/org/springframework/http/converter/ResourceRegionHttpMessageConverter.java
Show resolved
Hide resolved
| // custom handling of the close() method in a finally-block. | ||
| try { | ||
| StreamUtils.copyRange(in, outputMessage.getBody(), start, end); | ||
| try (var in = region.getResource().getInputStream()) { |
Signed-off-by: Vincent Potucek <vpotucek@me.com>
b317def to
af07e87
Compare
|
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. |
|
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? |


before:
now: