Skip to content

Fix resulting buffer from BufferProxy's out method being ignored. #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

LambdAurora
Copy link

This pull request aims to fix some cases in LMDBJava where the BufferProxy's out method resulting buffer is ignored, especially in Dbi.

I've discovered this issue while attempting to write a new implementation of BufferProxy to use Java 22's Function Foreign Memory API in preparation of Java 25's removal of various methods in Unsafe invalidating most fast BufferProxy implementations. The implementation failed to pass some tests since in the out method I returned a new ByteBuffer (taking advantage of MemorySegment.ofAddress().asByteBuffer()).

After further investigation, I've found that ByteArrayProxy also relies on returning a different "buffer" from the one that's given as an argument, for which I've added new tests that reproduce the behavior of DbiTest.customComparator and DbiTest.dbiWithComparatorThreadSafety using byte arrays instead. ByteArrayProxy led me to think that returning a different buffer in out is an allowed and intended behavior.

This fix is important for users of ByteArrayProxy and allows for a stop-gap external implementation of BufferProxy using the FFM API to allow users to upgrade to Java 25 when the time comes until a proper resolution to #42 comes around.

TODO: address failing dbiWithComparatorThreadSafetyByteArray test.
This proves to be more reliable than Agreno's UnsafeBuffers.
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.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy