[jboss-jira] [JBoss JIRA] (DROOLS-1444) KieSession to implement java.lang.AutoCloseable

tech meshter (JIRA) issues at jboss.org
Fri Feb 17 13:19:00 EST 2017


    [ https://issues.jboss.org/browse/DROOLS-1444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13365675#comment-13365675 ] 

tech meshter commented on DROOLS-1444:
--------------------------------------

I attached an artificial example using java.io.StringWriter (which is Autcloseable) ( [^AutocloseableSample.java] ).
In one method (desiredState) I take advantage of autocloseable feature and the syntax is pretty compact.
In another class, the autocloseable is not being used and I end up not even being able to compile the code.

Of course, the example is again artificial, just to make the point.

My actual scenario is that:
- I use drools in a Java 8 multi-user (it is a webapp) scenario
- I create one KieSession every time an user invokes that specific scenario and I want to release the resources by calling the "dispose" method.
- Inserting the objects in the KieSession using lambdas is pretty elegant (at least in my case).

Generally, the drools documentation emphasizes the need for the developer to call the "dispose" method once he is done with the KieSession (assuming he created it using a new* method on the KieBase). I see this no different that invoking close on input streams or database result sets...

Now, the AutoCloseable has been introduced in Java 7. If the intention is to keep the binaries compatible with 1.6 or below, then please forget about all this...

> KieSession to implement java.lang.AutoCloseable
> -----------------------------------------------
>
>                 Key: DROOLS-1444
>                 URL: https://issues.jboss.org/browse/DROOLS-1444
>             Project: Drools
>          Issue Type: Enhancement
>          Components: core engine
>    Affects Versions: 6.5.0.Final
>            Reporter: tech meshter
>            Assignee: Mario Fusco
>            Priority: Minor
>         Attachments: AutocloseableSample.java
>
>
> Given the new Java 7 and 8 syntax features, it would be useful that KieSession (and maybe some other APIs that involve "disposability") to implement java.lang.AutoCloseable. The implementation can call directly the "dispose" method (unless I miss something) and over time dispose might become deprecated.



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list