From c8ad6000646abd6e1faac396d901135c85c73cf5 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Wed, 25 Jan 2023 13:33:22 +0000 Subject: [PATCH] 8301004: httpclient: Add more debug to HttpResponseInputStream Reviewed-by: jpai --- .../internal/net/http/ResponseSubscribers.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/ResponseSubscribers.java b/src/java.net.http/share/classes/jdk/internal/net/http/ResponseSubscribers.java index ce976a870d9..c690ea4aa46 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/ResponseSubscribers.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/ResponseSubscribers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -545,8 +545,10 @@ public class ResponseSubscribers { @Override public void onSubscribe(Flow.Subscription s) { Objects.requireNonNull(s); + if (debug.on()) debug.log("onSubscribed called"); try { if (!subscribed.compareAndSet(false, true)) { + if (debug.on()) debug.log("Already subscribed: canceling"); s.cancel(); } else { // check whether the stream is already closed. @@ -557,10 +559,14 @@ public class ResponseSubscribers { closed = this.closed; if (!closed) { this.subscription = s; - assert buffers.remainingCapacity() > 1; // should contain at least 2 + // should contain at least 2 + assert buffers.remainingCapacity() > 1 + : "buffers capacity: " + buffers.remainingCapacity() + + " closed: " + closed + " failed: " + failed; } } if (closed) { + if (debug.on()) debug.log("Already closed: canceling"); s.cancel(); return; } @@ -571,6 +577,8 @@ public class ResponseSubscribers { } } catch (Throwable t) { failed = t; + if (debug.on()) + debug.log("onSubscribed failed", t); try { close(); } catch (IOException x) { @@ -604,6 +612,8 @@ public class ResponseSubscribers { @Override public void onError(Throwable thrwbl) { + if (debug.on()) + debug.log("onError called: " + thrwbl); subscription = null; failed = Objects.requireNonNull(thrwbl); // The client process that reads the input stream might @@ -618,6 +628,8 @@ public class ResponseSubscribers { @Override public void onComplete() { + if (debug.on()) + debug.log("onComplete called"); subscription = null; onNext(LAST_LIST); } @@ -631,6 +643,8 @@ public class ResponseSubscribers { s = subscription; subscription = null; } + if (debug.on()) + debug.log("close called"); // s will be null if already completed try { if (s != null) {