@@ -180,24 +180,20 @@ public void setVirtualHost(String virtualHost) {
180180 * Convenience method for setting the fields in an AMQP URI: host,
181181 * port, username, password and virtual host. If any part of the
182182 * URI is ommited, the ConnectionFactory's corresponding variable
183- * is left unchanged. Note that not all valid AMQP URIs are
184- * accepted; in particular, the hostname must be given if the
185- * port, username or password are given, and escapes in the
186- * hostname are not permitted.
187- * @param uriString is the AMQP URI containing the data
183+ * is left unchanged.
184+ * @param uri is the AMQP URI containing the data
188185 */
189- public void setUri (String uriString )
186+ public void setUri (URI uri )
190187 throws URISyntaxException , NoSuchAlgorithmException , KeyManagementException
191188 {
192- URI uri = new URI (uriString );
193-
194189 if ("amqp" .equals (uri .getScheme ().toLowerCase ())) {
195190 // nothing special to do
196191 } else if ("amqps" .equals (uri .getScheme ().toLowerCase ())) {
197192 setPort (DEFAULT_AMQP_OVER_SSL_PORT );
198193 useSslProtocol ();
199194 } else {
200- throw new IllegalArgumentException ("Wrong scheme in AMQP URI: " + uriString );
195+ throw new IllegalArgumentException ("Wrong scheme in AMQP URI: " +
196+ uri .getScheme ());
201197 }
202198
203199 String host = uri .getHost ();
@@ -214,7 +210,8 @@ public void setUri(String uriString)
214210 if (userInfo != null ) {
215211 String userPass [] = userInfo .split (":" );
216212 if (userPass .length > 2 ) {
217- throw new IllegalArgumentException ("Bad user info in AMQP URI: " + uriString );
213+ throw new IllegalArgumentException ("Bad user info in AMQP " +
214+ "URI: " + userInfo );
218215 }
219216
220217 setUsername (uriDecode (userPass [0 ]));
@@ -226,13 +223,31 @@ public void setUri(String uriString)
226223 String path = uri .getRawPath ();
227224 if (path != null && path .length () > 0 ) {
228225 if (path .indexOf ('/' , 1 ) != -1 ) {
229- throw new IllegalArgumentException ("Multiple segments in path of AMQP URI: " + uriString );
226+ throw new IllegalArgumentException ("Multiple segments in " +
227+ "path of AMQP URI: " +
228+ path );
230229 }
231230
232231 setVirtualHost (uriDecode (uri .getPath ().substring (1 )));
233232 }
234233 }
235234
235+ /**
236+ * Convenience method for setting the fields in an AMQP URI: host,
237+ * port, username, password and virtual host. If any part of the
238+ * URI is ommited, the ConnectionFactory's corresponding variable
239+ * is left unchanged. Note that not all valid AMQP URIs are
240+ * accepted; in particular, the hostname must be given if the
241+ * port, username or password are given, and escapes in the
242+ * hostname are not permitted.
243+ * @param uriString is the AMQP URI containing the data
244+ */
245+ public void setUri (String uriString )
246+ throws URISyntaxException , NoSuchAlgorithmException , KeyManagementException
247+ {
248+ setUri (new URI (uriString ));
249+ }
250+
236251 private String uriDecode (String s ) {
237252 try {
238253 // URLDecode decodes '+' to a space, as for
0 commit comments