Browse Source

Merge branch 'stable-3.3'

* stable-3.3:
  Prepare 3.3.2-SNAPSHOT builds
  JGit v3.3.1.201403241930-r
  Retry to call credentials provider if http authentication failed
  Ensure that ssh authentication is retried only in JGit
  [findBugs] Ensure streams are closed in a finally block
  Update com.jcraft.jsch to 0.1.50 also in pom dependencies

Change-Id: I45b48a3f2dc8c7708e9518645d72bc5645002836
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-3.4
Matthias Sohn 11 years ago
parent
commit
5c1736a8d8
  1. 16
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
  2. 10
      org.eclipse.jgit/src/org/eclipse/jgit/notes/DefaultNoteMerger.java
  3. 3
      org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
  4. 8
      org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java

16
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java

@ -714,26 +714,27 @@ public class GC {
JGitText.get().cannotCreateIndexfile, tmpIdx.getPath()));
// write the packfile
@SuppressWarnings("resource" /* java 7 */)
FileChannel channel = new FileOutputStream(tmpPack).getChannel();
FileOutputStream fos = new FileOutputStream(tmpPack);
FileChannel channel = fos.getChannel();
OutputStream channelStream = Channels.newOutputStream(channel);
try {
pw.writePack(pm, pm, channelStream);
} finally {
channel.force(true);
channelStream.close();
channel.close();
fos.close();
}
// write the packindex
FileChannel idxChannel = new FileOutputStream(tmpIdx).getChannel();
fos = new FileOutputStream(tmpIdx);
FileChannel idxChannel = fos.getChannel();
OutputStream idxStream = Channels.newOutputStream(idxChannel);
try {
pw.writeIndex(idxStream);
} finally {
idxChannel.force(true);
idxStream.close();
idxChannel.close();
fos.close();
}
if (pw.prepareBitmapIndex(pm)) {
@ -745,14 +746,15 @@ public class GC {
JGitText.get().cannotCreateIndexfile,
tmpBitmapIdx.getPath()));
idxChannel = new FileOutputStream(tmpBitmapIdx).getChannel();
fos = new FileOutputStream(tmpBitmapIdx);
idxChannel = fos.getChannel();
idxStream = Channels.newOutputStream(idxChannel);
try {
pw.writeBitmapIndex(idxStream);
} finally {
idxChannel.force(true);
idxStream.close();
idxChannel.close();
fos.close();
}
}

10
org.eclipse.jgit/src/org/eclipse/jgit/notes/DefaultNoteMerger.java

@ -82,8 +82,12 @@ public class DefaultNoteMerger implements NoteMerger {
ObjectLoader lt = reader.open(theirs.getData());
UnionInputStream union = new UnionInputStream(lo.openStream(),
lt.openStream());
ObjectId noteData = inserter.insert(Constants.OBJ_BLOB,
lo.getSize() + lt.getSize(), union);
return new Note(ours, noteData);
try {
ObjectId noteData = inserter.insert(Constants.OBJ_BLOB,
lo.getSize() + lt.getSize(), union);
return new Note(ours, noteData);
} finally {
union.close();
}
}
}

3
org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java

@ -148,6 +148,9 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
FS fs, String user, final String pass, String host, int port,
final OpenSshConfig.Host hc) throws JSchException {
final Session session = createSession(hc, user, host, port, fs);
// We retry already in getSession() method. JSch must not retry
// on its own.
session.setConfig("MaxAuthTries", "1"); //$NON-NLS-1$ //$NON-NLS-2$
if (pass != null)
session.setPassword(pass);
final String strictHostKeyCheckingPolicy = hc

8
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java

@ -471,12 +471,14 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
if (authMethod == HttpAuthMethod.NONE)
throw new TransportException(uri, MessageFormat.format(
JGitText.get().authenticationNotSupported, uri));
if (1 < authAttempts
|| !authMethod.authorize(uri,
getCredentialsProvider())) {
CredentialsProvider credentialsProvider = getCredentialsProvider();
if (3 < authAttempts
|| !authMethod.authorize(uri, credentialsProvider)) {
credentialsProvider.reset(uri);
throw new TransportException(uri,
JGitText.get().notAuthorized);
}
credentialsProvider.reset(uri);
authAttempts++;
continue;

Loading…
Cancel
Save