public static URL replacePort(final URL url, final int port) {
		Assert.notNull(url, "the url must not be null");
		try {
			return new URL("http://" + url.getHost() + ":" + port);
		}
		catch (MalformedURLException malformedUrlException) {
			throw new IllegalStateException(malformedUrlException.getMessage(), malformedUrlException);
		}
	}
Substitutes the port associated with the URL with another port.

@param url The URL that needs a port replaced.
@param port The new port number
@return A new URL with the host from the URL passed in and the new port.
spring-xd-integration-test/src/main/java/org/springframework/xd/integration/util/StreamUtils.java