Skip to content

Commit 6bc6bf8

Browse files
author
Guillaume Lederrey
committed
Adding jsr305 annotations.
Adding annotations so that paramters are non null by default and tagging methods appropriately. Change-Id: Iccb6fde3022f0add1aedaac9112d8ebb236141bc
1 parent cf36aa7 commit 6bc6bf8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

http-client-utils/src/main/java/org/wikimedia/utils/http/CustomRoutePlanner.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55

66
import java.util.Map;
77

8+
import javax.annotation.Nonnull;
9+
import javax.annotation.ParametersAreNonnullByDefault;
10+
811
import org.apache.http.HttpException;
912
import org.apache.http.HttpHost;
1013
import org.apache.http.HttpRequest;
1114
import org.apache.http.conn.routing.HttpRoute;
1215
import org.apache.http.conn.routing.HttpRoutePlanner;
1316
import org.apache.http.protocol.HttpContext;
1417

18+
@ParametersAreNonnullByDefault
1519
public class CustomRoutePlanner implements HttpRoutePlanner {
1620

1721
private final Map<String, HttpHost> customRouteMap;
@@ -27,6 +31,7 @@ public CustomRoutePlanner(Map<String, HttpHost> customRouteMap, HttpRoutePlanner
2731
* separated by commas with no space between them
2832
* for example: www.wikidata.org=http://proxy.local:9999,www.metawiki.org=https://proxy.local:8080
2933
*/
34+
@Nonnull
3035
public static Map<String, HttpHost> createMapFromString(String mapProxyProperty) {
3136
String[] pairs = mapProxyProperty.split(",");
3237
return stream(pairs).map(p -> p.split("=")).
@@ -37,7 +42,7 @@ public void addRoute(String sourceURL, String targetURL) {
3742
customRouteMap.put(sourceURL, HttpHost.create(targetURL));
3843
}
3944

40-
@Override
45+
@Override @Nonnull
4146
public HttpRoute determineRoute(HttpHost httpHost, HttpRequest httpRequest, HttpContext httpContext) throws HttpException {
4247
HttpHost destHost = customRouteMap.get(httpHost.getHostName());
4348
if (destHost != null) {

0 commit comments

Comments
 (0)