netty5/common/src/main/java/io/netty5/util/internal/EmptyArrays.java

39 lines
1.4 KiB
Java
Raw Normal View History

/*
* Copyright 2013 The Netty Project
*
* The Netty Project 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 io.netty5.util.internal;
import io.netty5.util.AsciiString;
import java.nio.ByteBuffer;
import java.security.cert.Certificate;
Add an OpenSslEngine and the universal API for enabling SSL Motivation: Some users already use an SSLEngine implementation in finagle-native. It wraps OpenSSL to get higher SSL performance. However, to take advantage of it, finagle-native must be compiled manually, and it means we cannot pull it in as a dependency and thus we cannot test our SslHandler against the OpenSSL-based SSLEngine. For an instance, we had #2216. Because the construction procedures of JDK SSLEngine and OpenSslEngine are very different from each other, we also need to provide a universal way to enable SSL in a Netty application. Modifications: - Pull netty-tcnative in as an optional dependency. http://netty.io/wiki/forked-tomcat-native.html - Backport NativeLibraryLoader from 4.0 - Move OpenSSL-based SSLEngine implementation into our code base. - Copied from finagle-native; originally written by @jpinner et al. - Overall cleanup by @trustin. - Run all SslHandler tests with both default SSLEngine and OpenSslEngine - Add a unified API for creating an SSL context - SslContext allows you to create a new SSLEngine or a new SslHandler with your PKCS#8 key and X.509 certificate chain. - Add JdkSslContext and its subclasses - Add OpenSslServerContext - Add ApplicationProtocolSelector to ensure the future support for NPN (NextProtoNego) and ALPN (Application Layer Protocol Negotiation) on the client-side. - Add SimpleTrustManagerFactory to help a user write a TrustManagerFactory easily, which should be useful for those who need to write an alternative verification mechanism. For example, we can use it to implement an unsafe TrustManagerFactory that accepts self-signed certificates for testing purposes. - Add InsecureTrustManagerFactory and FingerprintTrustManager for quick and dirty testing - Add SelfSignedCertificate class which generates a self-signed X.509 certificate very easily. - Update all our examples to use SslContext.newClient/ServerContext() - SslHandler now logs the chosen cipher suite when handshake is finished. Result: - Cleaner unified API for configuring an SSL client and an SSL server regardless of its internal implementation. - When native libraries are available, OpenSSL-based SSLEngine implementation is selected automatically to take advantage of its performance benefit. - Examples take advantage of this modification and thus are cleaner.
2014-05-17 19:26:01 +02:00
import java.security.cert.X509Certificate;
public final class EmptyArrays {
public static final int[] EMPTY_INTS = {};
public static final byte[] EMPTY_BYTES = {};
public static final char[] EMPTY_CHARS = {};
public static final Object[] EMPTY_OBJECTS = {};
public static final Class<?>[] EMPTY_CLASSES = {};
public static final String[] EMPTY_STRINGS = {};
Read Only Http2Headers Motivation: A read only implementation of Http2Headers can allow for a more efficient usage of memory and more performant combined construction and iteration during serialization. Modifications: - Add a new ReadOnlyHttp2Headers class Result: ReadOnlyHttp2Headers exists and can be used for performance reasons when appropriate. ``` Benchmark (headerCount) Mode Cnt Score Error Units ReadOnlyHttp2HeadersBenchmark.defaultClientHeaders 1 avgt 20 96.156 ± 1.902 ns/op ReadOnlyHttp2HeadersBenchmark.defaultClientHeaders 5 avgt 20 157.925 ± 3.847 ns/op ReadOnlyHttp2HeadersBenchmark.defaultClientHeaders 10 avgt 20 236.257 ± 2.663 ns/op ReadOnlyHttp2HeadersBenchmark.defaultClientHeaders 20 avgt 20 392.861 ± 3.932 ns/op ReadOnlyHttp2HeadersBenchmark.defaultServerHeaders 1 avgt 20 48.759 ± 0.466 ns/op ReadOnlyHttp2HeadersBenchmark.defaultServerHeaders 5 avgt 20 113.122 ± 0.948 ns/op ReadOnlyHttp2HeadersBenchmark.defaultServerHeaders 10 avgt 20 192.698 ± 1.936 ns/op ReadOnlyHttp2HeadersBenchmark.defaultServerHeaders 20 avgt 20 348.974 ± 3.111 ns/op ReadOnlyHttp2HeadersBenchmark.defaultTrailers 1 avgt 20 35.694 ± 0.271 ns/op ReadOnlyHttp2HeadersBenchmark.defaultTrailers 5 avgt 20 98.993 ± 2.933 ns/op ReadOnlyHttp2HeadersBenchmark.defaultTrailers 10 avgt 20 171.035 ± 5.068 ns/op ReadOnlyHttp2HeadersBenchmark.defaultTrailers 20 avgt 20 330.621 ± 3.381 ns/op ReadOnlyHttp2HeadersBenchmark.readOnlyClientHeaders 1 avgt 20 40.573 ± 0.474 ns/op ReadOnlyHttp2HeadersBenchmark.readOnlyClientHeaders 5 avgt 20 56.516 ± 0.660 ns/op ReadOnlyHttp2HeadersBenchmark.readOnlyClientHeaders 10 avgt 20 76.890 ± 0.776 ns/op ReadOnlyHttp2HeadersBenchmark.readOnlyClientHeaders 20 avgt 20 117.531 ± 1.393 ns/op ReadOnlyHttp2HeadersBenchmark.readOnlyServerHeaders 1 avgt 20 29.206 ± 0.264 ns/op ReadOnlyHttp2HeadersBenchmark.readOnlyServerHeaders 5 avgt 20 44.587 ± 0.312 ns/op ReadOnlyHttp2HeadersBenchmark.readOnlyServerHeaders 10 avgt 20 64.458 ± 1.169 ns/op ReadOnlyHttp2HeadersBenchmark.readOnlyServerHeaders 20 avgt 20 107.179 ± 0.881 ns/op ReadOnlyHttp2HeadersBenchmark.readOnlyTrailers 1 avgt 20 21.563 ± 0.202 ns/op ReadOnlyHttp2HeadersBenchmark.readOnlyTrailers 5 avgt 20 41.019 ± 0.440 ns/op ReadOnlyHttp2HeadersBenchmark.readOnlyTrailers 10 avgt 20 64.053 ± 0.785 ns/op ReadOnlyHttp2HeadersBenchmark.readOnlyTrailers 20 avgt 20 113.737 ± 4.433 ns/op ```
2016-11-12 19:40:35 +01:00
public static final AsciiString[] EMPTY_ASCII_STRINGS = {};
public static final StackTraceElement[] EMPTY_STACK_TRACE = {};
public static final ByteBuffer[] EMPTY_BYTE_BUFFERS = {};
public static final Certificate[] EMPTY_CERTIFICATES = {};
private EmptyArrays() { }
}