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

JRuby NPE parsing an invalid XML instruction #838

Closed
bhollis opened this issue Jan 18, 2013 · 1 comment
Closed

JRuby NPE parsing an invalid XML instruction #838

bhollis opened this issue Jan 18, 2013 · 1 comment

Comments

@bhollis
Copy link

bhollis commented Jan 18, 2013

Under JRuby 1.7.2, this:

Nokogiri::XML("<? ?>")

Causes:

null:-1:in `scanPIData': java.lang.NullPointerException
    from null:-1:in `scanPIData'
    from null:-1:in `scanPI'
    from null:-1:in `dispatch'
    from null:-1:in `scanDocument'
    from null:-1:in `parse'
    from null:-1:in `parse'
    from null:-1:in `parse'
    from null:-1:in `parse'
    from NokogiriDomParser.java:94:in `parse'
    from XmlDomParserContext.java:249:in `do_parse'
    from XmlDomParserContext.java:236:in `parse'
    from XmlDocument.java:325:in `newFromData'
    from XmlDocument.java:339:in `read_memory'
    from XmlDocument$INVOKER$s$0$0$read_memory.gen:-1:in `call'
    from CachingCallSite.java:296:in `cacheAndCall'
    from CachingCallSite.java:72:in `call'
    from FCallManyArgsNode.java:60:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from IfNode.java:118:in `interpret'
    from LocalAsgnNode.java:123:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from BlockNode.java:71:in `interpret'
    from ASTInterpreter.java:75:in `INTERPRET_METHOD'
    from InterpretedMethod.java:112:in `call'
    from DefaultMethod.java:154:in `call'
    from CachingCallSite.java:286:in `cacheAndCall'
    from CachingCallSite.java:81:in `callBlock'
    from CachingCallSite.java:85:in `call'
    from CallManyArgsBlockPassNode.java:57:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from ASTInterpreter.java:75:in `INTERPRET_METHOD'
    from InterpretedMethod.java:182:in `call'
    from DefaultMethod.java:188:in `call'
    from CachingCallSite.java:326:in `cacheAndCall'
    from CachingCallSite.java:170:in `call'
    from ./noko2.rb:7:in `__file__'
    from ./noko2.rb:-1:in `load'
    from Ruby.java:810:in `runScript'
    from Ruby.java:803:in `runScript'
    from Ruby.java:674:in `runNormally'
    from Ruby.java:523:in `runFromMain'
    from Main.java:390:in `doRunFromMain'
    from Main.java:279:in `internalRun'
    from Main.java:221:in `run'
    from Main.java:201:in `main'

I know it's not valid XML, but I'd rather get an error or an empty document (like how MRI version does) than an NPE.

@bhollis
Copy link
Author

bhollis commented Jan 21, 2013

Thanks!

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

No branches or pull requests

2 participants