[EGIT PATCH 04/31] Document/fix Transport open method for specific case

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Marek Zawirski
Date: Sunday, August 17, 2008 - 1:43 pm

RemoteConfig may have empty URIs list.
It would be nicer to throw documented exception than
ArrayIndexOutOfBoundsException in this case.

Signed-off-by: Marek Zawirski <marek.zawirski@gmail.com>
---
 .../src/org/spearce/jgit/transport/Transport.java  |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/Transport.java b/org.spearce.jgit/src/org/spearce/jgit/transport/Transport.java
index 5bec4d2..30175e3 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/Transport.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/Transport.java
@@ -103,9 +103,16 @@ public abstract class Transport {
 	 * @return the new transport instance. Never null.
 	 * @throws NotSupportedException
 	 *             the protocol specified is not supported.
+	 * @throws IllegalArgumentException
+	 *             if provided remote configuration doesn't have any URI
+	 *             associated.
 	 */
 	public static Transport open(final Repository local, final RemoteConfig cfg)
 			throws NotSupportedException {
+		if (cfg.getURIs().isEmpty())
+			throw new IllegalArgumentException(
+					"Remote config \""
+					+ cfg.getName() + "\" has no URIs associated");
 		final Transport tn = open(local, cfg.getURIs().get(0));
 		tn.setOptionUploadPack(cfg.getUploadPack());
 		tn.fetch = cfg.getFetchRefSpecs();
-- 
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[EGIT PATCH 04/31] Document/fix Transport open method for ..., Marek Zawirski, (Sun Aug 17, 1:43 pm)
[EGIT PATCH 10/31] Improve javadoc of Transport push(), Marek Zawirski, (Sun Aug 17, 1:43 pm)
[EGIT PATCH 17/31] Fix typo in uitext.properties message, Marek Zawirski, (Sun Aug 17, 1:43 pm)
[EGIT PATCH 27/31] Add few EPL Eclipse icons, Marek Zawirski, (Sun Aug 17, 1:44 pm)
[EGIT PATCH 28/31] Checkbox images/screenshots, Marek Zawirski, (Sun Aug 17, 1:44 pm)
[EGIT PATCH 30/31] Add PushOperation to plugin, Marek Zawirski, (Sun Aug 17, 1:44 pm)
[EGIT PATCH 31/31] Push GUI, Marek Zawirski, (Sun Aug 17, 1:44 pm)
Re: [EGIT PATCH 28/31] Checkbox images/screenshots, Robin Rosenberg, (Tue Aug 19, 11:24 am)
[EGIT PATCH 6/6] Fix RefSpecPage formatting, Marek Zawirski, (Tue Aug 19, 7:57 pm)
Git-aware Issue Tracking?, Petr Baudis, (Wed Aug 20, 8:23 am)
Re: Git-aware Issue Tracking?, Shawn O. Pearce, (Wed Aug 20, 9:44 am)
Re: Git-aware Issue Tracking?, Jakub Narebski, (Wed Aug 20, 11:52 am)
Re: Git-aware Issue Tracking?, Mike Dalessio, (Wed Aug 20, 1:22 pm)
Re: Git-aware Issue Tracking?, Robin Rosenberg, (Wed Aug 20, 1:25 pm)
Re: Git-aware Issue Tracking?, Pierre Habouzit, (Thu Aug 21, 1:30 am)
Re: Git-aware Issue Tracking?, Martin Langhoff, (Thu Aug 21, 1:47 am)
Re: Git-aware Issue Tracking?, Imran M Yousuf, (Thu Aug 21, 1:55 am)
Re: Git-aware Issue Tracking?, Jakub Narebski, (Thu Aug 21, 2:23 am)