You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by "afs (via GitHub)" <gi...@apache.org> on 2024/10/08 15:42:14 UTC
Re: [PR] GH-2755: Protect action cleanup [jena]
afs commented on code in PR #2760:
URL: https://github.com/apache/jena/pull/2760#discussion_r1792117033
##########
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java:
##########
@@ -329,23 +329,31 @@ public void begin(TxnType txnType) {
finishActionTxn();
if ( dataService != null )
dataService.finishTxn();
- if ( transactional != null && transactional.isInTransaction() ) {
- switch(transactional.transactionMode() ) {
- case READ -> {}
- case WRITE -> {
- // Write transactions must have explicitly called commit or abort.
- FmtLog.warn(log, "[%d] Transaction still active - no commit or abort seen (forced abort)", this.id);
- try {
- transactional.abort();
- } catch (RuntimeException ex) {
- FmtLog.warn(log, "[%d] Exception in forced abort (trying to continue)", this.id, ex);
- }
+ if ( transactional != null && transactional.isInTransaction() )
+ forceAbort();
+ leaveActionTxn();
+ }
+
+ /** Force an abort - i.e. abort with protection against anything going wrong. */
+ private void forceAbort() {
+ ReadWrite rwMode = transactional.transactionMode();
+ if ( rwMode == null )
+ // Damaged system.
+ return;
+ switch(rwMode) {
+ case READ -> {}
+ case WRITE -> {
+ // Write transactions must have explicitly called commit or abort.
+ FmtLog.warn(log, "[%d] Transaction still active - no commit or abort seen (forced abort)", this.id);
+ try {
+ transactional.abort();
+ } catch (RuntimeException ex) {
+ FmtLog.warn(log, "[%d] Exception in forced abort (trying to continue)", this.id, ex);
Review Comment:
Not the one from #2755 - the except is `Cannot invoke "org.apache.jena.query.ReadWrite.ordinal()`
which is a null value of `transactional.transactionMode()` in`finishActionTxn()`.
```
switch(transactional.transactionMode() )
```
and that says very little.
The `transactional.abort` exception may have some information (unlikely but possible) and would be hidden by the `switch` NPE.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org