aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Yonan2013-09-25 14:24:16 (EDT)
committerGerrit Code Review @ Eclipse.org2014-02-13 18:58:03 (EST)
commit7bb7299e8a815ac7884f429e3bc710e0c27c121c (patch)
tree7bc45ad9126d1890c14c81feef55ca34bb17eed9
parent48e36d8cb335382b99ec829d0dfe34be71ed49bb (diff)
downloadjgit-7bb7299e8a815ac7884f429e3bc710e0c27c121c.zip
jgit-7bb7299e8a815ac7884f429e3bc710e0c27c121c.tar.gz
jgit-7bb7299e8a815ac7884f429e3bc710e0c27c121c.tar.bz2
Fix a NullPointerException if properties file doesn't existrefs/changes/74/16774/2
For example with following URL, amazon-s3://.jgit@mybucket/foo.git if ~/.jgit is missing, jgit command will throw a NullPointerException. With this patch, a reasonable error message will be emitted: fatal: Cannot read file /Users/jamesyonan/.jgit Change-Id: I1d366f2d55e170d2972715c657c8e2d10c8d87d2 Signed-off-by: James Yonan <james@openvpn.net>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportAmazonS3.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportAmazonS3.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportAmazonS3.java
index 0a50fe2..b3a55a5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportAmazonS3.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportAmazonS3.java
@@ -170,8 +170,14 @@ public class TransportAmazonS3 extends HttpTransport implements WalkTransport {
return loadPropertiesFile(propsFile);
Properties props = new Properties();
- props.setProperty("accesskey", uri.getUser()); //$NON-NLS-1$
- props.setProperty("secretkey", uri.getPass()); //$NON-NLS-1$
+ String user = uri.getUser();
+ String pass = uri.getPass();
+ if (user != null && pass != null) {
+ props.setProperty("accesskey", user); //$NON-NLS-1$
+ props.setProperty("secretkey", pass); //$NON-NLS-1$
+ } else
+ throw new NotSupportedException(MessageFormat.format(
+ JGitText.get().cannotReadFile, propsFile));
return props;
}