Call to ‘asList’ with only one argument could be replaced with ‘singletonList’ (#9288)
Motivation: asList should only be used if there are multiple elements. Modification: Call to asList with only one argument could be replaced with singletonList Result: Cleaner code and a bit of memory savings
This commit is contained in:
parent
e233407e01
commit
3e836bd3fe
@ -196,7 +196,7 @@ public class CombinedHttpHeadersTest {
|
||||
public void addIterableCsvEmpty() {
|
||||
final CombinedHttpHeaders headers = newCombinedHttpHeaders();
|
||||
headers.add(HEADER_NAME, Collections.<CharSequence>emptyList());
|
||||
assertEquals(Arrays.asList(""), headers.getAll(HEADER_NAME));
|
||||
assertEquals(Collections.singletonList(""), headers.getAll(HEADER_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -294,9 +294,9 @@ public class CombinedHttpHeadersTest {
|
||||
headers.set(HEADER_NAME, Arrays.asList("\"a\"", "\"b\"", "\"c\""));
|
||||
assertEquals(Arrays.asList("a", "b", "c"), headers.getAll(HEADER_NAME));
|
||||
headers.set(HEADER_NAME, "a,b,c");
|
||||
assertEquals(Arrays.asList("a,b,c"), headers.getAll(HEADER_NAME));
|
||||
assertEquals(Collections.singletonList("a,b,c"), headers.getAll(HEADER_NAME));
|
||||
headers.set(HEADER_NAME, "\"a,b,c\"");
|
||||
assertEquals(Arrays.asList("a,b,c"), headers.getAll(HEADER_NAME));
|
||||
assertEquals(Collections.singletonList("a,b,c"), headers.getAll(HEADER_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -18,6 +18,7 @@ package io.netty.util.internal;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import static io.netty.util.internal.StringUtil.NEWLINE;
|
||||
import static io.netty.util.internal.StringUtil.commonSuffixOfLength;
|
||||
@ -446,15 +447,15 @@ public class StringUtilTest {
|
||||
|
||||
@Test
|
||||
public void testUnescapeCsvFields() {
|
||||
assertEquals(Arrays.asList(""), unescapeCsvFields(""));
|
||||
assertEquals(Collections.singletonList(""), unescapeCsvFields(""));
|
||||
assertEquals(Arrays.asList("", ""), unescapeCsvFields(","));
|
||||
assertEquals(Arrays.asList("a", ""), unescapeCsvFields("a,"));
|
||||
assertEquals(Arrays.asList("", "a"), unescapeCsvFields(",a"));
|
||||
assertEquals(Arrays.asList("\""), unescapeCsvFields("\"\"\"\""));
|
||||
assertEquals(Collections.singletonList("\""), unescapeCsvFields("\"\"\"\""));
|
||||
assertEquals(Arrays.asList("\"", "\""), unescapeCsvFields("\"\"\"\",\"\"\"\""));
|
||||
assertEquals(Arrays.asList("netty"), unescapeCsvFields("netty"));
|
||||
assertEquals(Collections.singletonList("netty"), unescapeCsvFields("netty"));
|
||||
assertEquals(Arrays.asList("hello", "netty"), unescapeCsvFields("hello,netty"));
|
||||
assertEquals(Arrays.asList("hello,netty"), unescapeCsvFields("\"hello,netty\""));
|
||||
assertEquals(Collections.singletonList("hello,netty"), unescapeCsvFields("\"hello,netty\""));
|
||||
assertEquals(Arrays.asList("hello", "netty"), unescapeCsvFields("\"hello\",\"netty\""));
|
||||
assertEquals(Arrays.asList("a\"b", "c\"d"), unescapeCsvFields("\"a\"\"b\",\"c\"\"d\""));
|
||||
assertEquals(Arrays.asList("a\rb", "c\nd"), unescapeCsvFields("\"a\rb\",\"c\nd\""));
|
||||
|
@ -1930,13 +1930,13 @@ public abstract class SSLEngineTest {
|
||||
final String sharedCipher = "TLS_RSA_WITH_AES_128_CBC_SHA";
|
||||
clientSslCtx = SslContextBuilder.forClient()
|
||||
.trustManager(InsecureTrustManagerFactory.INSTANCE)
|
||||
.ciphers(Arrays.asList(sharedCipher))
|
||||
.ciphers(Collections.singletonList(sharedCipher))
|
||||
.protocols(PROTOCOL_TLS_V1_2, PROTOCOL_TLS_V1)
|
||||
.sslProvider(sslClientProvider())
|
||||
.build();
|
||||
|
||||
serverSslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey())
|
||||
.ciphers(Arrays.asList(sharedCipher))
|
||||
.ciphers(Collections.singletonList(sharedCipher))
|
||||
.protocols(PROTOCOL_TLS_V1_2, PROTOCOL_TLS_V1)
|
||||
.sslProvider(sslServerProvider())
|
||||
.build();
|
||||
@ -1961,13 +1961,13 @@ public abstract class SSLEngineTest {
|
||||
final String sharedCipher = "TLS_RSA_WITH_AES_128_CBC_SHA";
|
||||
clientSslCtx = SslContextBuilder.forClient()
|
||||
.trustManager(InsecureTrustManagerFactory.INSTANCE)
|
||||
.ciphers(Arrays.asList(sharedCipher), SupportedCipherSuiteFilter.INSTANCE)
|
||||
.ciphers(Collections.singletonList(sharedCipher), SupportedCipherSuiteFilter.INSTANCE)
|
||||
.protocols(PROTOCOL_TLS_V1_2, PROTOCOL_TLS_V1)
|
||||
.sslProvider(sslClientProvider())
|
||||
.build();
|
||||
|
||||
serverSslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey())
|
||||
.ciphers(Arrays.asList(sharedCipher), SupportedCipherSuiteFilter.INSTANCE)
|
||||
.ciphers(Collections.singletonList(sharedCipher), SupportedCipherSuiteFilter.INSTANCE)
|
||||
.protocols(PROTOCOL_TLS_V1_2, PROTOCOL_TLS_V1)
|
||||
.sslProvider(sslServerProvider())
|
||||
.build();
|
||||
|
Loading…
Reference in New Issue
Block a user