[ 
https://issues.apache.org/jira/browse/JENA-2303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17502572#comment-17502572
 ] 

Claus Stadler edited comment on JENA-2303 at 3/7/22, 9:38 PM:
--------------------------------------------------------------

* Resource Leak / Redundant Code:
{code:java}
QueryExec queryExec = get().query(query);
return adapt(get().query(query));
{code}
The first line should be removed as it is redundant: You probably meant to 
write "return adapt(queryExec)" but then inlined the first line into the second.
Because QueryExec extends AutoClosable it means that the first line creates an 
object that can never be explicitly closed again which in the worst case may 
leak resources. 


* For RDFLinkModular: I want to be able to write wrappers that avoid needless 
wrapping - similar to e.g. 'QueryExecAdapter.adapt'.
However, RDFLinkModular does not provide public access to the 'modular' links 
so the following is not yet possible:
{code:java}
public static RDFLink applyQueryTransoform(link, Function<Query, Query> tform) {
  if (link instanceof RDFLinkModular) {
    RDFLinkModular l = (RDFLinkModular)link;
    return new RDFLinkModular(wrapWithTransform(l.queryLink(), tform), 
l.updateLink(), l.datasetLink()));
  }
  ...
}
{code}




was (Author: aklakan):
* Resource Leak / Redundant Code:
{code:java}
QueryExec queryExec = get().query(query);
return adapt(get().query(query));
{code}
The first line should be removed as it is redundant: You probably meant to 
write "return adapt(queryExec)" but then inlined the first line into the second.
Because QueryExec extends AutoClosable it means that the first line creates an 
object that can never be explicitly closed again which in the worst case may 
leak resources. 


* For RDFLinkModular: I want to be able to write wrappers that avoid needless 
wrapping - similar to e.g. 'QueryExecAdapter.adapt'.
However, RDFLinkModular does not provide public access to the 'modular' links 
so the following is not yet possible:

{code:java}
public static RDFLink applyQueryTransoform(link, Function<Query, Query> tform) {
  if (link instanceof RDFLinkModular) {
    RDFLinkModular l = (RDFLinkModular)link;
    return new RDFLinkModular(tform.apply(l.queryLink()), l.updateLink(), 
l.datasetLink()));
  }
  ...
}
{code}



> Resource leak in RDFConnectionAdapter
> -------------------------------------
>
>                 Key: JENA-2303
>                 URL: https://issues.apache.org/jira/browse/JENA-2303
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: ARQ
>    Affects Versions: Jena 4.5.0
>            Reporter: Claus Stadler
>            Priority: Minor
>
> * There is a resource leak in RDFConnectionAdapter:
> {code:java}
> public class RDFConnectionAdapter implements RDFConnection {
>     @Override
>     public QueryExecution query(Query query) {
>         QueryExec queryExec = get().query(query); // This line leaks resources
>         return adapt(get().query(query));
>     }
> }
> {code}
> * Also, please make access to the underlying links in RDFLinkModular public 
> in order to reduce the amount of re-wrapping needed when e.g. only only 
> wrapping the LinkSparqlQuery with custom query rewriting.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to