[ https://issues.apache.org/jira/browse/JENA-1941?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andy Seaborne resolved JENA-1941. --------------------------------- Fix Version/s: Jena 3.17.0 Resolution: Fixed > Parsed query cannot get serialized > ---------------------------------- > > Key: JENA-1941 > URL: https://issues.apache.org/jira/browse/JENA-1941 > Project: Apache Jena > Issue Type: Bug > Components: ARQ, Jena > Affects Versions: Jena 3.16.0 > Environment: Oracle jdk-14.0.1 > Reporter: Michael Cochez > Assignee: Andy Seaborne > Priority: Minor > Labels: Serializer, parser > Fix For: Jena 3.17.0 > > Time Spent: 20m > Remaining Estimate: 0h > > The following query can be parsed, but cannot be serialized back: > {code:java} > import org.apache.jena.query.Query; > import org.apache.jena.query.QueryFactory; > public class MinimalTest { > public static void main(String[] args) { > String queryString = "SELECT ?a WHERE { <%s> <http://ex.com> > <http://ex.com> }"; > Query q = QueryFactory.create(queryString); > String serialized = q.serialize(); > System.out.println(serialized); > } > } > {code} > {noformat} > Exception in thread "main" java.lang.StringIndexOutOfBoundsException: begin > 0, end 51, length 50 > at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3756) > at java.base/java.lang.String.substring(String.java:1902) > at > org.apache.jena.shared.impl.PrefixMappingImpl.qnameFor(PrefixMappingImpl.java:235) > at org.apache.jena.sparql.util.FmtUtils.prefixFor(FmtUtils.java:494) > at org.apache.jena.sparql.util.FmtUtils.stringForURI(FmtUtils.java:448) > at org.apache.jena.sparql.util.FmtUtils.stringForURI(FmtUtils.java:431) > at org.apache.jena.sparql.util.FmtUtils.stringForNode(FmtUtils.java:374) > at org.apache.jena.sparql.util.FmtUtils.stringForNode(FmtUtils.java:348) > at > org.apache.jena.sparql.serializer.FormatterBase.slotToString(FormatterBase.java:57) > at > org.apache.jena.sparql.serializer.FormatterElement.setWidths(FormatterElement.java:615) > at > org.apache.jena.sparql.serializer.FormatterElement.formatTriples(FormatterElement.java:503) > at > org.apache.jena.sparql.serializer.FormatterElement.flush(FormatterElement.java:558) > at > org.apache.jena.sparql.serializer.FormatterElement.visit(FormatterElement.java:165) > at > org.apache.jena.sparql.syntax.ElementPathBlock.visit(ElementPathBlock.java:94) > at > org.apache.jena.sparql.serializer.FormatterElement.visit(FormatterElement.java:321) > at > org.apache.jena.sparql.syntax.ElementGroup.visit(ElementGroup.java:120) > at > org.apache.jena.sparql.serializer.FormatterElement.visitAsGroup(FormatterElement.java:453) > at > org.apache.jena.sparql.serializer.QuerySerializer.visitQueryPattern(QuerySerializer.java:207) > at org.apache.jena.query.Query.visit(Query.java:770) > at org.apache.jena.query.Query.serialize(Query.java:928) > at org.apache.jena.query.Query.serialize(Query.java:905) > at org.apache.jena.query.Query.serialize(Query.java:895) > at org.apache.jena.query.Query.serialize(Query.java:856) > at MinimalTest.main(MinimalTest.java:10) > {noformat} > I am not entirely sure whether it is > # The query which is invalid, in which case there is a bug in the parser > # The serialization which should not fail, in which case the serializer has a > bug. -- This message was sent by Atlassian Jira (v8.3.4#803005)