32
32
import java .util .concurrent .locks .LockSupport ;
33
33
import java .util .function .BiFunction ;
34
34
import java .util .function .BooleanSupplier ;
35
+ import java .util .logging .Level ;
35
36
import java .util .logging .Logger ;
36
37
import javax .annotation .CheckReturnValue ;
37
38
import javax .annotation .Nullable ;
@@ -86,6 +87,11 @@ final class AsyncServletOutputStreamWriter {
86
87
InternalLogId logId ) throws IOException {
87
88
Logger logger = Logger .getLogger (AsyncServletOutputStreamWriter .class .getName ());
88
89
this .log = new Log () {
90
+ @ Override
91
+ public boolean isLoggable (Level level ) {
92
+ return logger .isLoggable (level );
93
+ }
94
+
89
95
@ Override
90
96
public void fine (String str , Object ... params ) {
91
97
if (logger .isLoggable (FINE )) {
@@ -105,7 +111,9 @@ public void finest(String str, Object... params) {
105
111
this .writeAction = (byte [] bytes , Integer numBytes ) -> () -> {
106
112
outputStream .write (bytes , 0 , numBytes );
107
113
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
+ }
109
117
};
110
118
this .flushAction = () -> {
111
119
log .finest ("flushBuffer" );
@@ -245,6 +253,10 @@ interface ActionItem {
245
253
246
254
@ VisibleForTesting // Lincheck test can not run with java.util.logging dependency.
247
255
interface Log {
256
+ default boolean isLoggable (Level level ) {
257
+ return false ;
258
+ }
259
+
248
260
default void fine (String str , Object ...params ) {}
249
261
250
262
default void finest (String str , Object ...params ) {}
0 commit comments