Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [rdf4j-dev] bug #773

Hi Håvard,

I research on that bug #773 [2] and I update your test-case.My new test-case look like this [1].In my test-case [1] I set RDFHandler to the parser then test case pass successfully.When I remove setRDFHandler test-case failed because of following line.
 if (rdfHandler == null) {   rdfHandler.startRDF();}
The reason is rdfHandler have null reference and rdfHandler.startRDF() not assign handler to rdfHandler variable. So I think we should set rdfHandler same as I set in the test-case.I did it like this and it successfully pass test-case you wrote in previous commit.
private class RDFHandlerSC extends StatementCollector {

private boolean started = false;

private boolean ended = false;

@Override
public void startRDF()
throws RDFHandlerException
{
super.startRDF();
started = true;
}

@Override
public void endRDF()
throws RDFHandlerException
{
super.endRDF();
ended = true;
}

}

@Override
public void parse(final Reader reader, final String baseUri)
throws IOException, RDFParseException, RDFHandlerException
{
if (rdfHandler == null) {
rdfHandler = new RDFHandlerSC();
// rdfHandler.startRDF();
}
JsonParser jp = null;

try {
jp = RDFJSONUtility.JSON_FACTORY.createParser(reader);
rdfJsonToHandlerInternal(rdfHandler, valueFactory, jp);
}
catch (final IOException e) {
if (jp != null) {
reportFatalError("Found IOException during parsing", e, jp.getCurrentLocation());
}
else {
reportFatalError(e);
}
}
finally {
if (jp != null) {
try {
jp.close();
}
catch (final IOException e) {
reportFatalError("Found exception while closing JSON parser", e, jp.getCurrentLocation());
}
}
}
if (rdfHandler != null) {
rdfHandler.endRDF();
}
}
This parse method come from RDFParser interface and it is used in RDFJSONParser [5] and TurtleParser [4] classes.In TurtleParser class check rdfHandler like this. if (rdfHandler != null) {rdfHandler.startRDF();}.test-cases wrote to that method also working fine. RDFJSONParser and TurtleParser [4] both used same override method so I think make == to != also can fixed this bug.

from you previous experience can you please tell me which way do you choose from these two fixes.This is my first fix so i think you will help me.




Thank You!
regards,
Heshan







Back to the top