Add 4-arg map override to FilterFileChannel#15801
Add 4-arg map override to FilterFileChannel#15801mayya-sharipova merged 1 commit intoapache:mainfrom
Conversation
Java 22 added FileChannel.map(MapMode, long, long, Arena) which returns MemorySegment. The base FileChannel class provides a default implementation that throws UnsupportedOperationException. Without this override, any wrapped FileChannel based on FilterFileChannel would fail when the 4-arg map variant is called.
|
@ldematte would appreciate your review here |
ldematte
left a comment
There was a problem hiding this comment.
The change looks good, it's the missing overload. However I'm not sure about one thing: this API is JDK 22+, and AFAIK lucene supports JDK 21. This could fail to compile (or at least give you warnings) with target 21, but most importantly it will fail at runtime if we run this with JDK 21. Again, not sure if this is an issue or not, especially since this is test code, but I wanted to point it out.
Not on main, no. Main is jdk25+. |
Oh nice! So I don't see any issue with this change. |
Yep, this just cannot be backported to 10x. |
|
Hi, lucene/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java Lines 325 to 326 in f7b35cb This is no longer needed because the test-wrappers now behave correctly. |
|
Oh this was already resolved, can you do the change on main branch or should I? |
…S providers without MemorySegmentSupport
|
Here is the PR: #15804 Will merge when tests are done. |
…iders without MemorySegment support (#15804)
|
Done. |
|
Basically this was my fault as I did not remove the MMapDirectory unwrapping after update to Java 22+ on main (see #14564, especially https://github.com/apache/lucene/pull/14564/changes#diff-8681a7b2259f78a6d0d2efe4894ef79ce4697c3825d24675248bc557617773ceL58). If I would have removed it I would have noticed the missing override anyways. Note to myself: "When migrating code to later java versions check your TODOs and workarounds in source code!" |
Java 22 added FileChannel.map(MapMode, long, long, Arena) which
returns MemorySegment. The base FileChannel class provides a default
implementation that throws UnsupportedOperationException. Without
this override, any wrapped FileChannel based on FilterFileChannel
would fail when the 4-arg map variant is called.