Skip to content

Conversation

ztefanie
Copy link
Collaborator

@ztefanie ztefanie commented Sep 3, 2025

Description

Related issues

closes #

Checklist

  • PR has a milestone or the no milestone label.
  • Backport labels are added if these code changes should be backported. No backport label is added to the latest release, as this branch will be rebased onto main before the next release.

@ztefanie ztefanie changed the base branch from main to chore/refactoring-of-document-code September 3, 2025 08:11
return result;
}

public DocumentMetadata metadata() {

Check notice

Code scanning / CodeQL

Missing Override annotation Note

This method overrides
Document.metadata
; it is advisable to add an Override annotation.
@Override
public Long getSize() {
return getResult().headers().get("content-length") instanceof String sizeStr
? Long.parseLong(sizeStr)

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.

Copilot Autofix

AI 6 days ago

To fix the problem, the call to Long.parseLong(sizeStr) should be surrounded with a try-catch block that catches NumberFormatException. If parsing fails, the code should return -1L (the code's current fallback in the else clause), or another appropriate fallback value. Only the body of the getSize() override (lines 82–85) in the anonymous DocumentMetadata implementation in metadata() (lines 68–108) should be changed. No additional imports or class-level definitions are necessary, as NumberFormatException is part of the Java standard library and is already available.


Suggested changeset 1
connector-runtime/connector-runtime-core/src/main/java/io/camunda/connector/runtime/core/document/ExternalDocument.java

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/connector-runtime/connector-runtime-core/src/main/java/io/camunda/connector/runtime/core/document/ExternalDocument.java b/connector-runtime/connector-runtime-core/src/main/java/io/camunda/connector/runtime/core/document/ExternalDocument.java
--- a/connector-runtime/connector-runtime-core/src/main/java/io/camunda/connector/runtime/core/document/ExternalDocument.java
+++ b/connector-runtime/connector-runtime-core/src/main/java/io/camunda/connector/runtime/core/document/ExternalDocument.java
@@ -80,9 +80,15 @@
 
           @Override
           public Long getSize() {
-            return getResult().headers().get("content-length") instanceof String sizeStr
-                ? Long.parseLong(sizeStr)
-                : -1L;
+            if (getResult().headers().get("content-length") instanceof String sizeStr) {
+              try {
+                return Long.parseLong(sizeStr);
+              } catch (NumberFormatException e) {
+                return -1L;
+              }
+            } else {
+              return -1L;
+            }
           }
 
           @Override
EOF
@@ -80,9 +80,15 @@

@Override
public Long getSize() {
return getResult().headers().get("content-length") instanceof String sizeStr
? Long.parseLong(sizeStr)
: -1L;
if (getResult().headers().get("content-length") instanceof String sizeStr) {
try {
return Long.parseLong(sizeStr);
} catch (NumberFormatException e) {
return -1L;
}
} else {
return -1L;
}
}

@Override
Copilot is powered by AI and may make mistakes. Always verify output.
Base automatically changed from chore/refactoring-of-document-code to main September 8, 2025 14:15
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