[EGIT PATCH 04/31] Document/fix Transport open method for specific case
- From
- Marek Zawirski <marek.zawirski@gmail.com>
- Date
- Aug 17, 2008, 20:43 UTC
- Message-ID
- <1219005852-21496-5-git-send-email-marek.zawirski@gmail.com>
- In-Reply-To
- <1219005852-21496-4-git-send-email-marek.zawirski@gmail.com>
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