mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8330748: ByteArrayOutputStream.writeTo(OutputStream) pins carrier
Reviewed-by: alanb
This commit is contained in:
parent
eb88343fb7
commit
819f3d6fc7
2 changed files with 142 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -159,8 +159,16 @@ public class ByteArrayOutputStream extends OutputStream {
|
|||
* @throws NullPointerException if {@code out} is {@code null}.
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*/
|
||||
public synchronized void writeTo(OutputStream out) throws IOException {
|
||||
out.write(buf, 0, count);
|
||||
public void writeTo(OutputStream out) throws IOException {
|
||||
if (Thread.currentThread().isVirtual()) {
|
||||
byte[] bytes;
|
||||
synchronized (this) {
|
||||
bytes = Arrays.copyOf(buf, count);
|
||||
}
|
||||
out.write(bytes);
|
||||
} else synchronized (this) {
|
||||
out.write(buf, 0, count);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue