3232import java .util .concurrent .locks .LockSupport ;
3333import java .util .function .BiFunction ;
3434import java .util .function .BooleanSupplier ;
35+ import java .util .logging .Level ;
3536import java .util .logging .Logger ;
3637import javax .annotation .CheckReturnValue ;
3738import javax .annotation .Nullable ;
@@ -86,6 +87,11 @@ final class AsyncServletOutputStreamWriter {
8687 InternalLogId logId ) throws IOException {
8788 Logger logger = Logger .getLogger (AsyncServletOutputStreamWriter .class .getName ());
8889 this .log = new Log () {
90+ @ Override
91+ public boolean isLoggable (Level level ) {
92+ return logger .isLoggable (level );
93+ }
94+
8995 @ Override
9096 public void fine (String str , Object ... params ) {
9197 if (logger .isLoggable (FINE )) {
@@ -105,7 +111,9 @@ public void finest(String str, Object... params) {
105111 this .writeAction = (byte [] bytes , Integer numBytes ) -> () -> {
106112 outputStream .write (bytes , 0 , numBytes );
107113 transportState .runOnTransportThread (() -> transportState .onSentBytes (numBytes ));
108- log .finest ("outbound data: length={0}, bytes={1}" , numBytes , toHexString (bytes , numBytes ));
114+ if (log .isLoggable (Level .FINEST )) {
115+ log .finest ("outbound data: length={0}, bytes={1}" , numBytes , toHexString (bytes , numBytes ));
116+ }
109117 };
110118 this .flushAction = () -> {
111119 log .finest ("flushBuffer" );
@@ -245,6 +253,10 @@ interface ActionItem {
245253
246254 @ VisibleForTesting // Lincheck test can not run with java.util.logging dependency.
247255 interface Log {
256+ default boolean isLoggable (Level level ) {
257+ return false ;
258+ }
259+
248260 default void fine (String str , Object ...params ) {}
249261
250262 default void finest (String str , Object ...params ) {}
0 commit comments