-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix RequestBodyUtil for older version of Android (M or before) #28399
Conversation
Hi @daisy1754! Thank you for your pull request and welcome to our community.We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Base commit: eb83356 |
Base commit: 25f7aea |
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
:/ it's sad that this is being ignored, IMO such a simple fix that fixes easy-to-reproduce crash |
195f202
to
fb951fd
Compare
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@cortinico merged this pull request in 4b39f44. |
…ook#28399) Summary: This is bugfix for following code in RequestBodyUtil.java. ``` stream.getChannel().transferFrom(channel, 0, Long.MAX_VALUE); ``` This throws IllegalArgumentException in Android M or before. It seems in old version of JVM it internally casts third argument to integer so when you pass value that is larger than Integer.MAX_VALUE app would crash. See: https://bugs.openjdk.java.net/browse/JDK-5105464 https://stackoverflow.com/questions/55696035/thrown-illegalargumentexception-when-using-java-nio ## Changelog [Android] [Fixed] Fix issue downloading request body via remote URL Pull Request resolved: facebook#28399 Test Plan: Run following code on Android M or before. It would crash w/o this PR but it won't with this PR. ``` const body = new FormData(); const image = { uri: "https://reactnative.dev/img/showcase/facebook.png", path: null }; body.append('user[img]', fileBody(image)); fetch("https://example.com", { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'multipart/form-data;', }, body: body }); ``` Reviewed By: christophpurrer, cipolleschi Differential Revision: D45057263 Pulled By: cortinico fbshipit-source-id: e0306eb157a5aa92619ac51e67d106b8651a0ba7
…ook#28399) Summary: This is bugfix for following code in RequestBodyUtil.java. ``` stream.getChannel().transferFrom(channel, 0, Long.MAX_VALUE); ``` This throws IllegalArgumentException in Android M or before. It seems in old version of JVM it internally casts third argument to integer so when you pass value that is larger than Integer.MAX_VALUE app would crash. See: https://bugs.openjdk.java.net/browse/JDK-5105464 https://stackoverflow.com/questions/55696035/thrown-illegalargumentexception-when-using-java-nio ## Changelog [Android] [Fixed] Fix issue downloading request body via remote URL Pull Request resolved: facebook#28399 Test Plan: Run following code on Android M or before. It would crash w/o this PR but it won't with this PR. ``` const body = new FormData(); const image = { uri: "https://reactnative.dev/img/showcase/facebook.png", path: null }; body.append('user[img]', fileBody(image)); fetch("https://example.com", { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'multipart/form-data;', }, body: body }); ``` Reviewed By: christophpurrer, cipolleschi Differential Revision: D45057263 Pulled By: cortinico fbshipit-source-id: e0306eb157a5aa92619ac51e67d106b8651a0ba7
Summary:
This is bugfix for following code in RequestBodyUtil.java.
This throws IllegalArgumentException in Android M or before. It seems in old version of JVM it internally casts third argument to integer so when you pass value that is larger than Integer.MAX_VALUE app would crash.
See:
https://bugs.openjdk.java.net/browse/JDK-5105464
https://stackoverflow.com/questions/55696035/thrown-illegalargumentexception-when-using-java-nio
Changelog:
[ANDROID] [FIXED] - Fix issue downloading request body via remote URL
Test Plan
Run following code on Android M or before. It would crash w/o this PR but it won't with this PR.