Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 30778a3

Browse files
authored
fix: setfiles OOM exception (microsoft#1384)
1 parent 25ba847 commit 30778a3

File tree

1 file changed

+5
-5
lines changed
  • playwright/src/main/java/com/microsoft/playwright/impl

1 file changed

+5
-5
lines changed

playwright/src/main/java/com/microsoft/playwright/impl/Utils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,18 @@ static String mimeType(Path path) {
174174
return mimeType;
175175
}
176176

177-
static final int maxUplodBufferSize = 50 * 1024 * 1024;
177+
static final long maxUploadBufferSize = 50 * 1024 * 1024;
178178

179179
static boolean hasLargeFile(Path[] files) {
180-
int totalSize = 0;
180+
long totalSize = 0;
181181
for (Path file: files) {
182182
try {
183183
totalSize += Files.size(file);
184184
} catch (IOException e) {
185185
throw new PlaywrightException("Cannot get file size.", e);
186186
}
187187
}
188-
return totalSize > maxUplodBufferSize;
188+
return totalSize > maxUploadBufferSize;
189189
}
190190

191191
static void addLargeFileUploadParams(Path[] files, JsonObject params, BrowserContextImpl context) {
@@ -216,11 +216,11 @@ static void addLargeFileUploadParams(Path[] files, JsonObject params, BrowserCon
216216
}
217217

218218
static void checkFilePayloadSize(FilePayload[] files) {
219-
int totalSize = 0;
219+
long totalSize = 0;
220220
for (FilePayload file: files) {
221221
totalSize += file.buffer.length;
222222
}
223-
if (totalSize > maxUplodBufferSize) {
223+
if (totalSize > maxUploadBufferSize) {
224224
throw new PlaywrightException("Cannot set buffer larger than 50Mb, please write it to a file and pass its path instead.");
225225
}
226226
}

0 commit comments

Comments
 (0)