File tree 1 file changed +11
-11
lines changed
spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/payload
1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -84,11 +84,11 @@ public void assignTo(HttpOutputMessage message) throws IOException {
84
84
headers .setContentLength (this .data .remaining ());
85
85
headers .add (SEQ_HEADER , Long .toString (getSequence ()));
86
86
headers .setContentType (MediaType .APPLICATION_OCTET_STREAM );
87
- WritableByteChannel body = Channels .newChannel (message .getBody ());
88
- while (this .data .hasRemaining ()) {
89
- body .write (this .data );
87
+ try (WritableByteChannel body = Channels .newChannel (message .getBody ())) {
88
+ while (this .data .hasRemaining ()) {
89
+ body .write (this .data );
90
+ }
90
91
}
91
- body .close ();
92
92
}
93
93
94
94
/**
@@ -117,14 +117,14 @@ public static HttpTunnelPayload get(HttpInputMessage message) throws IOException
117
117
}
118
118
String seqHeader = message .getHeaders ().getFirst (SEQ_HEADER );
119
119
Assert .state (StringUtils .hasLength (seqHeader ), "Missing sequence header" );
120
- ReadableByteChannel body = Channels .newChannel (message .getBody ());
121
- ByteBuffer payload = ByteBuffer .allocate ((int ) length );
122
- while (payload .hasRemaining ()) {
123
- body .read (payload );
120
+ try (ReadableByteChannel body = Channels .newChannel (message .getBody ())) {
121
+ ByteBuffer payload = ByteBuffer .allocate ((int ) length );
122
+ while (payload .hasRemaining ()) {
123
+ body .read (payload );
124
+ }
125
+ payload .flip ();
126
+ return new HttpTunnelPayload (Long .valueOf (seqHeader ), payload );
124
127
}
125
- body .close ();
126
- payload .flip ();
127
- return new HttpTunnelPayload (Long .valueOf (seqHeader ), payload );
128
128
}
129
129
130
130
/**
You can’t perform that action at this time.
0 commit comments