Skip to content

[documentcollector] Code generation: update services and models - #2045

Open
AdyenAutomationBot wants to merge 1 commit into
mainfrom
sdk-automation/documentcollector
Open

[documentcollector] Code generation: update services and models#2045
AdyenAutomationBot wants to merge 1 commit into
mainfrom
sdk-automation/documentcollector

Conversation

@AdyenAutomationBot

Copy link
Copy Markdown
Collaborator

This PR contains the automated changes for the documentcollector service.

The commit history of this PR reflects the adyen-openapi commits that have been applied.

@AdyenAutomationBot
AdyenAutomationBot requested a review from a team as a code owner August 21, 2026 14:02

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the auto-generated Java SDK client and models for the Cross-border Invoices API (documentcollector service). While the addition of these models and API endpoints is correct in scope, several critical issues were identified in the generated code. Specifically, the uploadCrossBorderInvoice method in DocumentsApi discards all of its parameters and forwards a null request, making document uploads impossible. Additionally, the static mapper in the JSON class is unsafely initialized inside a non-static constructor, which poses thread-safety risks and should be moved to a static block. Finally, a minor improvement is needed in AbstractOpenApiSchema to add a missing @Override annotation to the equals method.

Comment on lines +60 to +64
public DocumentUploadResponse uploadCrossBorderInvoice(
DocumentContext context, File _file, String merchantAccount)
throws ApiException, IOException {
return uploadCrossBorderInvoice(null);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The generated method uploadCrossBorderInvoice completely discards its parameters (context, _file, and merchantAccount) and forwards the call to uploadCrossBorderInvoice(null). This results in an empty request body (null) being sent to the /crossBorderInvoices endpoint, making it impossible to actually upload any documents using this method.\n\nPlease verify the OpenAPI specification or the generator templates to ensure that multipart form data or request body serialization is correctly configured and generated for this endpoint.

Comment on lines +18 to +36
private static ObjectMapper mapper;

private JSON() {
mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, true);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
mapper.registerModule(new JavaTimeModule());
// Custom ByteSerializer
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(byte[].class, new ByteArraySerializer());
simpleModule.addDeserializer(byte[].class, new ByteArrayDeserializer());
mapper.registerModule(simpleModule);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The static field mapper is initialized inside the non-static constructor of the JSON class. If multiple instances of JSON are created (for example, by a JAX-RS container or via setDefault), the static mapper will be overwritten, which can lead to race conditions or unexpected configuration changes in a multi-threaded environment.\n\nIt is highly recommended to initialize the static mapper either directly at its declaration or within a static initializer block to ensure thread safety and prevent re-initialization.

  private static final ObjectMapper mapper;\n\n  static {\n    mapper = new ObjectMapper();\n    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);\n    mapper.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, true);\n    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);\n    mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);\n    mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);\n    mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);\n    mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);\n    mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);\n    mapper.registerModule(new JavaTimeModule());\n    // Custom ByteSerializer\n    SimpleModule simpleModule = new SimpleModule();\n    simpleModule.addSerializer(byte[].class, new ByteArraySerializer());\n    simpleModule.addDeserializer(byte[].class, new ByteArrayDeserializer());\n    mapper.registerModule(simpleModule);\n  }\n\n  private JSON() {\n  }

return o.toString().replace("\n", "\n ");
}

public boolean equals(Object o) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The equals method overrides Object.equals but is missing the @Override annotation. Adding @Override is a best practice that improves readability and allows the compiler to catch errors if the method signature is accidentally changed.

Suggested change
public boolean equals(Object o) {
@Override\n public boolean equals(Object o) {

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant