Skip to content

Commit f761339

Browse files
author
Caitlin Bales (MSFT)
authored
Merge pull request #56 from davidmoten/multipart-fix
Multipart should close InputStream
2 parents cfc54a5 + eaa9139 commit f761339

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/com/microsoft/graph/models/extensions/Multipart.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,12 @@ private byte[] getByteArray(InputStream in) throws IOException {
135135
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
136136
int nRead;
137137
byte[] data = new byte[16384];
138-
while ((nRead = in.read(data, 0, data.length)) != -1) {
139-
buffer.write(data, 0, nRead);
138+
try {
139+
while ((nRead = in.read(data, 0, data.length)) != -1) {
140+
buffer.write(data, 0, nRead);
141+
}
142+
} finally {
143+
in.close();
140144
}
141145
buffer.flush();
142146
return buffer.toByteArray();

0 commit comments

Comments
 (0)