Skip to content
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 NullPointerException in BinaryResource #813

Open
wants to merge 1 commit into
base: releases/22.0
Choose a base branch
from

Conversation

nsteger
Copy link
Member

@nsteger nsteger commented Dec 11, 2023

java.lang.String.String(byte[], Charset) expects not null arguments, fix this call in BinaryResource.java

363702

java.lang.String.String(byte[], Charset) expects not null arguments, fix
this call in BinaryResource.java

363702
@@ -159,7 +159,7 @@ public String getContentAsString() {
if (getCharset() != null) {
charset = Charset.forName(getCharset());
}
return new String(m_content, charset);
return m_content != null ? new String(m_content, charset) : null;
Copy link
Contributor

Choose a reason for hiding this comment

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

richtig modern?

return Optional.ofNullable(m_content) .map(c -> new String(c, Optional.ofNullable(getCharset()) .map(Charset::forName) .orElse(StandardCharsets.UTF_8))) .orElse(null);

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.

None yet

2 participants