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

use jspecify annotations #2026

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@

<dependencies>
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import io.netty.handler.codec.http.HttpHeaders;
import org.asynchttpclient.handler.ProgressAsyncHandler;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*/
package org.asynchttpclient;


import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

/**
* Simple {@link AsyncHandler} of type {@link Response}
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/org/asynchttpclient/AsyncHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import io.netty.channel.Channel;
import io.netty.handler.codec.http.HttpHeaders;
import org.asynchttpclient.netty.request.NettyRequest;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import javax.net.ssl.SSLSession;
import java.net.InetSocketAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.asynchttpclient.netty.channel.ConnectionSemaphoreFactory;
import org.asynchttpclient.proxy.ProxyServer;
import org.asynchttpclient.proxy.ProxyServerSelector;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.io.IOException;
import java.time.Duration;
Expand Down Expand Up @@ -263,14 +263,12 @@ public interface AsyncHttpClientConfig {
/**
* @return the array of enabled protocols
*/
@Nullable
String[] getEnabledProtocols();
String @Nullable[] getEnabledProtocols();

/**
* @return the array of enabled cipher suites
*/
@Nullable
String[] getEnabledCipherSuites();
String @Nullable[] getEnabledCipherSuites();

/**
* @return if insecure cipher suites must be filtered out (only used when not explicitly passing enabled cipher suites)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.asynchttpclient.handler.resumable.ResumableAsyncHandler;
import org.asynchttpclient.netty.channel.ChannelManager;
import org.asynchttpclient.netty.request.NettyRequestSender;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.asynchttpclient.proxy.ProxyServer;
import org.asynchttpclient.proxy.ProxyServerSelector;
import org.asynchttpclient.util.ProxyUtils;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.time.Duration;
import java.util.Collections;
Expand Down Expand Up @@ -158,8 +158,8 @@ public class DefaultAsyncHttpClientConfig implements AsyncHttpClientConfig {
private final boolean useInsecureTrustManager;
private final boolean disableHttpsEndpointIdentificationAlgorithm;
private final int handshakeTimeout;
private final @Nullable String[] enabledProtocols;
private final @Nullable String[] enabledCipherSuites;
private final String @Nullable[] enabledProtocols;
private final String @Nullable[] enabledCipherSuites;
private final boolean filterInsecureCipherSuites;
private final int sslSessionCacheSize;
private final int sslSessionTimeout;
Expand Down Expand Up @@ -244,8 +244,8 @@ private DefaultAsyncHttpClientConfig(// http
boolean useInsecureTrustManager,
boolean disableHttpsEndpointIdentificationAlgorithm,
int handshakeTimeout,
@Nullable String[] enabledProtocols,
@Nullable String[] enabledCipherSuites,
String @Nullable[] enabledProtocols,
String @Nullable[] enabledCipherSuites,
boolean filterInsecureCipherSuites,
int sslSessionCacheSize,
int sslSessionTimeout,
Expand Down Expand Up @@ -586,12 +586,12 @@ public int getHandshakeTimeout() {
}

@Override
public @Nullable String[] getEnabledProtocols() {
public String @Nullable[] getEnabledProtocols() {
return enabledProtocols;
}

@Override
public @Nullable String[] getEnabledCipherSuites() {
public String @Nullable[] getEnabledCipherSuites() {
return enabledCipherSuites;
}

Expand Down Expand Up @@ -831,8 +831,8 @@ public static class Builder {
private boolean useInsecureTrustManager = defaultUseInsecureTrustManager();
private boolean disableHttpsEndpointIdentificationAlgorithm = defaultDisableHttpsEndpointIdentificationAlgorithm();
private int handshakeTimeout = defaultHandshakeTimeout();
private @Nullable String[] enabledProtocols = defaultEnabledProtocols();
private @Nullable String[] enabledCipherSuites = defaultEnabledCipherSuites();
private String @Nullable[] enabledProtocols = defaultEnabledProtocols();
private String @Nullable[] enabledCipherSuites = defaultEnabledCipherSuites();
private boolean filterInsecureCipherSuites = defaultFilterInsecureCipherSuites();
private int sslSessionCacheSize = defaultSslSessionCacheSize();
private int sslSessionTimeout = defaultSslSessionTimeout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.asynchttpclient.request.body.generator.BodyGenerator;
import org.asynchttpclient.request.body.multipart.Part;
import org.asynchttpclient.uri.Uri;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.io.File;
import java.io.InputStream;
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/org/asynchttpclient/Param.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.asynchttpclient;

import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/org/asynchttpclient/Realm.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.asynchttpclient.util.AuthenticatorUtils;
import org.asynchttpclient.util.StringBuilderPool;
import org.asynchttpclient.util.StringUtils;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.nio.charset.Charset;
import java.security.MessageDigest;
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/org/asynchttpclient/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.asynchttpclient.request.body.generator.BodyGenerator;
import org.asynchttpclient.request.body.multipart.Part;
import org.asynchttpclient.uri.Uri;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.io.File;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.asynchttpclient.uri.Uri;
import org.asynchttpclient.util.EnsuresNonNull;
import org.asynchttpclient.util.UriEncoder;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/org/asynchttpclient/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import io.netty.handler.codec.http.cookie.Cookie;
import org.asynchttpclient.netty.NettyResponse;
import org.asynchttpclient.uri.Uri;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.io.InputStream;
import java.net.SocketAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.asynchttpclient.channel;

import io.netty.channel.Channel;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.util.Map;
import java.util.function.Predicate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.asynchttpclient.proxy.ProxyServer;
import org.asynchttpclient.proxy.ProxyType;
import org.asynchttpclient.uri.Uri;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.asynchttpclient.channel;

import io.netty.channel.Channel;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.util.Collections;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.asynchttpclient.config;

import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -159,11 +159,11 @@ public static String defaultUserAgent() {
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getString(ASYNC_CLIENT_CONFIG_ROOT + USER_AGENT_CONFIG);
}

public static @Nullable String[] defaultEnabledProtocols() {
public static String @Nullable[] defaultEnabledProtocols() {
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getStringArray(ASYNC_CLIENT_CONFIG_ROOT + ENABLED_PROTOCOLS_CONFIG);
}

public static @Nullable String[] defaultEnabledCipherSuites() {
public static String @Nullable[] defaultEnabledCipherSuites() {
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getStringArray(ASYNC_CLIENT_CONFIG_ROOT + ENABLED_CIPHER_SUITES_CONFIG);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.asynchttpclient.config;

import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -105,8 +105,8 @@ public String getString(String key) {
});
}

@Nullable
public String[] getStringArray(String key) {

public String @Nullable[] getStringArray(String key) {
String s = getString(key);
s = s.trim();
if (s.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import io.netty.handler.codec.http.cookie.Cookie;
import org.asynchttpclient.uri.Uri;
import org.asynchttpclient.util.MiscUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;

import java.util.AbstractMap;
import java.util.ArrayList;
Expand Down Expand Up @@ -246,7 +246,7 @@ private static class CookieKey implements Comparable<CookieKey> {
}

@Override
public int compareTo(@NotNull CookieKey cookieKey) {
public int compareTo(@NonNull CookieKey cookieKey) {
requireNonNull(cookieKey, "Parameter can't be null");

int result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.asynchttpclient.AsyncHttpClient;
import org.asynchttpclient.HttpResponseStatus;
import org.asynchttpclient.Request;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.asynchttpclient.HttpResponseBodyPart;
import org.asynchttpclient.HttpResponseStatus;
import org.asynchttpclient.Response;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.io.FilterInputStream;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.asynchttpclient.AsyncHandler;
import org.asynchttpclient.HttpResponseBodyPart;
import org.asynchttpclient.Response;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.asynchttpclient.Response;
import org.asynchttpclient.Response.ResponseBuilder;
import org.asynchttpclient.handler.TransferCompletionHandler;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
package org.asynchttpclient.ntlm;

import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
*/
package org.asynchttpclient.ntlm;


import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

/**
* Signals NTLM protocol failure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.netty.handler.codec.http.HttpHeaders;
import org.asynchttpclient.Realm;
import org.asynchttpclient.Request;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.asynchttpclient.proxy;

import org.asynchttpclient.uri.Uri;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

/**
* Selector for a proxy server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.asynchttpclient.spnego;

import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.ietf.jgss.GSSManager;
import org.ietf.jgss.GSSName;
import org.ietf.jgss.Oid;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.asynchttpclient.spnego;

import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

/**
* Signals SPNEGO protocol failure.
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/org/asynchttpclient/uri/Uri.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.asynchttpclient.uri;

import org.asynchttpclient.util.StringBuilderPool;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.net.URI;
import java.net.URISyntaxException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.asynchttpclient.uri;

import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import static java.util.Objects.requireNonNull;
import static org.asynchttpclient.util.MiscUtils.isNonEmpty;
Expand Down
Loading