Commit 0446ae5
* fix: abort leaked request Context in StatelessAuthenticationFilter (backport dc57ffd / #852)
Backport the behavioral fix from dc57ffd ("Transaction bug - close
context in finally block", PR #852) which is on dtq-dev/customer/lindat
but missing from customer/zcu-data.
On the request error path a slow submission upload could leave its
Hibernate session bound to the Tomcat thread with a dirty, stale Item:
the upload throws before reaching context.commit(), and
DSpaceRequestContextFilter assigns its `context` local only AFTER
chain.doFilter, so on an exception the local stays null and its finally
skips the abort -> the session leaks. A later request on that thread then
flushes the stale Item as a full-row UPDATE (Item has no
@DynamicUpdate/@Version), reverting owning_collection->NULL and
in_archive->false while collection2item + handle survive -> the item
becomes an unsearchable orphan (e.g. handle 20.500.14592/107).
Wrap chain.doFilter in the outer StatelessAuthenticationFilter with a
try/finally that reads the Context from the request attribute and
abort()s it if still valid, cleaning up the leaked context the inner
filter missed. No-op on the normal success path.
Only the StatelessAuthenticationFilter hunk is ported; the diagnostic/CI
files in dc57ffd are omitted (they conflict and are not needed).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit ea6116e)
* docs: clarify Context-abort comment and link #1353 (Copilot review)
---------
Co-authored-by: milanmajchrak <milan.majchrak@dataquest.sk>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent ccdbf8f commit 0446ae5
1 file changed
Lines changed: 17 additions & 1 deletion
File tree
- dspace-server-webapp/src/main/java/org/dspace/app/rest/security
dspace-server-webapp/src/main/java/org/dspace/app/rest/security/StatelessAuthenticationFilter.java
Lines changed: 17 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
103 | 119 | | |
104 | 120 | | |
105 | 121 | | |
| |||
0 commit comments