File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
main/java/hudson/plugins/jira
test/java/hudson/plugins/jira Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -445,7 +445,13 @@ private Request buildGetRequest(URI uri) {
445445 ProxyConfiguration proxyConfiguration = Jenkins .get ().proxy ;
446446 if ( proxyConfiguration != null ) {
447447 final HttpHost proxyHost = new HttpHost ( proxyConfiguration .name , proxyConfiguration .port );
448- request .viaProxy (proxyHost );
448+
449+ boolean shouldByPassProxy = proxyConfiguration .getNoProxyHostPatterns ().stream ().anyMatch (
450+ it -> it .matcher (uri .getHost ()).matches ()
451+ );
452+
453+ if (!shouldByPassProxy )
454+ request .viaProxy (proxyHost );
449455 }
450456
451457 return request
Original file line number Diff line number Diff line change @@ -63,6 +63,18 @@ public void withProxy() throws Exception {
6363 assertEquals (localPort , proxyHost .getPort ());
6464 }
6565
66+ @ Test
67+ public void withProxyAndNoProxyHosts () throws Exception {
68+ int localPort = connector .getLocalPort ();
69+ Jenkins .get ().proxy = new ProxyConfiguration ("localhost" , localPort );
70+ Jenkins .get ().proxy .setNoProxyHost ("example.com|google.com" );
71+
72+
73+ assertNull (getProxyObjectFromRequest ());
74+
75+ }
76+
77+
6678 @ Test
6779 public void withoutProxy () throws Exception {
6880 assertNull (getProxyObjectFromRequest ());
@@ -76,7 +88,7 @@ private Object getProxyObjectFromRequest()
7688 Method m = service .getClass ().getDeclaredMethod ("buildGetRequest" , URI .class );
7789 m .setAccessible (true );
7890
79- Request buildGetRequestValue = (Request ) m .invoke (service , URI . create ( "" ) );
91+ Request buildGetRequestValue = (Request ) m .invoke (service , JIRA_URI );
8092
8193 assertNotNull (buildGetRequestValue );
8294
You can’t perform that action at this time.
0 commit comments