Skip to content

Commit 684db43

Browse files
committed
RAF.write(int) should only use blocker when in virtual thread
1 parent 3c47b03 commit 684db43

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/java.base/share/classes/java/io/RandomAccessFile.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,11 @@ public int skipBytes(int n) throws IOException {
534534
* @throws IOException if an I/O error occurs.
535535
*/
536536
public void write(int b) throws IOException {
537-
Blocker.managedBlock(() -> write0(b));
537+
if (Thread.currentThread().isVirtual()) {
538+
Blocker.managedBlock(() -> write0(b));
539+
} else {
540+
write0(b);
541+
}
538542
}
539543

540544
private native void write0(int b) throws IOException;

0 commit comments

Comments
 (0)