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

Updates header type hierarchy to make HeaderValueCached not writeable #8000

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.ArrayList;
import java.util.List;

class HeaderValueArray extends HeaderValueBase {
class HeaderValueArray extends HeaderWritableValueBase {
private final String[] originalValues;
private List<String> values;

Expand Down
5 changes: 1 addition & 4 deletions http/http/src/main/java/io/helidon/http/HeaderValueBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import io.helidon.common.mapper.MapperManager;
import io.helidon.common.mapper.Value;

abstract class HeaderValueBase implements HeaderWriteable {
abstract class HeaderValueBase implements Header {
private static final String[] QUALIFIER = new String[] {"http", "header"};
private final HeaderName name;
private final String actualName;
Expand All @@ -41,9 +41,6 @@ abstract class HeaderValueBase implements HeaderWriteable {
this.firstValue = value;
}

@Override
public abstract HeaderWriteable addValue(String value);

@Override
public String name() {
return actualName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public void writeHttp1Header(BufferData buffer) {
buffer.write(cachedHttp1Header);
}

@Override
public HeaderWriteable addValue(String value) {
throw new UnsupportedOperationException("Cannot change values of a cached header " + name());
}

@Override
public List<String> allValues() {
return List.of(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.ArrayList;
import java.util.List;

class HeaderValueCopy extends HeaderValueBase {
class HeaderValueCopy extends HeaderWritableValueBase {
private final Header original;
private List<String> values;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import io.helidon.common.buffers.LazyString;

class HeaderValueLazy extends HeaderValueBase {
class HeaderValueLazy extends HeaderWritableValueBase {
private final LazyString value;
private List<String> values;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.Collection;
import java.util.List;

class HeaderValueList extends HeaderValueBase {
class HeaderValueList extends HeaderWritableValueBase {
private List<String> values;

HeaderValueList(HeaderName name, boolean changing, boolean sensitive, Collection<String> values) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.ArrayList;
import java.util.List;

class HeaderValueSingle extends HeaderValueBase {
class HeaderValueSingle extends HeaderWritableValueBase {
private final String value;
private List<String> values;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
*
* Licensed 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
*
* http://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 io.helidon.http;

abstract class HeaderWritableValueBase extends HeaderValueBase implements HeaderWriteable {

HeaderWritableValueBase(HeaderName name, boolean changing, boolean sensitive, String value) {
super(name, changing, sensitive, value);
}
}