Im trying to get all http requests that my Java application makes to go through a proxy. Ive set the proxy host and port via system properties
System.setProperty("http.proxyHost", "192.168.1.23")
System.setProperty("http.proxyPort", "8081")
The problem I have is that the application will make http requests even if the proxy isnt available. In fact if I put in any non-valid proxy host property Java seems to ignore the proxy setting and connect directly anyway.
Id like to force all http connections to use these proxy settings and fail (via exception) if it cant connect to the proxy. Any ideas for how I can force this behaviour?
Thanks