Skip to content

Commit

Permalink
Fixes issue #1078 (#1079)
Browse files Browse the repository at this point in the history
* Fixes issue #1078
Check the "socksProxyHost" system property not only for null, but also for emptiness

* #1078: Added test and fixed code style issues
  • Loading branch information
JCzogalla authored and davecramer committed Jan 19, 2018
1 parent fe463bc commit 0d51370
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pgjdbc/src/main/java/org/postgresql/util/HostSpec.java
Expand Up @@ -48,7 +48,8 @@ public int hashCode() {
}

public Boolean shouldResolve() {
if (System.getProperty("socksProxyHost") == null) {
String socksProxy = System.getProperty("socksProxyHost");
if (socksProxy == null || socksProxy.trim().isEmpty()) {
return true;
}
return matchesNonProxyHosts();
Expand Down
14 changes: 14 additions & 0 deletions pgjdbc/src/test/java/org/postgresql/test/util/HostSpecTest.java
Expand Up @@ -32,6 +32,20 @@ public void testShouldResolve() throws Exception {
assertTrue(hostSpec.shouldResolve());
}

@Test
public void testShouldResolveWithEmptySocksProxyHost() throws Exception {
System.setProperty("socksProxyHost", "");
HostSpec hostSpec = new HostSpec("localhost", 5432);
assertFalse(hostSpec.shouldResolve());
}

@Test
public void testShouldResolveWithWhiteSpaceSocksProxyHost() throws Exception {
System.setProperty("socksProxyHost", " ");
HostSpec hostSpec = new HostSpec("localhost", 5432);
assertFalse(hostSpec.shouldResolve());
}

@Test
public void testShouldResolveWithSocksProxyHost() throws Exception {
System.setProperty("socksProxyHost", "fake-socks-proxy");
Expand Down

0 comments on commit 0d51370

Please sign in to comment.