@@ -71,18 +71,17 @@ public void process(HttpRequest httpRequest, HttpContext httpContext)
7171 // convert header names to lower case for case in-sensitive lookup
7272 Set <String > protectedHeaders =
7373 currentHeaders .keySet ().stream ().map (String ::toLowerCase ).collect (Collectors .toSet ());
74- Object executionCount =
75- httpContext .getAttribute (
74+ Integer executionCount =
75+ ( Integer ) httpContext .getAttribute (
7676 AttributeEnhancingHttpRequestRetryHandler .EXECUTION_COUNT_ATTRIBUTE );
77- // If count is null or 0, it's the first attempt. Otherwise, it's a retry.
78- boolean isRetry = (executionCount != null && (Integer ) executionCount > 0 );
77+ boolean isRetry = (executionCount == null || executionCount > 0 );
7978
8079 for (HttpHeadersCustomizer customizer : this .headersCustomizers ) {
8180 if (customizer .applies (httpMethod , uri , currentHeaders )) {
8281 if (customizer .invokeOnce () && isRetry ) {
8382 logger .debug (
8483 "{} customizer should only run on the first attempt and this is a {} retry. Skipping." ,
85- customizer .getClass (),
84+ customizer .getClass (). getCanonicalName () ,
8685 executionCount );
8786 continue ;
8887 }
@@ -157,18 +156,22 @@ private static void throwIfExistingHeadersAreModified(
157156 Set <String > protectedHeaders , Set <String > newHeaders , HttpHeadersCustomizer customizer ) {
158157 for (String headerName : newHeaders ) {
159158 if (headerName != null && protectedHeaders .contains (headerName .toLowerCase ())) {
159+ String customizerName = customizer .getClass ().getCanonicalName ();
160160 logger .debug (
161161 "Customizer {} attempted to override existing driver header: {}" ,
162- customizer . getClass (). getName () ,
162+ customizerName ,
163163 headerName );
164- throw new DriverHeaderOverridingNotAllowedException (headerName );
164+ throw new DriverHeaderOverridingNotAllowedException (headerName , customizerName );
165165 }
166166 }
167167 }
168168
169169 public static class DriverHeaderOverridingNotAllowedException extends RuntimeException {
170- public DriverHeaderOverridingNotAllowedException (String header ) {
171- super (String .format ("Driver headers overriding not allowed. Tried for header: %s" , header ));
170+ public DriverHeaderOverridingNotAllowedException (String header , String customizerName ) {
171+ super (
172+ String .format (
173+ "Driver headers overriding not allowed. Tried for header: %s in customizer: {}" ,
174+ header , customizerName ));
172175 }
173176 }
174177}
0 commit comments