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

org.swordapp.client.ErrorHandler #2

Open
MistretzulPrietenos opened this issue Mar 10, 2015 · 0 comments
Open

org.swordapp.client.ErrorHandler #2

MistretzulPrietenos opened this issue Mar 10, 2015 · 0 comments

Comments

@MistretzulPrietenos
Copy link

Hi Richard,
I think there is a problem in the org.swordapp.client.ErrorHandler.java class

// try to parse the string as XML
Builder parser = new Builder();
try{
     Document doc = parser.build(errorBody);
     ...
}

The parser.build instruction will always throw an IOException. The method expects an URL but not an XML file :

Document nu.xom.Builder.build(String systemID) throws ParsingException, ValidityException, IOException

Parses the document at the specified URL.

Note that relative URLs generally do not work here, as there's no base to resolve them against. This includes relative URLs that point into the file system, though this is somewhat platform dependent. Furthermore, file URLs often only work when they adhere exactly to RFC 2396 syntax. URLs that work in Internet Explorer often fail when used in Java. If you're reading XML from a file, more reliable results are obtained by using the build method that takes a java.io.File object as an argument.

Parameters:
systemID an absolute URL from which the document is read. The URL's scheme must be one supported by the Java VM.
Returns:
the parsed Document
Throws:
ValidityException - if a validity error is detected. This is only thrown if the builder has been instructed to validate.
ParsingException - if a well-formedness error is detected
IOException - if an I/O error such as a broken socket prevents the document from being fully read

An easy fix would be

     Document doc = parser.build(IOUtils.toInputStream(errorBody));
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

No branches or pull requests

1 participant