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

Support null as an empty source #1146

Closed
abelsromero opened this issue Mar 19, 2023 · 0 comments · Fixed by #1148
Closed

Support null as an empty source #1146

abelsromero opened this issue Mar 19, 2023 · 0 comments · Fixed by #1148

Comments

@abelsromero
Copy link
Member

convert and load fail with a java assert exception when input is null String.
For satefy we should consider null as an empty value that returns an empty document, for both convert and load.

In the case of convert with Reader I'd keep the current exception, at most, add Objects.requireNonNull(reader, "reader"); to

try (Scanner scanner = new Scanner(reader).useDelimiter("\\A")){
so the users gets a hint of where the issue is without adding too much complexity.

java.lang.NullPointerException: reader
	at java.base/java.util.Objects.requireNonNull(Objects.java:233)
	at org.asciidoctor.jruby.internal.IOUtils.readFull(IOUtils.java:24)
	at org.asciidoctor.jruby.internal.JRubyAsciidoctor.convert(JRubyAsciidoctor.java:351)
	at org.asciidoctor.jruby.internal.JRubyAsciidoctor.convert(JRubyAsciidoctor.java:358)
	at org.asciidoctor.jruby.ast.impl.SectionImplTest.temporal(SectionImplTest.java:28)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at 

abelsromero added a commit to abelsromero/asciidoctorj that referenced this issue Mar 21, 2023
Both empty and null String are accepted as valid for load/convert methods
for safety.
* Minor Javadoc fixed
* Integrate WhenDocumentIsLoaded into WhenAsciiDocIsLoadedToDocument

Fixes asciidoctor#1146
abelsromero added a commit to abelsromero/asciidoctorj that referenced this issue Mar 21, 2023
Both empty and null String are accepted as valid for load/convert methods
for safety.
* Minor Javadoc fixed
* Integrate WhenDocumentIsLoaded into WhenAsciiDocIsLoadedToDocument

Fixes asciidoctor#1146
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 a pull request may close this issue.

1 participant