55
66import java .util .Map ;
77
8+ import javax .annotation .Nonnull ;
9+ import javax .annotation .ParametersAreNonnullByDefault ;
10+
811import org .apache .http .HttpException ;
912import org .apache .http .HttpHost ;
1013import org .apache .http .HttpRequest ;
1114import org .apache .http .conn .routing .HttpRoute ;
1215import org .apache .http .conn .routing .HttpRoutePlanner ;
1316import org .apache .http .protocol .HttpContext ;
1417
18+ @ ParametersAreNonnullByDefault
1519public 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