Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ClassCastException when calling *HeadersBuilder.build() #2193

Merged
merged 1 commit into from
Oct 17, 2019

Conversation

trustin
Copy link
Member

@trustin trustin commented Oct 17, 2019

Motivation:

The following code, which calls *HeadersBuilder.build() twice, fails
with a ClassCastException.

HttpHeadersBuilder b = HttpHeaders.builder();
b.add("foo", "bar");
b.build();
b.build(); // Throws a ClassCastException

Modifications:

  • Make sure the parent is of a desired type. Rebuild if not.

Result:

Motivation:

The following code, which calls `*HeadersBuilder.build()` twice, fails
with a `ClassCastException`.

    HttpHeadersBuilder b = HttpHeaders.builder();
    b.add("foo", "bar");
    b.build();
    b.build(); // Throws a ClassCastException

Modifications:

- Make sure the `parent` is of a desired type. Rebuild if not.

Result:

- Fixes line#2190
@trustin trustin added the defect label Oct 17, 2019
@trustin trustin added this to the 0.95.0 milestone Oct 17, 2019
@trustin
Copy link
Member Author

trustin commented Oct 17, 2019

/cc @yuinacor

Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! @trustin

@codecov
Copy link

codecov bot commented Oct 17, 2019

Codecov Report

Merging #2193 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2193      +/-   ##
============================================
+ Coverage     73.54%   73.58%   +0.03%     
- Complexity     9570     9577       +7     
============================================
  Files           837      837              
  Lines         36883    36893      +10     
  Branches       4548     4551       +3     
============================================
+ Hits          27126    27146      +20     
+ Misses         7438     7419      -19     
- Partials       2319     2328       +9
Impacted Files Coverage Δ Complexity Δ
...orp/armeria/common/AbstractHttpHeadersBuilder.java 47.25% <100%> (+0.58%) 64 <1> (+1) ⬆️
...p/armeria/common/DefaultRequestHeadersBuilder.java 77.14% <100%> (+1.38%) 15 <0> (+1) ⬆️
.../armeria/common/DefaultResponseHeadersBuilder.java 95% <100%> (+0.55%) 9 <0> (+1) ⬆️
...corp/armeria/common/DefaultHttpHeadersBuilder.java 100% <100%> (ø) 8 <0> (+1) ⬆️
...meria/common/stream/RegularFixedStreamMessage.java 81.63% <0%> (-6.13%) 13% <0%> (-1%)
.../linecorp/armeria/internal/Http2GoAwayHandler.java 53.84% <0%> (-2.57%) 13% <0%> (-1%)
...a/com/linecorp/armeria/client/HttpChannelPool.java 72.76% <0%> (-2.34%) 59% <0%> (-2%)
...om/linecorp/armeria/client/HttpClientDelegate.java 88.67% <0%> (-1.89%) 31% <0%> (-1%)
...corp/armeria/common/stream/FixedStreamMessage.java 87.71% <0%> (-1.76%) 22% <0%> (-1%)
...necorp/armeria/client/HeapBasedEventLoopState.java 92.78% <0%> (-1.04%) 31% <0%> (-1%)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84362c4...a39ae21. Read the comment docs.

Copy link
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@trustin trustin changed the title Fix ClassCastException when calling *HeadersBuilder.build() twice Fix ClassCastException when calling *HeadersBuilder.build() Oct 17, 2019
@trustin trustin merged commit 5647766 into line:master Oct 17, 2019
@trustin trustin deleted the fix_client_double_build branch October 17, 2019 07:34
fmguerreiro pushed a commit to fmguerreiro/armeria that referenced this pull request Sep 19, 2020
…e#2193)

Motivation:

The following code, which calls `*HeadersBuilder.build()` twice, fails
with a `ClassCastException`.

    HttpHeadersBuilder b = HttpHeaders.builder();
    b.add("foo", "bar");
    b.build();
    b.build(); // Throws a ClassCastException

Modifications:

- Make sure the `parent` is of a desired type. Rebuild if not.

Result:

- Fixes line#2190
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClassCastException while building a Client with additional headers
3 participants