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

Add QueryParams which deprecates HttpParameters #2307

Merged
merged 49 commits into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
959f402
Add `QueryParams` which deprecates `HttpParameters`
trustin Dec 10, 2019
dfa5d11
Merge branch 'master' into immutable_http_params
trustin Dec 11, 2019
eb6bf37
Checkstyle
trustin Dec 11, 2019
8c47f62
Share the common logic between `QueryParamsBase` and `HttpHeadersBase`
trustin Dec 11, 2019
a70b113
Add some tests to ensure API consistency
trustin Dec 11, 2019
7863cca
Fix test failure
trustin Dec 11, 2019
6687a81
Rename a bunch of stuff for consistency
trustin Dec 11, 2019
acea7ff
Fix import
trustin Dec 11, 2019
48751d6
AbstractStringMultimapBuilder -> StringMultimapBuilder
trustin Dec 11, 2019
f7ae4e9
Add `QueryParamGetters.toQueryString()` and `appendQueryString()`
trustin Dec 12, 2019
5613b6d
Checkstyle and cleanup
trustin Dec 12, 2019
3f5a874
Documentation
trustin Dec 12, 2019
79ffa65
Add Javadoc return tag
trustin Dec 12, 2019
4a27a93
Merge branch 'master' into immutable_http_params
trustin Dec 14, 2019
c3ea71c
Address the comments from @anuraaga and @ikhoon
trustin Dec 14, 2019
b8c6d5e
Fix comment, inspired by @ikhoon's comment
trustin Dec 14, 2019
3663f03
Checkstyle
trustin Dec 14, 2019
b365e6d
Clean-up
trustin Dec 15, 2019
df1a365
Address the comments from @minwoox
trustin Dec 16, 2019
a041106
Address one more comment from @minwoox
trustin Dec 16, 2019
c5c096a
Address yet another comment from @minwoox
trustin Dec 16, 2019
7eea42f
Address some of the comments from @anuraaga
trustin Dec 16, 2019
39521ff
Replace `ThreadLocalByteArray` with `TemporaryThreadLocals` / Optimiz…
trustin Dec 16, 2019
ce90fe5
Optimization
trustin Dec 17, 2019
bfd2196
Simplify
trustin Dec 17, 2019
0ef906b
Clean-up
trustin Dec 18, 2019
1bc56ae
Fix encoder bug / Optimize decoder / More tests
trustin Dec 18, 2019
b8c5e91
Add benchmark for `QueryStringDecoder`
trustin Dec 18, 2019
937779c
Switch to traditional decoding loop as advised by @anuraaga
trustin Dec 18, 2019
2cac19f
Optimization and fix
trustin Dec 18, 2019
266cdc2
Further optimization of ASCII decoding
trustin Dec 18, 2019
9240e84
Optimize the decoder tad bit more, allowing us to win at any case
trustin Dec 18, 2019
b4956d0
Slightly more compact lookup table
trustin Dec 18, 2019
47f448d
Use `hashName()` instead of `.hashCode()` for names
trustin Dec 18, 2019
1e78f95
Clean-up benchmarks and add test for long query string
trustin Dec 18, 2019
e44d3b3
Improve safe octet scanning in `QueryStringEncoder` as advised by @an…
trustin Dec 18, 2019
ba0e903
Optimize percent encoding
trustin Dec 18, 2019
3d9123c
Borrow more from Guava
trustin Dec 18, 2019
c67ffb7
Checkstyle
trustin Dec 18, 2019
541796b
Experiment: Pre-inflate `StringBuilder`
trustin Dec 18, 2019
fd1c4e5
Micro clean-up
trustin Dec 18, 2019
c399ff9
Checkstyle
trustin Dec 19, 2019
8383ef9
Experiment: Make `char[]` stack-allocated by JVM
trustin Dec 19, 2019
5d17e4a
Checkstyle
trustin Dec 19, 2019
959793f
Merge branches
trustin Dec 19, 2019
59b00d5
Add Guava copyright header
trustin Dec 19, 2019
5b7dfaf
Checkstyle
trustin Dec 19, 2019
1cb66cb
Address the comments from @anuraaga
trustin Dec 19, 2019
4ae61e4
Address the comments from @minwoox
trustin Dec 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add QueryParams which deprecates HttpParameters
Motivation:

- #1567

Modifications:

- Fork our HTTP headers implementation into:
  - `QueryParams`
  - `QueryParamGetters`
  - `QueryParamsBase`
  - `QueryParamsBuilder`
  - .. and their implementations.
  - Note that it is intentional that I didn't introduce any common
    classes between `HttpHeaders` and `QueryParams`. They are just
    similar to each other accidentally and thus share nothing
    semantically close in common in my opinion. Please let me know if
    you do not like this approach - we should discuss.
- Add support for `QueryParams` to annotated services.
- Deprecate `HttpParameters`.

Result:

- Closes #1567

To-dos:

- Add encoding/decoding methods like we did for `Cookie`.
- Update `annotated-services.rst`
  • Loading branch information
trustin committed Dec 10, 2019
commit 959f4023f5d7781360d5535934720e32e076d33c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2019 LINE Corporation
*
* LINE Corporation licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.linecorp.armeria.common;

import javax.annotation.Nullable;

@SuppressWarnings("checkstyle:EqualsHashCode")
final class DefaultQueryParams extends QueryParamsBase implements QueryParams {

static final DefaultQueryParams EMPTY = new DefaultQueryParams();

/**
* Creates an empty parameters.
*/
private DefaultQueryParams() {
// Note that we do not specify a small size hint here, because a user may create a new builder
// derived from an empty parameters and add many parameters. If we specified a small hint,
// such a parameters would suffer from hash collisions.
super(DEFAULT_SIZE_HINT);
}

/**
* Creates a shallow copy of the specified {@link QueryParamsBase}.
*/
DefaultQueryParams(QueryParamsBase params) {
super(params, true);
}

@Override
public QueryParamsBuilder toBuilder() {
return new DefaultQueryParamsBuilder(this);
}

@Override
public boolean equals(@Nullable Object o) {
return o instanceof QueryParams && super.equals(o);
}
}
Loading