@@ -132,7 +132,6 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
132132 @ SuppressWarnings ("this-escape" )
133133 public ElasticsearchException (Throwable cause ) {
134134 super (cause );
135- maybeAddErrorHeaders ();
136135 }
137136
138137 /**
@@ -147,7 +146,6 @@ public ElasticsearchException(Throwable cause) {
147146 @ SuppressWarnings ("this-escape" )
148147 public ElasticsearchException (String msg , Object ... args ) {
149148 super (LoggerMessageFormat .format (msg , args ));
150- maybeAddErrorHeaders ();
151149 }
152150
153151 /**
@@ -164,7 +162,6 @@ public ElasticsearchException(String msg, Object... args) {
164162 @ SuppressWarnings ("this-escape" )
165163 public ElasticsearchException (String msg , Throwable cause , Object ... args ) {
166164 super (LoggerMessageFormat .format (msg , args ), cause );
167- maybeAddErrorHeaders ();
168165 }
169166
170167 @ SuppressWarnings ("this-escape" )
@@ -253,6 +250,7 @@ public void addBodyHeader(String key, String... value) {
253250 * Returns a set of all body header keys on this exception
254251 */
255252 public Set <String > getBodyHeaderKeys () {
253+ maybeAddErrorHeaders ();
256254 return bodyHeaders .keySet ();
257255 }
258256
@@ -261,10 +259,12 @@ public Set<String> getBodyHeaderKeys() {
261259 * given key exists.
262260 */
263261 public List <String > getBodyHeader (String key ) {
262+ maybeAddErrorHeaders ();
264263 return bodyHeaders .get (key );
265264 }
266265
267266 protected Map <String , List <String >> getBodyHeaders () {
267+ maybeAddErrorHeaders ();
268268 return bodyHeaders ;
269269 }
270270
@@ -288,6 +288,7 @@ public void addHttpHeader(String key, String... value) {
288288 * Returns a set of all body header keys on this exception
289289 */
290290 public Set <String > getHttpHeaderKeys () {
291+ maybeAddErrorHeaders ();
291292 return httpHeaders .keySet ();
292293 }
293294
@@ -296,10 +297,12 @@ public Set<String> getHttpHeaderKeys() {
296297 * given key exists.
297298 */
298299 public List <String > getHttpHeader (String key ) {
300+ maybeAddErrorHeaders ();
299301 return httpHeaders .get (key );
300302 }
301303
302304 protected Map <String , List <String >> getHttpHeaders () {
305+ maybeAddErrorHeaders ();
303306 return httpHeaders ;
304307 }
305308
0 commit comments