Repository navigation
fix(tmp): try make clipboard patterns safe for Filter - #3622
Timongcraft wants to merge 7 commits into
Conversation
hm... |
-> currently "wrongly" marked true in ConcurrentReadClipboard although it only wraps block reads
this ensures that a pattern using the same clipboard multiple times is synced as well chore: mark Clipboard#supportsParallelAccess as experimental it is currently only needed for the temporary wrapper & I'm not sure if I thought this through correctly
There was a problem hiding this comment.
🟡 Changes recommended
World-backed clipboards bypass synchronization even when their arbitrary backing extent is not concurrency-safe.
1 open finding
What changed in this PR
Adds synchronized clipboard reads to prevent corruption during parallel ClipboardPattern filtering.
Changes:
- Introduces a synchronized read wrapper.
- Adds parallel-access capability detection.
- Exempts selected clipboard implementations from wrapping.
| File | Description |
|---|---|
ClipboardPattern.java |
Wraps clipboard reads for concurrency safety. |
Clipboard.java |
Adds the parallel-access capability API. |
BlockArrayClipboard.java |
Delegates capability to its parent. |
WorldCopyClipboard.java |
Declares parallel-read support. |
EmptyClipboard.java |
Declares parallel-read support. |
DiskOptimizedClipboard.java |
Declares parallel-read support. |
ConcurrentReadClipboard.java |
Implements synchronized block reads. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
was naive and moving up #supportsParallelAccess prob. won't help because of EditSession
| @ApiStatus.Experimental // Temporary wrapper | ||
| public class ConcurrentReadClipboard implements Clipboard { |
There was a problem hiding this comment.
| @ApiStatus.Experimental // Temporary wrapper | |
| public class ConcurrentReadClipboard implements Clipboard { | |
| public class ConcurrentReadOnlyClipboard implements Clipboard { |
I think there's no need for the experimental label here - it's likely to need to stay. Also worth stating readonly explicitly
There was a problem hiding this comment.
Should Clipboard#supportsParallelAccess also not be marked experimental?
|
Would it make sense to use a marker interface like That would allow a more or less clean method directly on the Clipboard like I don't really like the name personally - "parallel access" kind of implies parallel / multi-threaded writing access as well - but I don't have any better one right now. All just nitpicks. |
chore: more appropriate wrapper class name
|
If that is desired that could also be done, sure. |

Overview
Fix corruption when using ClipboardPattern and disabling on disk clipboards as some implementations have an unsafe cache.
This does not fix RandomFullClipboardPattern, which also seems affected but I'm not sure how to wrap the clipboard properly as it uses the old single get clipboard (seemingly on purpose) but idk if or how that should be wrapped as we'd need a map or list, no?
Description
Add a temporary wrapper to sync block access in clipboards for ClipboardPattern.
Submitter Checklist
- [ ] New public fields and methods are annotated with@since TODO.