Skip to content

Commit

Permalink
Fixes 1.9 failure of html/test_document_fragment.rb. Adds to_s for 1.…
Browse files Browse the repository at this point in the history
…9 in XmlSyntaxError.
  • Loading branch information
yokolet committed May 12, 2012
1 parent 8b4529a commit dee01c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 10 additions & 2 deletions ext/java/nokogiri/XmlSyntaxError.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* (The MIT License)
*
* Copyright (c) 2008 - 2011:
* Copyright (c) 2008 - 2012:
*
* * {Aaron Patterson}[http://tenderlovemaking.com]
* * {Mike Dalessio}[http://mike.daless.io]
Expand Down Expand Up @@ -35,6 +35,7 @@
import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
import static nokogiri.internals.NokogiriHelpers.stringOrNil;

import org.jruby.CompatVersion;
import org.jruby.Ruby;
import org.jruby.RubyClass;
import org.jruby.RubyException;
Expand Down Expand Up @@ -109,11 +110,18 @@ public static RubyException createXPathSyntaxError(Ruby runtime, Exception e) {
}

@Override
@JRubyMethod(name = "to_s")
@JRubyMethod(name = "to_s", compat = CompatVersion.RUBY1_8)
public IRubyObject to_s(ThreadContext context) {
if (exception != null && exception.getMessage() != null)
return context.getRuntime().newString(exception.getMessage());
else
return super.to_s(context);
}

@Override
@JRubyMethod(name = "to_s", compat = CompatVersion.RUBY1_9)
public IRubyObject to_s19(ThreadContext context) {
return this.to_s(context);
}

}
3 changes: 1 addition & 2 deletions ext/java/nokogiri/internals/XmlDomParserContext.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* (The MIT License)
*
* Copyright (c) 2008 - 2011:
* Copyright (c) 2008 - 2012:
*
* * {Aaron Patterson}[http://tenderlovemaking.com]
* * {Mike Dalessio}[http://mike.daless.io]
Expand Down Expand Up @@ -33,7 +33,6 @@
package nokogiri.internals;

import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
import static nokogiri.internals.NokogiriHelpers.rubyStringToString;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
Expand Down

0 comments on commit dee01c0

Please sign in to comment.