Skip to content

Commit 039bdd5

Browse files
authored
Remove public constructors from production types. (#7335)
* Remove public constructors from production types.
1 parent ac711c9 commit 039bdd5

File tree

8 files changed

+35
-17
lines changed

8 files changed

+35
-17
lines changed

nima/common/tls/src/main/java/io/helidon/nima/common/tls/TrustAllManagerFactory.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@
3232
/**
3333
* A trust manager factory that trusts all peers.
3434
*/
35-
public class TrustAllManagerFactory extends TrustManagerFactory {
35+
class TrustAllManagerFactory extends TrustManagerFactory {
3636
private static final TrustAllManagerFactorySpi SPI = new TrustAllManagerFactorySpi();
3737
private static final Provider PROVIDER = new Provider("helidon",
3838
"0.0",
@@ -43,7 +43,7 @@ public class TrustAllManagerFactory extends TrustManagerFactory {
4343
/**
4444
* Create a new instance.
4545
*/
46-
public TrustAllManagerFactory() {
46+
TrustAllManagerFactory() {
4747
super(SPI, PROVIDER, "insecure-trust-all");
4848
}
4949

nima/http2/http2/src/main/java/io/helidon/nima/http2/Http2ConnectionWriter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public Http2ConnectionWriter(SocketContext ctx, DataWriter writer, List<Http2Fra
5353

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

5959
@Override

nima/http2/http2/src/main/java/io/helidon/nima/http2/Http2HuffmanDecoder.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@
4040
import io.helidon.common.buffers.BufferData;
4141

4242
/**
43-
* Implementation of HPack Huffman decoding and encoding.
43+
* Implementation of HPack Huffman decoding.
4444
*/
4545
public class Http2HuffmanDecoder {
4646
private static final String EMPTY_STRING = "";
@@ -54,7 +54,16 @@ public class Http2HuffmanDecoder {
5454
/**
5555
* Huffman decoder.
5656
*/
57-
public Http2HuffmanDecoder() {
57+
private Http2HuffmanDecoder() {
58+
}
59+
60+
/**
61+
* Creates a new HPack Huffman decoder.
62+
*
63+
* @return a new Huffman decoder
64+
*/
65+
public static Http2HuffmanDecoder create() {
66+
return new Http2HuffmanDecoder();
5867
}
5968

6069
/**

nima/http2/http2/src/main/java/io/helidon/nima/http2/Http2HuffmanEncoder.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,15 +37,24 @@
3737
import io.helidon.common.buffers.BufferData;
3838

3939
/**
40-
* Implementation of HPack Huffman decoding and encoding.
40+
* Implementation of HPack Huffman encoding.
4141
*/
4242
public class Http2HuffmanEncoder {
4343
private static final int HUFFMAN_ENCODED = 1 << 7;
4444

4545
/**
4646
* Huffman encoder.
4747
*/
48-
public Http2HuffmanEncoder() {
48+
private Http2HuffmanEncoder() {
49+
}
50+
51+
/**
52+
* Creates a new HPack Huffman encoder.
53+
*
54+
* @return a new Huffman encoder
55+
*/
56+
public static Http2HuffmanEncoder create() {
57+
return new Http2HuffmanEncoder();
4958
}
5059

5160
void encode(BufferData buffer, String string) {

nima/http2/http2/src/test/java/io/helidon/nima/http2/Http2HeadersTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void testC_4_toBytes() {
171171
http2Headers.path("/");
172172
http2Headers.authority("www.example.com");
173173

174-
Http2HuffmanEncoder huffman = new Http2HuffmanEncoder();
174+
Http2HuffmanEncoder huffman = Http2HuffmanEncoder.create();
175175

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

263263
return Http2Headers.create(stream,
264264
dynamicTable,
265-
new Http2HuffmanDecoder(),
265+
Http2HuffmanDecoder.create(),
266266
new Http2FrameData(header, data));
267267
}
268268
}

nima/http2/http2/src/test/java/io/helidon/nima/http2/Http2HuffmanTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,8 +26,8 @@
2626
class Http2HuffmanTest {
2727
@Test
2828
void testEncodeDecode() {
29-
Http2HuffmanEncoder enc = new Http2HuffmanEncoder();
30-
Http2HuffmanDecoder dec = new Http2HuffmanDecoder();
29+
Http2HuffmanEncoder enc = Http2HuffmanEncoder.create();
30+
Http2HuffmanDecoder dec = Http2HuffmanDecoder.create();
3131

3232
String value = "my very nice long value";
3333
BufferData result = BufferData.growing(32);

nima/http2/webclient/src/main/java/io/helidon/nima/http2/webclient/Http2ClientStream.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private Http2FrameData readOne() {
292292
case HEADERS, CONTINUATION:
293293
continuationData.add(frameData);
294294
if (endOfHeaders) {
295-
var requestHuffman = new Http2HuffmanDecoder();
295+
var requestHuffman = Http2HuffmanDecoder.create();
296296
Http2Headers http2Headers = Http2Headers.create(this,
297297
connection.getInboundDynamicTable(),
298298
requestHuffman,

nima/http2/webserver/src/main/java/io/helidon/nima/http2/webserver/Http2Connection.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public class Http2Connection implements ServerConnection, InterruptableTask<Void
125125
this.subProviders = subProviders;
126126
this.requestDynamicTable = Http2Headers.DynamicTable.create(
127127
serverSettings.value(Http2Setting.HEADER_TABLE_SIZE));
128-
this.requestHuffman = new Http2HuffmanDecoder();
128+
this.requestHuffman = Http2HuffmanDecoder.create();
129129
this.routing = ctx.router().routing(HttpRouting.class, HttpRouting.empty());
130130
this.reader = ctx.dataReader();
131131
this.sendErrorDetails = http2Config.sendErrorDetails();

0 commit comments

Comments
 (0)