GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — servlet: Check log fine level before hex string conversion. Fixes #11… · grpc/grpc-java@f7ee5f3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • servlet/src/main/java/io/grpc/servlet
    • AsyncServletOutputStreamWriter.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎servlet/src/main/java/io/grpc/servlet/AsyncServletOutputStreamWriter.java‎

Copy file name to clipboardExpand all lines: servlet/src/main/java/io/grpc/servlet/AsyncServletOutputStreamWriter.java
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.concurrent.locks.LockSupport;
3333
import java.util.function.BiFunction;
3434
import java.util.function.BooleanSupplier;
35+
import java.util.logging.Level;
3536
import java.util.logging.Logger;
3637
import javax.annotation.CheckReturnValue;
3738
import 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

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.