Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove java.util.logging from AsyncServletOutputStreamWriter.Log #11644

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.concurrent.locks.LockSupport;
import java.util.function.BiFunction;
import java.util.function.BooleanSupplier;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -88,8 +87,8 @@ final class AsyncServletOutputStreamWriter {
Logger logger = Logger.getLogger(AsyncServletOutputStreamWriter.class.getName());
this.log = new Log() {
@Override
public boolean isLoggable(Level level) {
return logger.isLoggable(level);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the point was to not run this line. There can be synchronization involved here, and that could maybe mess up lincheck. So it wasn't about avoiding the loading of the dependency (that actually happens anyway, even with this change), it ways about not calling into its infrastructure.

Not that I have any more background on this than you do, but I do think it is a plausible story.

Maybe we should change the comment to say "not call java.util.logging.Logger"?

public boolean isFinestLoggable() {
return logger.isLoggable(FINEST);
}

@Override
Expand All @@ -111,7 +110,7 @@ public void finest(String str, Object... params) {
this.writeAction = (byte[] bytes, Integer numBytes) -> () -> {
outputStream.write(bytes, 0, numBytes);
transportState.runOnTransportThread(() -> transportState.onSentBytes(numBytes));
if (log.isLoggable(Level.FINEST)) {
if (log.isFinestLoggable()) {
log.finest("outbound data: length={0}, bytes={1}", numBytes, toHexString(bytes, numBytes));
}
};
Expand Down Expand Up @@ -253,7 +252,7 @@ interface ActionItem {

@VisibleForTesting // Lincheck test can not run with java.util.logging dependency.
interface Log {
default boolean isLoggable(Level level) {
default boolean isFinestLoggable() {
return false;
}

Expand Down