-
Notifications
You must be signed in to change notification settings - Fork 159
Fix handling multiple request form #2048
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,58 @@ | ||||||||||||||||||
| /* | ||||||||||||||||||
| * ###### | ||||||||||||||||||
| * ###### | ||||||||||||||||||
| * ############ ####( ###### #####. ###### ############ ############ | ||||||||||||||||||
| * ############# #####( ###### #####. ###### ############# ############# | ||||||||||||||||||
| * ###### #####( ###### #####. ###### ##### ###### ##### ###### | ||||||||||||||||||
| * ###### ###### #####( ###### #####. ###### ##### ###### ##### ###### | ||||||||||||||||||
| * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### | ||||||||||||||||||
| * ############# ############# ############# ############# ##### ###### | ||||||||||||||||||
| * ############ ############ ############# ############# ###### | ||||||||||||||||||
| * ###### | ||||||||||||||||||
| * ############# | ||||||||||||||||||
| * ############ | ||||||||||||||||||
| * | ||||||||||||||||||
| * Adyen Java API Library | ||||||||||||||||||
| * | ||||||||||||||||||
| * Copyright (c) 2026 Adyen B.V. | ||||||||||||||||||
| * This file is open source and available under the MIT license. | ||||||||||||||||||
| * See the LICENSE file for more info. | ||||||||||||||||||
| */ | ||||||||||||||||||
| package com.adyen.httpclient; | ||||||||||||||||||
|
|
||||||||||||||||||
| import java.util.Arrays; | ||||||||||||||||||
|
|
||||||||||||||||||
| /** Contains a binary request payload and its content type. */ | ||||||||||||||||||
| public final class BinaryRequestBody { | ||||||||||||||||||
| private final byte[] data; | ||||||||||||||||||
| private final String contentType; | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Creates a binary request payload. | ||||||||||||||||||
| * | ||||||||||||||||||
| * @param data request body data | ||||||||||||||||||
| * @param contentType request content type | ||||||||||||||||||
| */ | ||||||||||||||||||
| public BinaryRequestBody(byte[] data, String contentType) { | ||||||||||||||||||
| this.data = Arrays.copyOf(data, data.length); | ||||||||||||||||||
| this.contentType = contentType; | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+36
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To prevent a potential NullPointerException when data is null, we should add a defensive null check in the constructor. If data is null, we can default to an empty byte array.
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Gets a copy of the request body data. | ||||||||||||||||||
| * | ||||||||||||||||||
| * @return request body data | ||||||||||||||||||
| */ | ||||||||||||||||||
| public byte[] getData() { | ||||||||||||||||||
| return Arrays.copyOf(data, data.length); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Gets the request content type. | ||||||||||||||||||
| * | ||||||||||||||||||
| * @return request content type | ||||||||||||||||||
| */ | ||||||||||||||||||
| public String getContentType() { | ||||||||||||||||||
| return contentType; | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,58 @@ | ||||||||||||||||||
| /* | ||||||||||||||||||
| * ###### | ||||||||||||||||||
| * ###### | ||||||||||||||||||
| * ############ ####( ###### #####. ###### ############ ############ | ||||||||||||||||||
| * ############# #####( ###### #####. ###### ############# ############# | ||||||||||||||||||
| * ###### #####( ###### #####. ###### ##### ###### ##### ###### | ||||||||||||||||||
| * ###### ###### #####( ###### #####. ###### ##### ###### ##### ###### | ||||||||||||||||||
| * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### | ||||||||||||||||||
| * ############# ############# ############# ############# ##### ###### | ||||||||||||||||||
| * ############ ############ ############# ############# ###### | ||||||||||||||||||
| * ###### | ||||||||||||||||||
| * ############# | ||||||||||||||||||
| * ############ | ||||||||||||||||||
| * | ||||||||||||||||||
| * Adyen Java API Library | ||||||||||||||||||
| * | ||||||||||||||||||
| * Copyright (c) 2026 Adyen B.V. | ||||||||||||||||||
| * This file is open source and available under the MIT license. | ||||||||||||||||||
| * See the LICENSE file for more info. | ||||||||||||||||||
| */ | ||||||||||||||||||
| package com.adyen.httpclient; | ||||||||||||||||||
|
|
||||||||||||||||||
| import java.util.Arrays; | ||||||||||||||||||
|
|
||||||||||||||||||
| /** Represents a file uploaded as part of a multipart request. */ | ||||||||||||||||||
| public class HttpFile { | ||||||||||||||||||
| private final byte[] data; | ||||||||||||||||||
| private final String name; | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Creates a file for a multipart request. | ||||||||||||||||||
| * | ||||||||||||||||||
| * @param data file contents | ||||||||||||||||||
| * @param name file name sent to the API | ||||||||||||||||||
| */ | ||||||||||||||||||
| public HttpFile(byte[] data, String name) { | ||||||||||||||||||
| this.data = Arrays.copyOf(data, data.length); | ||||||||||||||||||
| this.name = name; | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+36
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To prevent a potential NullPointerException when data is null, we should add a defensive null check in the constructor. If data is null, we can default to an empty byte array.
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Gets a copy of the file contents. | ||||||||||||||||||
| * | ||||||||||||||||||
| * @return file contents | ||||||||||||||||||
| */ | ||||||||||||||||||
| public byte[] getData() { | ||||||||||||||||||
| return Arrays.copyOf(data, data.length); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Gets the file name. | ||||||||||||||||||
| * | ||||||||||||||||||
| * @return file name | ||||||||||||||||||
| */ | ||||||||||||||||||
| public String getName() { | ||||||||||||||||||
| return name; | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent a potential NullPointerException when requestBody is null, we should add a defensive null check at the beginning of createRequest.