Skip to content

Commit

Permalink
Remove public constructors from production types. (#7335)
Browse files Browse the repository at this point in the history
* Remove public constructors from production types.
  • Loading branch information
tomas-langer authored Aug 8, 2023
1 parent ac711c9 commit 039bdd5
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 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.
Expand Down Expand Up @@ -32,7 +32,7 @@
/**
* A trust manager factory that trusts all peers.
*/
public class TrustAllManagerFactory extends TrustManagerFactory {
class TrustAllManagerFactory extends TrustManagerFactory {
private static final TrustAllManagerFactorySpi SPI = new TrustAllManagerFactorySpi();
private static final Provider PROVIDER = new Provider("helidon",
"0.0",
Expand All @@ -43,7 +43,7 @@ public class TrustAllManagerFactory extends TrustManagerFactory {
/**
* Create a new instance.
*/
public TrustAllManagerFactory() {
TrustAllManagerFactory() {
super(SPI, PROVIDER, "insecure-trust-all");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Http2ConnectionWriter(SocketContext ctx, DataWriter writer, List<Http2Fra

// initial size is based on our settings, then updated with client settings
this.outboundDynamicTable = Http2Headers.DynamicTable.create(Http2Setting.HEADER_TABLE_SIZE.defaultValue());
this.responseHuffman = new Http2HuffmanEncoder();
this.responseHuffman = Http2HuffmanEncoder.create();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 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.
Expand Down Expand Up @@ -40,7 +40,7 @@
import io.helidon.common.buffers.BufferData;

/**
* Implementation of HPack Huffman decoding and encoding.
* Implementation of HPack Huffman decoding.
*/
public class Http2HuffmanDecoder {
private static final String EMPTY_STRING = "";
Expand All @@ -54,7 +54,16 @@ public class Http2HuffmanDecoder {
/**
* Huffman decoder.
*/
public Http2HuffmanDecoder() {
private Http2HuffmanDecoder() {
}

/**
* Creates a new HPack Huffman decoder.
*
* @return a new Huffman decoder
*/
public static Http2HuffmanDecoder create() {
return new Http2HuffmanDecoder();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 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.
Expand Down Expand Up @@ -37,15 +37,24 @@
import io.helidon.common.buffers.BufferData;

/**
* Implementation of HPack Huffman decoding and encoding.
* Implementation of HPack Huffman encoding.
*/
public class Http2HuffmanEncoder {
private static final int HUFFMAN_ENCODED = 1 << 7;

/**
* Huffman encoder.
*/
public Http2HuffmanEncoder() {
private Http2HuffmanEncoder() {
}

/**
* Creates a new HPack Huffman encoder.
*
* @return a new Huffman encoder
*/
public static Http2HuffmanEncoder create() {
return new Http2HuffmanEncoder();
}

void encode(BufferData buffer, String string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void testC_4_toBytes() {
http2Headers.path("/");
http2Headers.authority("www.example.com");

Http2HuffmanEncoder huffman = new Http2HuffmanEncoder();
Http2HuffmanEncoder huffman = Http2HuffmanEncoder.create();

BufferData buffer = BufferData.growing(32);
http2Headers.write(dynamicTable, huffman, buffer);
Expand Down Expand Up @@ -262,7 +262,7 @@ private Http2Headers headers(String hexEncoded, DynamicTable dynamicTable) {

return Http2Headers.create(stream,
dynamicTable,
new Http2HuffmanDecoder(),
Http2HuffmanDecoder.create(),
new Http2FrameData(header, data));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 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.
Expand All @@ -26,8 +26,8 @@
class Http2HuffmanTest {
@Test
void testEncodeDecode() {
Http2HuffmanEncoder enc = new Http2HuffmanEncoder();
Http2HuffmanDecoder dec = new Http2HuffmanDecoder();
Http2HuffmanEncoder enc = Http2HuffmanEncoder.create();
Http2HuffmanDecoder dec = Http2HuffmanDecoder.create();

String value = "my very nice long value";
BufferData result = BufferData.growing(32);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private Http2FrameData readOne() {
case HEADERS, CONTINUATION:
continuationData.add(frameData);
if (endOfHeaders) {
var requestHuffman = new Http2HuffmanDecoder();
var requestHuffman = Http2HuffmanDecoder.create();
Http2Headers http2Headers = Http2Headers.create(this,
connection.getInboundDynamicTable(),
requestHuffman,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public class Http2Connection implements ServerConnection, InterruptableTask<Void
this.subProviders = subProviders;
this.requestDynamicTable = Http2Headers.DynamicTable.create(
serverSettings.value(Http2Setting.HEADER_TABLE_SIZE));
this.requestHuffman = new Http2HuffmanDecoder();
this.requestHuffman = Http2HuffmanDecoder.create();
this.routing = ctx.router().routing(HttpRouting.class, HttpRouting.empty());
this.reader = ctx.dataReader();
this.sendErrorDetails = http2Config.sendErrorDetails();
Expand Down

0 comments on commit 039bdd5

Please sign in to comment.