-
Notifications
You must be signed in to change notification settings - Fork 45
Feat/external document #5334
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?
Feat/external document #5334
Conversation
return result; | ||
} | ||
|
||
public DocumentMetadata metadata() { |
Check notice
Code scanning / CodeQL
Missing Override annotation Note
Document.metadata
@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
Show autofix suggestion
Hide autofix suggestion
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.
-
Copy modified lines R83-R91
@@ -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 |
Description
Related issues
closes #
Checklist
no milestone
label.