@@ -55,6 +55,12 @@ public final class HttpRequest {
5555 */
5656 public static final String USER_AGENT_SUFFIX = "Google-HTTP-Java-Client/" + VERSION + " (gzip)" ;
5757
58+ /** Whether we've warned about {@link #setAllowEmptyContent} being deprecated. */
59+ private static volatile boolean warnedDeprecatedSetAllowEmptyContent ;
60+
61+ /** Whether we've warned about {@link #isAllowEmptyContent} being deprecated. */
62+ private static volatile boolean warnedDeprecatedIsAllowEmptyContent ;
63+
5864 /**
5965 * HTTP request execute interceptor to intercept the start of {@link #execute()} (before executing
6066 * the HTTP request) or {@code null} for none.
@@ -585,8 +591,11 @@ public HttpRequest setUnsuccessfulResponseHandler(
585591 @ Deprecated
586592 public HttpRequest setAllowEmptyContent (boolean allowEmptyContent ) {
587593 this .allowEmptyContent = allowEmptyContent ;
588- HttpTransport .LOGGER .warning ("setAllowEmptyContent is deprecated and will be removed in 1.12;"
589- + " use setEmptyContent instead (if needed)" );
594+ if (!warnedDeprecatedSetAllowEmptyContent ) {
595+ HttpTransport .LOGGER .warning ("setAllowEmptyContent is deprecated and will be removed in 1.12;"
596+ + " use setEmptyContent instead (if needed)" );
597+ warnedDeprecatedSetAllowEmptyContent = true ;
598+ }
590599 return this ;
591600 }
592601
@@ -600,7 +609,10 @@ public HttpRequest setAllowEmptyContent(boolean allowEmptyContent) {
600609 */
601610 @ Deprecated
602611 public boolean isAllowEmptyContent () {
603- HttpTransport .LOGGER .warning ("isAllowEmptyContent is deprecated and will be removed in 1.12" );
612+ if (!warnedDeprecatedIsAllowEmptyContent ) {
613+ HttpTransport .LOGGER .warning ("isAllowEmptyContent is deprecated and will be removed in 1.12" );
614+ warnedDeprecatedIsAllowEmptyContent = true ;
615+ }
604616 return allowEmptyContent ;
605617 }
606618
0 commit comments