Skip to content

fix(tmp): try make clipboard patterns safe for Filter - #3622

Open
Timongcraft wants to merge 7 commits into
IntellectualSites:mainfrom
Timongcraft:fix/sync-clip-wrapper
Open

Timongcraft wants to merge 7 commits into
IntellectualSites:mainfrom
Timongcraft:fix/sync-clip-wrapper

Conversation

@Timongcraft

Copy link
Copy Markdown
Contributor

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

  • Make sure you are opening from a topic branch (/feature/fix/docs/ branch (right side)) and not your main branch.
  • Ensure that the pull request title represents the desired changelog entry.
    - [ ] New public fields and methods are annotated with @since TODO.
  • I read and followed the contribution guidelines.

@Timongcraft

Timongcraft commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Caused by: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find yarn-1.21.1+build.3-mergedv2.jar (net.fabricmc:yarn:1.21.1+build.3).

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
@Timongcraft
Timongcraft marked this pull request as ready for review October 3, 2026 14:25
@Timongcraft
Timongcraft requested a review from a team as a code owner October 3, 2026 14:25
@NotMyFault
NotMyFault requested review from dordsor21 and a balanced review from Copilot October 12, 2026 17:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Timongcraft and others added 2 commits October 14, 2026 18:04
was naive and moving up #supportsParallelAccess prob. won't help because of EditSession
Comment on lines +19 to +20
@ApiStatus.Experimental // Temporary wrapper
public class ConcurrentReadClipboard implements Clipboard {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should Clipboard#supportsParallelAccess also not be marked experimental?

@PierreSchwang

Copy link
Copy Markdown
Member

Would it make sense to use a marker interface like public interface ParallelAccessClipboard extends Clipboard and a SynchronizedAccessClipboard as the implementation for wrapping non-parallel access clipboards?

That would allow a more or less clean method directly on the Clipboard like forParallelAccess() or something (not that it depends on the implementation details). Not sure if that's really required as of now tbf.

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.

@Timongcraft

Copy link
Copy Markdown
Contributor Author

If that is desired that could also be done, sure.
Is your intention to give third party implementions more abilities for wrapping?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants