APISonar


jdk.internal.net.http.common.Logger.log

> jdk > internal > net > http > common > Logger > log
jdk APIs internal APIs net APIs http APIs common APIs Logger APIs log APIs

Example 1
final Logger debug;

    private void connectFlows() {
        if (debug.on()) debug.log("connectFlows");
        tube.connectFlows(writePublisher, readSubscriber);
    }
Example 2
final Logger debug;

    public void close() {
        if (closed.compareAndSet(false, true)) {
            if (debug.on()) debug.log("close");
            connection.client().webSocketClose();
            connection.close();
        }
    }
Example 3
private static final Logger debug =
            Utils.getWebSocketLogger("[WebSocket]"::toString, Utils.DEBUG_WS);

    private void processCloseError(Throwable e) {
        if (e == null) {
            debug.log("send close completed successfully");
        } else {
            debug.log("send close completed with error", e);
        }
        outputClosed.set(true);
        try {
            transport.closeOutput();
        } catch (IOException ignored) { }
    }
Example 4
private static final Logger debug =
            Utils.getWebSocketLogger("[Transport]"::toString, Utils.DEBUG_WS);

    private boolean write() throws IOException {
        if (debug.on()) {
            debug.log("writing to the channel");
        }
        long count = channel.write(dstArray, 0, dstArray.length);
        if (debug.on()) {
            debug.log("%s bytes written", count);
        }
        for (ByteBuffer b : dstArray) {
            if (b.hasRemaining()) {
                return false;
            }
        }
        return true;
    }
Example 5
final Logger debug;

    public void shutdownOutput() {
        if (outputClosed.compareAndSet(false, true)) {
            if (debug.on()) debug.log("shutdownOutput");
            // TransportImpl will eventually call RawChannel::close.
            // We must not call it here as this would close the socket
            // and can cause an exception to back fire before
            // TransportImpl and WebSocketImpl have updated their state.
        }
    }
Example 6
private static final Logger debug =
            Utils.getWebSocketLogger("[WebSocket]"::toString, Utils.DEBUG_WS);

    private void signalError(Throwable error) {
        if (debug.on()) {
            debug.log("signalError %s", (Object) error);
        }
        inputClosed = true;
        outputClosed.set(true);
        if (!this.error.compareAndSet(null, error) || !trySetState(ERROR)) {
            if (debug.on()) {
                debug.log("signalError", error);
            }
            Log.logError(error);
        } else {
            close();
        }
    }
Example 7
private static final Logger debug =
            Utils.getWebSocketLogger("[WebSocket]"::toString, Utils.DEBUG_WS);

    private void sendCloseSilently(int statusCode) {
        sendClose0(statusCode, "").whenComplete((r, e) -> {
            if (e != null) {
                if (debug.on()) {
                    debug.log("automatic closure completed with error",
                              (Object) e);
                }
            }
        });
    }
Example 8
private static final Logger debug =
            Utils.getWebSocketLogger("[Transport]"::toString, Utils.DEBUG_WS);

    private ByteBuffer createWriteBuffer() {
        String name = "jdk.httpclient.websocket.writeBufferSize";
        int capacity = Utils.getIntegerNetProperty(name, 16384);
        if (debug.on()) {
            debug.log("write buffer capacity %s", capacity);
        }

        // TODO (optimization?): allocateDirect if SSL?
        return ByteBuffer.allocate(capacity);
    }
Example 9
private static final Logger debug =
            Utils.getWebSocketLogger("[WebSocket]"::toString, Utils.DEBUG_WS);

    public void abort() {
        if (debug.on()) {
            debug.log("abort");
        }
        inputClosed = true;
        outputClosed.set(true);
        receiveScheduler.stop();
        close();
    }
Example 10
static final Logger debug =
            Utils.getDebugLogger("FramesDecoder"::toString, Utils.DEBUG);

    public void close(String msg) {
        closed = true;
        tailBuffers.clear();
        int bytes = tailSize;
        ByteBuffer b = currentBuffer;
        if (b != null) {
            bytes += b.remaining();
            b.position(b.limit());
        }
        tailSize = 0;
        currentBuffer = null;
        if (debug.on()) debug.log("closed %s, ignoring %d bytes", msg, bytes);
    }
Example 11
final Logger debug = Utils.getDebugLogger(this::dbgString, Utils.DEBUG);

    void cleanup(HttpConnection c, Throwable error) {
        if (debug.on())
            debug.log("%s : ConnectionPool.cleanup(%s)",
                    String.valueOf(c.getConnectionFlow()), error);
        synchronized(this) {
            removeFromPool(c);
            expiryList.remove(c);
        }
        c.close();
    }
Example 12
private final Logger debugHpack =
            Utils.getHpackLogger(this::dbgString, Utils.DEBUG_HPACK);

    private void decodeHeaders(HeaderFrame frame, DecodingCallback decoder)
            throws IOException
    {
        if (debugHpack.on()) debugHpack.log("decodeHeaders(%s)", decoder);

        boolean endOfHeaders = frame.getFlag(HeaderFrame.END_HEADERS);

        List<ByteBuffer> buffers = frame.getHeaderBlock();
        int len = buffers.size();
        for (int i = 0; i < len; i++) {
            ByteBuffer b = buffers.get(i);
            hpackIn.decode(b, endOfHeaders && (i == len - 1), decoder);
        }
    }
Example 13
final Logger debugelapsed = Utils.getDebugLogger(this::dbgString, DEBUGELAPSED);

    private void debugCompleted(String tag, long startNanos, HttpRequest req) {
        if (debugelapsed.on()) {
            debugelapsed.log(tag + " elapsed "
                    + (System.nanoTime() - startNanos)/1000_000L
                    + " millis for " + req.method()
                    + " to " + req.uri());
        }
    }
Example 14
final Logger debug = Utils.getDebugLogger(this::dbgString, Utils.DEBUG);

    void stop() {
        if (debug.on()) debug.log("stopping");
        if (Log.channel() && !scheduler.isStopped()) {
            Log.logChannel("HTTP/1 read subscriber stopped for {0}", describe());
        }
        scheduler.stop();
        // make sure ref count is handled properly by
        // closing the delegate.
        Http1AsyncDelegate previous = delegate;
        if (previous != null) previous.close(error);
        delegate = null;
        owner  = null;
        whenFinished.complete(null);
    }
Example 15
final static Logger debug =
            Utils.getDebugLogger("Http2ClientImpl"::toString, Utils.DEBUG);

    void stop() {
        if (debug.on()) debug.log("stopping");
        connections.values().forEach(this::close);
        connections.clear();
    }
Example 16
private static final Logger debug =
            Utils.getWebSocketLogger("[Input]"::toString, Utils.DEBUG_WS);

    public void rsv1(boolean value) {
        if (debug.on()) {
            debug.log("rsv1 %s", value);
        }
        if (value) {
            throw new FailWebSocketException("Unexpected rsv1 bit");
        }
    }
Example 17
final Logger debug = Utils.getDebugLogger(this::dbgString, Utils.DEBUG);

    private CompletableFuture<Response> sendRequestBody(ExchangeImpl<T> ex) {
        assert !request.expectContinue();
        if (debug.on()) debug.log("sendRequestBody");
        CompletableFuture<Response> cf = ex.sendBodyAsync()
                .thenCompose(exIm -> exIm.getResponseAsync(parentExecutor));
        cf = wrapForUpgrade(cf);
        cf = wrapForLog(cf);
        return cf;
    }
Example 18
final static Logger debug =
            Utils.getDebugLogger("Http2ClientImpl"::toString, Utils.DEBUG);

    void deleteConnection(Http2Connection c) {
        if (debug.on())
            debug.log("removing from the connection pool: %s", c);
        synchronized (this) {
            Http2Connection c1 = connections.get(c.key());
            if (c1 != null && c1.equals(c)) {
                connections.remove(c.key());
                if (debug.on())
                    debug.log("removed from the connection pool: %s", c);
            }
        }
    }
Example 19
final Logger debug =
            Utils.getDebugLogger(this::dbgString, Utils.DEBUG);

    void update(int delta) {
        if (debug.on()) debug.log("update: %d", delta);
        if (received.addAndGet(delta) > limit) {
            synchronized (this) {
                int tosend = received.get();
                if( tosend > limit) {
                    received.getAndAdd(-tosend);
                    sendWindowUpdate(tosend);
                }
            }
        }
    }
Example 20
final Logger debug = Utils.getDebugLogger(this::dbgString, Utils.DEBUG);

    private void asyncReceive(ByteBuffer buf) {
        if (debug.on())
            debug.log("Putting %s bytes into the queue", buf.remaining());
        received.addAndGet(buf.remaining());
        queue.offer(buf);

        // This callback is called from within the selector thread.
        // Use an executor here to avoid doing the heavy lifting in the
        // selector.
        scheduler.runOrSchedule(executor);
    }
Example 21
final Logger debug = Utils.getDebugLogger(this::dbgString, Utils.DEBUG);

    void clear() {
        if (debug.on()) debug.log("cleared");
        this.pendingDelegateRef.set(null);
        this.delegate = null;
        this.owner = null;
    }
Example 22
private static final Logger debug =
            Utils.getWebSocketLogger("[Output]"::toString, Utils.DEBUG_WS);

    private void setupHeader(Opcode opcode, boolean fin, long payloadLen) {
        if (debug.on()) {
            debug.log("frame opcode=%s fin=%s len=%s",
                      opcode, fin, payloadLen);
        }
        headerBuffer.clear();
        int mask = maskingKeySource.nextInt();
        headerWriter.fin(fin)
                    .opcode(opcode)
                    .payloadLen(payloadLen)
                    .mask(mask)
                    .write(headerBuffer);
        headerBuffer.flip();
        payloadMasker.mask(mask);
    }
Example 23
final Logger debug =
            Utils.getDebugLogger(this::dbgString, Utils.DEBUG);

    void sendWindowUpdate(int delta) {
        if (debug.on()) debug.log("sending window update: %d", delta);
        connection.sendUnorderedFrame(new WindowUpdateFrame(getStreamId(), delta));
    }
Example 24
final Logger debug = Utils.getDebugLogger(this::dbgString, Utils.DEBUG);

    private void appendToOutgoing(DataPair dp) {
        if (debug.on()) debug.log("appending to outgoing " + dp);
        outgoing.add(dp);
        writePublisher.writeScheduler.runOrSchedule();
    }
Example 25
final Logger debug = Utils.getDebugLogger(this::dbgString, Utils.DEBUG);

    private void onFinished() {
        asyncReceiver.clear();
        if (return2Cache) {
            Log.logTrace("Attempting to return connection to the pool: {0}", connection);
            // TODO: need to do something here?
            // connection.setAsyncCallbacks(null, null, null);

            // don't return the connection to the cache if EOF happened.
            if (debug.on())
                debug.log(connection.getConnectionFlow() + ": return to HTTP/1.1 pool");
            connection.closeOrReturnToCache(eof == null ? headers : null);
        }
    }