Skip to content

Commit

Permalink
Now handling that proxy settings can be null because `URLConnection…
Browse files Browse the repository at this point in the history
….openConnection()` and `URLConnection.openConnection(Proxy.NO_PROXY)` don't behave the same
  • Loading branch information
quintesse committed May 6, 2015
1 parent 3c1be3a commit 65b75f1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/com/redhat/ceylon/ceylondoc/LinkRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.io.IOException;
import java.io.Writer;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -781,7 +782,14 @@ private boolean checkHttpUrlExist(String moduleUrl) {
Boolean result = ceylonDocTool.getModuleUrlAvailabilityCache().get(moduleUrl);
if( result == null ) {
try {
HttpURLConnection con = (HttpURLConnection) new URL(moduleUrl + "index.html").openConnection(DefaultToolOptions.getDefaultProxy());
URL url = new URL(moduleUrl + "index.html");
HttpURLConnection con;
Proxy proxy = DefaultToolOptions.getDefaultProxy();
if (proxy != null) {
con = (HttpURLConnection) url.openConnection(proxy);
} else {
con = (HttpURLConnection) url.openConnection();
}
con.setConnectTimeout((int) DefaultToolOptions.getDefaultTimeout());
con.setReadTimeout((int) DefaultToolOptions.getDefaultTimeout() * Constants.READ_TIMEOUT_MULTIPLIER);
con.setRequestMethod("HEAD");
Expand Down

1 comment on commit 65b75f1

@quintesse
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.