@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*
*
*/
*/
package org.apache.tools.ant.util.java15;
package org.apache.tools.ant.util.java15;
@@ -55,14 +55,14 @@ public class ProxyDiagnostics {
public ProxyDiagnostics(String destination) {
public ProxyDiagnostics(String destination) {
this.destination = destination;
this.destination = destination;
try {
try {
this.destURI=new URI(destination);
this.destURI = new URI(destination);
} catch (URISyntaxException e) {
} catch (URISyntaxException e) {
throw new BuildException(e);
throw new BuildException(e);
}
}
}
}
/**
/**
* create a proxy diagnostics tool bound to
* create a proxy diagnostics tool bound to
* {@link #DEFAULT_DESTINATION}
* {@link #DEFAULT_DESTINATION}
*/
*/
public ProxyDiagnostics() {
public ProxyDiagnostics() {
@@ -70,24 +70,24 @@ public class ProxyDiagnostics {
}
}
public String toString() {
public String toString() {
ProxySelector selector=ProxySelector.getDefault();
ProxySelector selector = ProxySelector.getDefault();
List list = selector.select(destURI);
List list = selector.select(destURI);
StringBuffer result=new StringBuffer();
Iterator proxies=list.listIterator();
StringBuffer result = new StringBuffer();
Iterator proxies = list.listIterator();
while (proxies.hasNext()) {
while (proxies.hasNext()) {
Proxy proxy = (Proxy) proxies.next();
Proxy proxy = (Proxy) proxies.next();
SocketAddress address = proxy.address();
SocketAddress address = proxy.address();
if(address==null) {
if (address == null) {
result.append("Direct connection\n");
result.append("Direct connection\n");
} else {
} else {
result.append(proxy.toString());
result.append(proxy.toString());
if(address instanceof InetSocketAddress) {
InetSocketAddress ina=(InetSocketAddress) address;
if (address instanceof InetSocketAddress) {
InetSocketAddress ina = (InetSocketAddress) address;
result.append(' ');
result.append(' ');
result.append(ina.getHostName());
result.append(ina.getHostName());
result.append(':');
result.append(':');
result.append(ina.getPort());
result.append(ina.getPort());
if(ina.isUnresolved()) {
if (ina.isUnresolved()) {
result.append(" [unresolved]");
result.append(" [unresolved]");
} else {
} else {
InetAddress addr = ina.getAddress();
InetAddress addr = ina.getAddress();
@@ -98,7 +98,6 @@ public class ProxyDiagnostics {
}
}
result.append('\n');
result.append('\n');
}
}
}
}
return result.toString();
return result.toString();
}
}