aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaServlet.java13
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AdvertiseErrorTest.java18
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/GitServletResponseTests.java40
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java32
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java19
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/MeasurePackSizeTest.java29
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java19
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java20
-rw-r--r--org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/SimpleHttpServer.java17
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java30
-rw-r--r--org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/UploadTest.java12
-rw-r--r--org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java9
-rw-r--r--org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java8
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java16
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java9
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java26
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java8
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java10
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java14
-rw-r--r--org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/auth/BasicAuthentication.java17
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java117
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java16
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/events/ConfigChangeEventTest.java9
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java23
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPackRefsTest.java52
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java17
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java9
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryTest.java31
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftree/RefTreeDatabaseTest.java34
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java13
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ThreadSafeProgressMonitorTest.java43
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java34
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushOptionsTest.java18
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TestProtocolTest.java35
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java107
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java37
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/ListTagCommand.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java14
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheTree.java35
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/KetchLeader.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/LocalReplica.java25
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/RemoteGitReplica.java21
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java23
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java97
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaTask.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java65
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java46
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PostReceiveHook.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PostUploadHook.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PreReceiveHook.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java135
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/RefFilter.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/SshSessionFactory.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java16
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/ReceivePackFactory.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/RepositoryResolver.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/UploadPackFactory.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java19
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/io/IsolatedOutputStream.java36
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/io/ThrowingPrintWriter.java10
74 files changed, 626 insertions, 1097 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaServlet.java
index d8fa712ebf..14b6506ad3 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/MetaServlet.java
@@ -47,7 +47,6 @@ import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
import java.io.IOException;
-import javax.servlet.FilterChain;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -140,14 +139,10 @@ public class MetaServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
- filter.doFilter(req, res, new FilterChain() {
- @Override
- public void doFilter(ServletRequest request,
- ServletResponse response) throws IOException,
- ServletException {
- ((HttpServletResponse) response).sendError(SC_NOT_FOUND);
- }
- });
+ filter.doFilter(req, res,
+ (ServletRequest request, ServletResponse response) -> {
+ ((HttpServletResponse) response).sendError(SC_NOT_FOUND);
+ });
}
/**
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AdvertiseErrorTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AdvertiseErrorTest.java
index 5a46967766..ec9ced0f70 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AdvertiseErrorTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AdvertiseErrorTest.java
@@ -69,7 +69,6 @@ import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.RemoteRefUpdate;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish;
-import org.eclipse.jgit.transport.resolver.RepositoryResolver;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.junit.Before;
@@ -90,18 +89,13 @@ public class AdvertiseErrorTest extends HttpTestCase {
ServletContextHandler app = server.addContext("/git");
GitServlet gs = new GitServlet();
- gs.setRepositoryResolver(new RepositoryResolver<HttpServletRequest>() {
- @Override
- public Repository open(HttpServletRequest req, String name)
- throws RepositoryNotFoundException,
- ServiceNotEnabledException {
- if (!name.equals(srcName))
- throw new RepositoryNotFoundException(name);
-
- final Repository db = src.getRepository();
- db.incrementOpen();
- return db;
+ gs.setRepositoryResolver((HttpServletRequest req, String name) -> {
+ if (!name.equals(srcName)) {
+ throw new RepositoryNotFoundException(name);
}
+ final Repository db = src.getRepository();
+ db.incrementOpen();
+ return db;
});
gs.setReceivePackFactory(new DefaultReceivePackFactory() {
@Override
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/GitServletResponseTests.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/GitServletResponseTests.java
index 8dce98beef..eb19365074 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/GitServletResponseTests.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/GitServletResponseTests.java
@@ -75,7 +75,6 @@ import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.RemoteRefUpdate;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish;
-import org.eclipse.jgit.transport.resolver.RepositoryResolver;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.junit.Before;
@@ -117,18 +116,13 @@ public class GitServletResponseTests extends HttpTestCase {
ServletContextHandler app = server.addContext("/git");
gs = new GitServlet();
- gs.setRepositoryResolver(new RepositoryResolver<HttpServletRequest>() {
- @Override
- public Repository open(HttpServletRequest req, String name)
- throws RepositoryNotFoundException,
- ServiceNotEnabledException {
- if (!name.equals(repoName))
- throw new RepositoryNotFoundException(name);
-
- final Repository db = srv.getRepository();
- db.incrementOpen();
- return db;
+ gs.setRepositoryResolver((HttpServletRequest req, String name) -> {
+ if (!name.equals(repoName)) {
+ throw new RepositoryNotFoundException(name);
}
+ final Repository db = srv.getRepository();
+ db.incrementOpen();
+ return db;
});
gs.setReceivePackFactory(new DefaultReceivePackFactory() {
@Override
@@ -179,12 +173,8 @@ public class GitServletResponseTests extends HttpTestCase {
maxPackSize = 0;
postHook = null;
- preHook = new PreReceiveHook() {
- @Override
- public void onPreReceive(ReceivePack rp,
- Collection<ReceiveCommand> commands) {
- throw new IllegalStateException();
- }
+ preHook = (ReceivePack rp, Collection<ReceiveCommand> commands) -> {
+ throw new IllegalStateException();
};
try (Transport t = Transport.open(clientRepo, srvURI)) {
@@ -263,15 +253,11 @@ public class GitServletResponseTests extends HttpTestCase {
maxPackSize = 100;
// this PostReceiveHook when called after an unsuccesfull unpack will
// lead to an IllegalStateException
- postHook = new PostReceiveHook() {
- @Override
- public void onPostReceive(ReceivePack rp,
- Collection<ReceiveCommand> commands) {
- // the maxPackSize setting caused that the packfile couldn't be
- // saved to disk. Calling getPackSize() now will lead to a
- // IllegalStateException.
- rp.getPackSize();
- }
+ postHook = (ReceivePack rp, Collection<ReceiveCommand> commands) -> {
+ // the maxPackSize setting caused that the packfile couldn't be
+ // saved to disk. Calling getPackSize() now will lead to a
+ // IllegalStateException.
+ rp.getPackSize();
};
try (Transport t = Transport.open(clientRepo, srvURI)) {
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java
index 5a5ff1a8ae..49ff51a5b1 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java
@@ -70,14 +70,12 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.revwalk.RevBlob;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.transport.PreReceiveHook;
import org.eclipse.jgit.transport.PushResult;
import org.eclipse.jgit.transport.ReceiveCommand;
import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.RemoteRefUpdate;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish;
-import org.eclipse.jgit.transport.resolver.RepositoryResolver;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.junit.Before;
@@ -98,18 +96,13 @@ public class HookMessageTest extends HttpTestCase {
ServletContextHandler app = server.addContext("/git");
GitServlet gs = new GitServlet();
- gs.setRepositoryResolver(new RepositoryResolver<HttpServletRequest>() {
- @Override
- public Repository open(HttpServletRequest req, String name)
- throws RepositoryNotFoundException,
- ServiceNotEnabledException {
- if (!name.equals(srcName))
- throw new RepositoryNotFoundException(name);
-
- final Repository db = src.getRepository();
- db.incrementOpen();
- return db;
+ gs.setRepositoryResolver((HttpServletRequest req, String name) -> {
+ if (!name.equals(srcName)) {
+ throw new RepositoryNotFoundException(name);
}
+ final Repository db = src.getRepository();
+ db.incrementOpen();
+ return db;
});
gs.setReceivePackFactory(new DefaultReceivePackFactory() {
@Override
@@ -117,14 +110,11 @@ public class HookMessageTest extends HttpTestCase {
throws ServiceNotEnabledException,
ServiceNotAuthorizedException {
ReceivePack recv = super.create(req, db);
- recv.setPreReceiveHook(new PreReceiveHook() {
- @Override
- public void onPreReceive(ReceivePack rp,
- Collection<ReceiveCommand> commands) {
- rp.sendMessage("message line 1");
- rp.sendError("no soup for you!");
- rp.sendMessage("come back next year!");
- }
+ recv.setPreReceiveHook((ReceivePack rp,
+ Collection<ReceiveCommand> commands) -> {
+ rp.sendMessage("message line 1");
+ rp.sendError("no soup for you!");
+ rp.sendMessage("come back next year!");
});
return recv;
}
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
index 53626b1b2e..1660f14f34 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
@@ -87,8 +87,6 @@ import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.jgit.transport.http.HttpConnection;
import org.eclipse.jgit.transport.http.JDKHttpConnectionFactory;
-import org.eclipse.jgit.transport.resolver.RepositoryResolver;
-import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.junit.Before;
import org.junit.Test;
@@ -141,18 +139,13 @@ public class HttpClientTests extends HttpTestCase {
private ServletContextHandler smart(String path) {
GitServlet gs = new GitServlet();
- gs.setRepositoryResolver(new RepositoryResolver<HttpServletRequest>() {
- @Override
- public Repository open(HttpServletRequest req, String name)
- throws RepositoryNotFoundException,
- ServiceNotEnabledException {
- final Repository db = remoteRepository.getRepository();
- if (!name.equals(nameOf(db)))
- throw new RepositoryNotFoundException(name);
-
- db.incrementOpen();
- return db;
+ gs.setRepositoryResolver((HttpServletRequest req, String name) -> {
+ final Repository db = remoteRepository.getRepository();
+ if (!name.equals(nameOf(db))) {
+ throw new RepositoryNotFoundException(name);
}
+ db.incrementOpen();
+ return db;
});
ServletContextHandler ctx = server.addContext(path);
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/MeasurePackSizeTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/MeasurePackSizeTest.java
index 0415bcbb55..79df5a2ab2 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/MeasurePackSizeTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/MeasurePackSizeTest.java
@@ -63,14 +63,12 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.revwalk.RevBlob;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.transport.PostReceiveHook;
import org.eclipse.jgit.transport.PushResult;
import org.eclipse.jgit.transport.ReceiveCommand;
import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.RemoteRefUpdate;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish;
-import org.eclipse.jgit.transport.resolver.RepositoryResolver;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.junit.Before;
@@ -93,18 +91,13 @@ public class MeasurePackSizeTest extends HttpTestCase {
ServletContextHandler app = server.addContext("/git");
GitServlet gs = new GitServlet();
- gs.setRepositoryResolver(new RepositoryResolver<HttpServletRequest>() {
- @Override
- public Repository open(HttpServletRequest req, String name)
- throws RepositoryNotFoundException,
- ServiceNotEnabledException {
- if (!name.equals(srcName))
- throw new RepositoryNotFoundException(name);
-
- final Repository db = src.getRepository();
- db.incrementOpen();
- return db;
+ gs.setRepositoryResolver((HttpServletRequest req, String name) -> {
+ if (!name.equals(srcName)) {
+ throw new RepositoryNotFoundException(name);
}
+ final Repository db = src.getRepository();
+ db.incrementOpen();
+ return db;
});
gs.setReceivePackFactory(new DefaultReceivePackFactory() {
@Override
@@ -112,13 +105,9 @@ public class MeasurePackSizeTest extends HttpTestCase {
throws ServiceNotEnabledException,
ServiceNotAuthorizedException {
ReceivePack recv = super.create(req, db);
- recv.setPostReceiveHook(new PostReceiveHook() {
-
- @Override
- public void onPostReceive(ReceivePack rp,
- Collection<ReceiveCommand> commands) {
- packSize = rp.getPackSize();
- }
+ recv.setPostReceiveHook((ReceivePack rp,
+ Collection<ReceiveCommand> commands) -> {
+ packSize = rp.getPackSize();
});
return recv;
}
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java
index a1baae3b26..f0fac5ab51 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java
@@ -71,8 +71,6 @@ import org.eclipse.jgit.revwalk.RevBlob;
import org.eclipse.jgit.transport.PacketLineIn;
import org.eclipse.jgit.transport.PacketLineOut;
import org.eclipse.jgit.transport.URIish;
-import org.eclipse.jgit.transport.resolver.RepositoryResolver;
-import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.eclipse.jgit.util.NB;
import org.junit.Before;
import org.junit.Test;
@@ -94,18 +92,13 @@ public class ProtocolErrorTest extends HttpTestCase {
ServletContextHandler app = server.addContext("/git");
GitServlet gs = new GitServlet();
- gs.setRepositoryResolver(new RepositoryResolver<HttpServletRequest>() {
- @Override
- public Repository open(HttpServletRequest req, String name)
- throws RepositoryNotFoundException,
- ServiceNotEnabledException {
- if (!name.equals(srcName))
- throw new RepositoryNotFoundException(name);
-
- final Repository db = src.getRepository();
- db.incrementOpen();
- return db;
+ gs.setRepositoryResolver((HttpServletRequest req, String name) -> {
+ if (!name.equals(srcName)) {
+ throw new RepositoryNotFoundException(name);
}
+ final Repository db = src.getRepository();
+ db.incrementOpen();
+ return db;
});
app.addServlet(new ServletHolder(gs), "/*");
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
index aad029ccfc..54c1c03b50 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
@@ -124,9 +124,6 @@ import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.jgit.transport.http.HttpConnectionFactory;
import org.eclipse.jgit.transport.http.JDKHttpConnectionFactory;
import org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory;
-import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
-import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
-import org.eclipse.jgit.transport.resolver.UploadPackFactory;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.HttpSupport;
import org.eclipse.jgit.util.SystemReader;
@@ -192,18 +189,13 @@ public class SmartClientSmartServerTest extends HttpTestCase {
ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES, true);
GitServlet gs = new GitServlet();
- gs.setUploadPackFactory(new UploadPackFactory<HttpServletRequest>() {
- @Override
- public UploadPack create(HttpServletRequest req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- DefaultUploadPackFactory f = new DefaultUploadPackFactory();
- UploadPack up = f.create(req, db);
- if (advertiseRefsHook != null) {
- up.setAdvertiseRefsHook(advertiseRefsHook);
- }
- return up;
+ gs.setUploadPackFactory((HttpServletRequest req, Repository db) -> {
+ DefaultUploadPackFactory f = new DefaultUploadPackFactory();
+ UploadPack up = f.create(req, db);
+ if (advertiseRefsHook != null) {
+ up.setAdvertiseRefsHook(advertiseRefsHook);
}
+ return up;
});
ServletContextHandler app = addNormalContext(gs, src, srcName);
diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/SimpleHttpServer.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/SimpleHttpServer.java
index 245b510fe1..7c78330828 100644
--- a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/SimpleHttpServer.java
+++ b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/SimpleHttpServer.java
@@ -54,8 +54,6 @@ import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.http.server.GitServlet;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.URIish;
-import org.eclipse.jgit.transport.resolver.RepositoryResolver;
-import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
/**
* Simple http server for testing http access to Git repositories.
@@ -136,17 +134,12 @@ public class SimpleHttpServer {
private ServletContextHandler smart(String path) {
GitServlet gs = new GitServlet();
- gs.setRepositoryResolver(new RepositoryResolver<HttpServletRequest>() {
- @Override
- public Repository open(HttpServletRequest req, String name)
- throws RepositoryNotFoundException,
- ServiceNotEnabledException {
- if (!name.equals(nameOf(db)))
- throw new RepositoryNotFoundException(name);
-
- db.incrementOpen();
- return db;
+ gs.setRepositoryResolver((HttpServletRequest req, String name) -> {
+ if (!name.equals(nameOf(db))) {
+ throw new RepositoryNotFoundException(name);
}
+ db.incrementOpen();
+ return db;
});
ServletContextHandler ctx = server.addContext(path);
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java
index 8de386e344..89f2530a31 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java
@@ -171,22 +171,20 @@ public class MockSystemReader extends SystemReader {
/** {@inheritDoc} */
@Override
public MonotonicClock getClock() {
- return new MonotonicClock() {
- @Override
- public ProposedTimestamp propose() {
- long t = getCurrentTime();
- return new ProposedTimestamp() {
- @Override
- public long read(TimeUnit unit) {
- return unit.convert(t, TimeUnit.MILLISECONDS);
- }
-
- @Override
- public void blockUntil(Duration maxWait) {
- // Do not wait.
- }
- };
- }
+ return () -> {
+ long t = getCurrentTime();
+ return new ProposedTimestamp() {
+
+ @Override
+ public long read(TimeUnit unit) {
+ return unit.convert(t, TimeUnit.MILLISECONDS);
+ }
+
+ @Override
+ public void blockUntil(Duration maxWait) {
+ // Do not wait.
+ }
+ };
};
}
diff --git a/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/UploadTest.java b/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/UploadTest.java
index 09f8d0aeaf..c6f9535564 100644
--- a/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/UploadTest.java
+++ b/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/UploadTest.java
@@ -53,7 +53,6 @@ import java.nio.file.Paths;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.Callable;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -123,13 +122,10 @@ public class UploadTest extends LfsServerTest {
ExecutorService e = Executors.newFixedThreadPool(count);
try {
for (Path p : paths) {
- e.submit(new Callable<Void>() {
- @Override
- public Void call() throws Exception {
- barrier.await();
- putContent(p);
- return null;
- }
+ e.submit(() -> {
+ barrier.await();
+ putContent(p);
+ return null;
});
}
} finally {
diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java
index 217e46f48e..80da802db4 100644
--- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java
+++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java
@@ -78,14 +78,7 @@ public class CleanFilter extends FilterCommand {
* The factory is responsible for creating instances of
* {@link org.eclipse.jgit.lfs.CleanFilter}
*/
- public final static FilterCommandFactory FACTORY = new FilterCommandFactory() {
-
- @Override
- public FilterCommand create(Repository db, InputStream in,
- OutputStream out) throws IOException {
- return new CleanFilter(db, in, out);
- }
- };
+ public final static FilterCommandFactory FACTORY = CleanFilter::new;
/**
* Registers this filter by calling
diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java
index 7bacf49269..6b30da343e 100644
--- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java
+++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java
@@ -92,13 +92,7 @@ public class SmudgeFilter extends FilterCommand {
* The factory is responsible for creating instances of
* {@link org.eclipse.jgit.lfs.SmudgeFilter}
*/
- public final static FilterCommandFactory FACTORY = new FilterCommandFactory() {
- @Override
- public FilterCommand create(Repository db, InputStream in,
- OutputStream out) throws IOException {
- return new SmudgeFilter(db, in, out);
- }
- };
+ public final static FilterCommandFactory FACTORY = SmudgeFilter::new;
/**
* Register this filter in JGit
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
index 47eb156c55..e07fdd50d2 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
@@ -60,7 +60,6 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -703,15 +702,12 @@ public class ArchiveTest extends CLIRepositoryTestCase {
private static Future<Object> writeAsync(OutputStream stream, byte[] data) {
ExecutorService executor = Executors.newSingleThreadExecutor();
- return executor.submit(new Callable<Object>() {
- @Override
- public Object call() throws IOException {
- try {
- stream.write(data);
- return null;
- } finally {
- stream.close();
- }
+ return executor.submit(() -> {
+ try {
+ stream.write(data);
+ return null;
+ } finally {
+ stream.close();
}
});
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java
index b98bf151a5..dab52f6ce9 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java
@@ -52,7 +52,6 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
@@ -115,12 +114,8 @@ public class CommandCatalog {
private static CommandRef[] toSortedArray(Collection<CommandRef> c) {
final CommandRef[] r = c.toArray(new CommandRef[0]);
- Arrays.sort(r, new Comparator<CommandRef>() {
- @Override
- public int compare(CommandRef o1, CommandRef o2) {
- return o1.getName().compareTo(o2.getName());
- }
- });
+ Arrays.sort(r, (CommandRef o1, CommandRef o2) -> o1.getName()
+ .compareTo(o2.getName()));
return r;
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java
index 319b5e39dc..43826636aa 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java
@@ -66,7 +66,6 @@ import org.eclipse.jgit.transport.DaemonService;
import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.resolver.FileResolver;
import org.eclipse.jgit.transport.resolver.ReceivePackFactory;
-import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.eclipse.jgit.util.FS;
import org.kohsuke.args4j.Argument;
@@ -188,22 +187,17 @@ class Daemon extends TextBuiltin {
final ReceivePackFactory<DaemonClient> factory;
factory = daemon.getReceivePackFactory();
- daemon.setReceivePackFactory(new ReceivePackFactory<DaemonClient>() {
- @Override
- public ReceivePack create(DaemonClient req, Repository repo)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- ReceivePack rp = factory.create(req, repo);
- KetchLeader leader;
- try {
- leader = leaders.get(repo);
- } catch (URISyntaxException err) {
- throw new ServiceNotEnabledException(
- KetchText.get().invalidFollowerUri, err);
- }
- rp.setPreReceiveHook(new KetchPreReceive(leader));
- return rp;
+ daemon.setReceivePackFactory((DaemonClient req, Repository repo) -> {
+ ReceivePack rp = factory.create(req, repo);
+ KetchLeader leader;
+ try {
+ leader = leaders.get(repo);
+ } catch (URISyntaxException err) {
+ throw new ServiceNotEnabledException(
+ KetchText.get().invalidFollowerUri, err);
}
+ rp.setPreReceiveHook(new KetchPreReceive(leader));
+ return rp;
});
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java
index 2b5af5d7b7..00bbfb788b 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java
@@ -47,7 +47,6 @@ package org.eclipse.jgit.pgm;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
@@ -87,11 +86,8 @@ class Glog extends RevWalkTextBuiltin {
final JPanel buttons = new JPanel(new FlowLayout());
final JButton repaint = new JButton();
repaint.setText(CLIText.get().repaint);
- repaint.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- graphPane.repaint();
- }
+ repaint.addActionListener((ActionEvent e) -> {
+ graphPane.repaint();
});
buttons.add(repaint);
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
index 1c2564dd7c..708fcde683 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
@@ -46,7 +46,6 @@
package org.eclipse.jgit.pgm;
import java.io.IOException;
-import java.util.Comparator;
import java.util.TreeSet;
import org.eclipse.jgit.api.Git;
@@ -76,13 +75,8 @@ class LsRemote extends TextBuiltin {
protected void run() {
LsRemoteCommand command = Git.lsRemoteRepository().setRemote(remote)
.setTimeout(timeout).setHeads(heads).setTags(tags);
- TreeSet<Ref> refs = new TreeSet<>(new Comparator<Ref>() {
-
- @Override
- public int compare(Ref r1, Ref r2) {
- return r1.getName().compareTo(r2.getName());
- }
- });
+ TreeSet<Ref> refs = new TreeSet<>(
+ (Ref r1, Ref r2) -> r1.getName().compareTo(r2.getName()));
try {
refs.addAll(command.call());
for (Ref r : refs) {
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java
index 6165c0aeed..85a74448f7 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java
@@ -52,7 +52,6 @@ import java.lang.management.ThreadMXBean;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import org.eclipse.jgit.diff.DiffAlgorithm;
@@ -235,15 +234,12 @@ class DiffAlgorithms extends TextBuiltin {
}
}
- Collections.sort(all, new Comparator<Test>() {
- @Override
- public int compare(Test a, Test b) {
- int result = Long.signum(a.runningTimeNanos - b.runningTimeNanos);
- if (result == 0) {
- result = a.algorithm.name.compareTo(b.algorithm.name);
- }
- return result;
+ Collections.sort(all, (Test a, Test b) -> {
+ int result = Long.signum(a.runningTimeNanos - b.runningTimeNanos);
+ if (result == 0) {
+ result = a.algorithm.name.compareTo(b.algorithm.name);
}
+ return result;
});
File directory = repo.getDirectory();
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/auth/BasicAuthentication.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/auth/BasicAuthentication.java
index a257a5ebc8..6fa528daf5 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/auth/BasicAuthentication.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/auth/BasicAuthentication.java
@@ -145,18 +145,13 @@ public abstract class BasicAuthentication<ParameterType, TokenType>
*/
protected void askCredentials() {
clearPassword();
- PasswordAuthentication auth = AccessController
- .doPrivileged(new PrivilegedAction<PasswordAuthentication>() {
-
- @Override
- public PasswordAuthentication run() {
- return Authenticator.requestPasswordAuthentication(
- proxy.getHostString(), proxy.getAddress(),
- proxy.getPort(), SshConstants.SSH_SCHEME,
+ PasswordAuthentication auth = AccessController.doPrivileged(
+ (PrivilegedAction<PasswordAuthentication>) () -> Authenticator
+ .requestPasswordAuthentication(proxy.getHostString(),
+ proxy.getAddress(), proxy.getPort(),
+ SshConstants.SSH_SCHEME,
SshdText.get().proxyPasswordPrompt, "Basic", //$NON-NLS-1$
- null, RequestorType.PROXY);
- }
- });
+ null, RequestorType.PROXY));
if (auth == null) {
user = ""; //$NON-NLS-1$
throw new CancellationException(
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
index 9461c42500..2fd378842f 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
@@ -346,14 +346,11 @@ public class PullCommandTest extends RepositoryTestCase {
@Test
/** global rebase config should be respected */
public void testPullWithRebasePreserve1Config() throws Exception {
- Callable<PullResult> setup = new Callable<PullResult>() {
- @Override
- public PullResult call() throws Exception {
- StoredConfig config = dbTarget.getConfig();
- config.setString("pull", null, "rebase", "preserve");
- config.save();
- return target.pull().call();
- }
+ Callable<PullResult> setup = () -> {
+ StoredConfig config = dbTarget.getConfig();
+ config.setString("pull", null, "rebase", "preserve");
+ config.save();
+ return target.pull().call();
};
doTestPullWithRebase(setup, TestPullMode.REBASE_PREASERVE);
}
@@ -361,15 +358,12 @@ public class PullCommandTest extends RepositoryTestCase {
@Test
/** the branch-local config should win over the global config */
public void testPullWithRebasePreserveConfig2() throws Exception {
- Callable<PullResult> setup = new Callable<PullResult>() {
- @Override
- public PullResult call() throws Exception {
- StoredConfig config = dbTarget.getConfig();
- config.setString("pull", null, "rebase", "false");
- config.setString("branch", "master", "rebase", "preserve");
- config.save();
- return target.pull().call();
- }
+ Callable<PullResult> setup = () -> {
+ StoredConfig config = dbTarget.getConfig();
+ config.setString("pull", null, "rebase", "false");
+ config.setString("branch", "master", "rebase", "preserve");
+ config.save();
+ return target.pull().call();
};
doTestPullWithRebase(setup, TestPullMode.REBASE_PREASERVE);
}
@@ -377,14 +371,11 @@ public class PullCommandTest extends RepositoryTestCase {
@Test
/** the branch-local config should be respected */
public void testPullWithRebasePreserveConfig3() throws Exception {
- Callable<PullResult> setup = new Callable<PullResult>() {
- @Override
- public PullResult call() throws Exception {
- StoredConfig config = dbTarget.getConfig();
- config.setString("branch", "master", "rebase", "preserve");
- config.save();
- return target.pull().call();
- }
+ Callable<PullResult> setup = () -> {
+ StoredConfig config = dbTarget.getConfig();
+ config.setString("branch", "master", "rebase", "preserve");
+ config.save();
+ return target.pull().call();
};
doTestPullWithRebase(setup, TestPullMode.REBASE_PREASERVE);
}
@@ -392,14 +383,11 @@ public class PullCommandTest extends RepositoryTestCase {
@Test
/** global rebase config should be respected */
public void testPullWithRebaseConfig1() throws Exception {
- Callable<PullResult> setup = new Callable<PullResult>() {
- @Override
- public PullResult call() throws Exception {
- StoredConfig config = dbTarget.getConfig();
- config.setString("pull", null, "rebase", "true");
- config.save();
- return target.pull().call();
- }
+ Callable<PullResult> setup = () -> {
+ StoredConfig config = dbTarget.getConfig();
+ config.setString("pull", null, "rebase", "true");
+ config.save();
+ return target.pull().call();
};
doTestPullWithRebase(setup, TestPullMode.REBASE);
}
@@ -407,15 +395,12 @@ public class PullCommandTest extends RepositoryTestCase {
@Test
/** the branch-local config should win over the global config */
public void testPullWithRebaseConfig2() throws Exception {
- Callable<PullResult> setup = new Callable<PullResult>() {
- @Override
- public PullResult call() throws Exception {
- StoredConfig config = dbTarget.getConfig();
- config.setString("pull", null, "rebase", "preserve");
- config.setString("branch", "master", "rebase", "true");
- config.save();
- return target.pull().call();
- }
+ Callable<PullResult> setup = () -> {
+ StoredConfig config = dbTarget.getConfig();
+ config.setString("pull", null, "rebase", "preserve");
+ config.setString("branch", "master", "rebase", "true");
+ config.save();
+ return target.pull().call();
};
doTestPullWithRebase(setup, TestPullMode.REBASE);
}
@@ -423,14 +408,11 @@ public class PullCommandTest extends RepositoryTestCase {
@Test
/** the branch-local config should be respected */
public void testPullWithRebaseConfig3() throws Exception {
- Callable<PullResult> setup = new Callable<PullResult>() {
- @Override
- public PullResult call() throws Exception {
- StoredConfig config = dbTarget.getConfig();
- config.setString("branch", "master", "rebase", "true");
- config.save();
- return target.pull().call();
- }
+ Callable<PullResult> setup = () -> {
+ StoredConfig config = dbTarget.getConfig();
+ config.setString("branch", "master", "rebase", "true");
+ config.save();
+ return target.pull().call();
};
doTestPullWithRebase(setup, TestPullMode.REBASE);
}
@@ -438,27 +420,19 @@ public class PullCommandTest extends RepositoryTestCase {
@Test
/** without config it should merge */
public void testPullWithoutConfig() throws Exception {
- Callable<PullResult> setup = new Callable<PullResult>() {
- @Override
- public PullResult call() throws Exception {
- return target.pull().call();
- }
- };
+ Callable<PullResult> setup = target.pull()::call;
doTestPullWithRebase(setup, TestPullMode.MERGE);
}
@Test
/** the branch local config should win over the global config */
public void testPullWithMergeConfig() throws Exception {
- Callable<PullResult> setup = new Callable<PullResult>() {
- @Override
- public PullResult call() throws Exception {
- StoredConfig config = dbTarget.getConfig();
- config.setString("pull", null, "rebase", "true");
- config.setString("branch", "master", "rebase", "false");
- config.save();
- return target.pull().call();
- }
+ Callable<PullResult> setup = () -> {
+ StoredConfig config = dbTarget.getConfig();
+ config.setString("pull", null, "rebase", "true");
+ config.setString("branch", "master", "rebase", "false");
+ config.save();
+ return target.pull().call();
};
doTestPullWithRebase(setup, TestPullMode.MERGE);
}
@@ -466,14 +440,11 @@ public class PullCommandTest extends RepositoryTestCase {
@Test
/** the branch local config should win over the global config */
public void testPullWithMergeConfig2() throws Exception {
- Callable<PullResult> setup = new Callable<PullResult>() {
- @Override
- public PullResult call() throws Exception {
- StoredConfig config = dbTarget.getConfig();
- config.setString("pull", null, "rebase", "false");
- config.save();
- return target.pull().call();
- }
+ Callable<PullResult> setup = () -> {
+ StoredConfig config = dbTarget.getConfig();
+ config.setString("pull", null, "rebase", "false");
+ config.save();
+ return target.pull().call();
};
doTestPullWithRebase(setup, TestPullMode.MERGE);
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java
index b284771e58..0c1131ba86 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java
@@ -210,12 +210,8 @@ public class DirCacheBuilderTest extends RepositoryTestCase {
boolean receivedEvent = false;
DirCache dc = db.lockDirCache();
- IndexChangedListener listener = new IndexChangedListener() {
-
- @Override
- public void onIndexChanged(IndexChangedEvent event) {
- throw new ReceivedEventMarkerException();
- }
+ IndexChangedListener listener = (IndexChangedEvent event) -> {
+ throw new ReceivedEventMarkerException();
};
ListenerList l = db.getListenerList();
@@ -238,12 +234,8 @@ public class DirCacheBuilderTest extends RepositoryTestCase {
// do the same again, as this doesn't change index compared to first
// round we should get no event this time
dc = db.lockDirCache();
- listener = new IndexChangedListener() {
-
- @Override
- public void onIndexChanged(IndexChangedEvent event) {
- throw new ReceivedEventMarkerException();
- }
+ listener = (IndexChangedEvent event) -> {
+ throw new ReceivedEventMarkerException();
};
l = db.getListenerList();
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/events/ConfigChangeEventTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/events/ConfigChangeEventTest.java
index 3624100671..b6f312dfec 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/events/ConfigChangeEventTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/events/ConfigChangeEventTest.java
@@ -54,12 +54,9 @@ public class ConfigChangeEventTest extends RepositoryTestCase {
@Test
public void testFileRepository_ChangeEventsOnlyOnSave() throws Exception {
final ConfigChangedEvent[] events = new ConfigChangedEvent[1];
- db.getListenerList().addConfigChangedListener(
- new ConfigChangedListener() {
- @Override
- public void onConfigChanged(ConfigChangedEvent event) {
- events[0] = event;
- }
+ db.getListenerList()
+ .addConfigChangedListener((ConfigChangedEvent event) -> {
+ events[0] = event;
});
FileBasedConfig config = db.getConfig();
assertNull(events[0]);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java
index 05f7c65fa8..9e7d41a693 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java
@@ -239,20 +239,15 @@ public class GcConcurrentTest extends GcTestCase {
SampleDataRepositoryTestCase.copyCGitTestPacks(repo);
ExecutorService executor = Executors.newSingleThreadExecutor();
final CountDownLatch latch = new CountDownLatch(1);
- Future<Collection<PackFile>> result = executor
- .submit(new Callable<Collection<PackFile>>() {
-
- @Override
- public Collection<PackFile> call() throws Exception {
- long start = System.currentTimeMillis();
- System.out.println("starting gc");
- latch.countDown();
- Collection<PackFile> r = gc.gc();
- System.out.println("gc took "
- + (System.currentTimeMillis() - start) + " ms");
- return r;
- }
- });
+ Future<Collection<PackFile>> result = executor.submit(() -> {
+ long start = System.currentTimeMillis();
+ System.out.println("starting gc");
+ latch.countDown();
+ Collection<PackFile> r = gc.gc();
+ System.out.println(
+ "gc took " + (System.currentTimeMillis() - start) + " ms");
+ return r;
+ });
try {
latch.await();
Thread.sleep(5);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPackRefsTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPackRefsTest.java
index 9289e5a67b..1fa5aa09ad 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPackRefsTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPackRefsTest.java
@@ -155,38 +155,32 @@ public class GcPackRefsTest extends GcTestCase {
final CyclicBarrier packRefsDone = new CyclicBarrier(2);
ExecutorService pool = Executors.newFixedThreadPool(2);
try {
- Future<Result> result = pool.submit(new Callable<Result>() {
-
- @Override
- public Result call() throws Exception {
- RefUpdate update = new RefDirectoryUpdate(
- (RefDirectory) repo.getRefDatabase(),
- repo.exactRef("refs/tags/t")) {
- @Override
- public boolean isForceUpdate() {
- try {
- refUpdateLockedRef.await();
- packRefsDone.await();
- } catch (InterruptedException | BrokenBarrierException e) {
- Thread.currentThread().interrupt();
- }
- return super.isForceUpdate();
+ Future<Result> result = pool.submit(() -> {
+ RefUpdate update = new RefDirectoryUpdate(
+ (RefDirectory) repo.getRefDatabase(),
+ repo.exactRef("refs/tags/t")) {
+ @Override
+ public boolean isForceUpdate() {
+ try {
+ refUpdateLockedRef.await();
+ packRefsDone.await();
+ } catch (InterruptedException
+ | BrokenBarrierException e) {
+ Thread.currentThread().interrupt();
}
- };
- update.setForceUpdate(true);
- update.setNewObjectId(b);
- return update.update();
- }
+ return super.isForceUpdate();
+ }
+ };
+ update.setForceUpdate(true);
+ update.setNewObjectId(b);
+ return update.update();
});
- pool.submit(new Callable<Void>() {
- @Override
- public Void call() throws Exception {
- refUpdateLockedRef.await();
- gc.packRefs();
- packRefsDone.await();
- return null;
- }
+ pool.submit(() -> {
+ refUpdateLockedRef.await();
+ gc.packRefs();
+ packRefsDone.await();
+ return null;
});
assertSame(result.get(), Result.FORCED);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java
index a3a302d81a..a9d0dc20e6 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java
@@ -47,7 +47,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.File;
-import java.io.FilenameFilter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.MessageFormat;
@@ -167,12 +166,8 @@ public class ObjectDirectoryTest extends RepositoryTestCase {
// Bug. To show the bug we sleep for more than 2500ms
Thread.sleep(2600);
- File[] ret = packsFolder.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(".pack");
- }
- });
+ File[] ret = packsFolder.listFiles(
+ (File dir, String name) -> name.endsWith(".pack"));
assertTrue(ret != null && ret.length == 1);
Assume.assumeTrue(tmpFile.lastModified() == ret[0].lastModified());
@@ -220,12 +215,8 @@ public class ObjectDirectoryTest extends RepositoryTestCase {
private Collection<Callable<ObjectId>> blobInsertersForTheSameFanOutDir(
final ObjectDirectory dir) {
- Callable<ObjectId> callable = new Callable<ObjectId>() {
- @Override
- public ObjectId call() throws Exception {
- return dir.newInserter().insert(Constants.OBJ_BLOB, new byte[0]);
- }
- };
+ Callable<ObjectId> callable = () -> dir.newInserter()
+ .insert(Constants.OBJ_BLOB, new byte[0]);
return Collections.nCopies(4, callable);
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java
index ca4486256b..5d0a7e2a0b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java
@@ -60,7 +60,6 @@ import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -881,12 +880,8 @@ public class PackWriterTest extends SampleDataRepositoryTestCase {
for (MutableEntry me : pack) {
entries.add(me.cloneEntry());
}
- Collections.sort(entries, new Comparator<PackIndex.MutableEntry>() {
- @Override
- public int compare(MutableEntry o1, MutableEntry o2) {
- return Long.signum(o1.getOffset() - o2.getOffset());
- }
- });
+ Collections.sort(entries, (MutableEntry o1, MutableEntry o2) -> Long
+ .signum(o1.getOffset() - o2.getOffset()));
int i = 0;
for (MutableEntry me : entries) {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryTest.java
index 7b3684c865..bd9572b113 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryTest.java
@@ -70,7 +70,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jgit.errors.LockFailedException;
import org.eclipse.jgit.events.ListenerHandle;
import org.eclipse.jgit.events.RefsChangedEvent;
-import org.eclipse.jgit.events.RefsChangedListener;
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.AnyObjectId;
@@ -570,12 +569,8 @@ public class RefDirectoryTest extends LocalDiskRepositoryTestCase {
final int[] count = new int[1];
ListenerHandle listener = Repository.getGlobalListenerList()
- .addRefsChangedListener(new RefsChangedListener() {
-
- @Override
- public void onRefsChanged(RefsChangedEvent event) {
- count[0]++;
- }
+ .addRefsChangedListener((RefsChangedEvent event) -> {
+ count[0]++;
});
refs = refdir.getRefs(RefDatabase.ALL);
@@ -1316,19 +1311,15 @@ public class RefDirectoryTest extends LocalDiskRepositoryTestCase {
final AtomicReference<StackOverflowError> error = new AtomicReference<>();
final AtomicReference<IOException> exception = new AtomicReference<>();
final AtomicInteger changeCount = new AtomicInteger();
- newRepo.getListenerList().addRefsChangedListener(
- new RefsChangedListener() {
-
- @Override
- public void onRefsChanged(RefsChangedEvent event) {
- try {
- refDb.getRefsByPrefix("ref");
- changeCount.incrementAndGet();
- } catch (StackOverflowError soe) {
- error.set(soe);
- } catch (IOException ioe) {
- exception.set(ioe);
- }
+ newRepo.getListenerList()
+ .addRefsChangedListener((RefsChangedEvent event) -> {
+ try {
+ refDb.getRefsByPrefix("ref");
+ changeCount.incrementAndGet();
+ } catch (StackOverflowError soe) {
+ error.set(soe);
+ } catch (IOException ioe) {
+ exception.set(ioe);
}
});
refDb.getRefsByPrefix("ref");
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftree/RefTreeDatabaseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftree/RefTreeDatabaseTest.java
index 8ef21e6da7..c3f5baa67b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftree/RefTreeDatabaseTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftree/RefTreeDatabaseTest.java
@@ -633,35 +633,23 @@ public class RefTreeDatabaseTest {
private void symref(String name, String dst)
throws IOException {
- commit(new Function() {
- @Override
- public boolean apply(ObjectReader reader, RefTree tree)
- throws IOException {
- Ref old = tree.exactRef(reader, name);
- Command n = new Command(
- old,
- new SymbolicRef(
- name,
- new ObjectIdRef.Unpeeled(Ref.Storage.NEW, dst, null)));
- return tree.apply(Collections.singleton(n));
- }
+ commit((ObjectReader reader, RefTree tree) -> {
+ Ref old = tree.exactRef(reader, name);
+ Command n = new Command(old, new SymbolicRef(name,
+ new ObjectIdRef.Unpeeled(Ref.Storage.NEW, dst, null)));
+ return tree.apply(Collections.singleton(n));
});
}
private void update(String name, ObjectId id)
throws IOException {
- commit(new Function() {
- @Override
- public boolean apply(ObjectReader reader, RefTree tree)
- throws IOException {
- Ref old = tree.exactRef(reader, name);
- Command n;
- try (RevWalk rw = new RevWalk(repo)) {
- n = new Command(old,
- Command.toRef(rw, id, null, name, true));
- }
- return tree.apply(Collections.singleton(n));
+ commit((ObjectReader reader, RefTree tree) -> {
+ Ref old = tree.exactRef(reader, name);
+ Command n;
+ try (RevWalk rw = new RevWalk(repo)) {
+ n = new Command(old, Command.toRef(rw, id, null, name, true));
}
+ return tree.apply(Collections.singleton(n));
});
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java
index 16ad70d383..e7a5b286dd 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java
@@ -1775,16 +1775,13 @@ public class ObjectCheckerTest {
}
private static ObjectIdSet set(ObjectId... ids) {
- return new ObjectIdSet() {
- @Override
- public boolean contains(AnyObjectId objectId) {
- for (ObjectId id : ids) {
- if (id.equals(objectId)) {
- return true;
- }
+ return (AnyObjectId objectId) -> {
+ for (ObjectId id : ids) {
+ if (id.equals(objectId)) {
+ return true;
}
- return false;
}
+ return false;
};
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ThreadSafeProgressMonitorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ThreadSafeProgressMonitorTest.java
index 545a188a98..682982226e 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ThreadSafeProgressMonitorTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ThreadSafeProgressMonitorTest.java
@@ -61,29 +61,26 @@ public class ThreadSafeProgressMonitorTest {
final MockProgressMonitor mock = new MockProgressMonitor();
final ThreadSafeProgressMonitor pm = new ThreadSafeProgressMonitor(mock);
- runOnThread(new Runnable() {
- @Override
- public void run() {
- try {
- pm.start(1);
- fail("start did not fail on background thread");
- } catch (IllegalStateException notMainThread) {
- // Expected result
- }
-
- try {
- pm.beginTask("title", 1);
- fail("beginTask did not fail on background thread");
- } catch (IllegalStateException notMainThread) {
- // Expected result
- }
-
- try {
- pm.endTask();
- fail("endTask did not fail on background thread");
- } catch (IllegalStateException notMainThread) {
- // Expected result
- }
+ runOnThread(() -> {
+ try {
+ pm.start(1);
+ fail("start did not fail on background thread");
+ } catch (IllegalStateException notMainThread) {
+ // Expected result
+ }
+
+ try {
+ pm.beginTask("title", 1);
+ fail("beginTask did not fail on background thread");
+ } catch (IllegalStateException notMainThread) {
+ // Expected result
+ }
+
+ try {
+ pm.endTask();
+ fail("endTask did not fail on background thread");
+ } catch (IllegalStateException notMainThread) {
+ // Expected result
}
});
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java
index cea432e34c..89d02d7527 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java
@@ -67,9 +67,6 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.transport.resolver.ReceivePackFactory;
-import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
-import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -91,27 +88,16 @@ public class PushConnectionTest {
server = newRepo("server");
client = newRepo("client");
processedRefs = new ArrayList<>();
- testProtocol = new TestProtocol<>(
- null,
- new ReceivePackFactory<Object>() {
- @Override
- public ReceivePack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- ReceivePack rp = new ReceivePack(db);
- rp.setPreReceiveHook(
- new PreReceiveHook() {
- @Override
- public void onPreReceive(ReceivePack receivePack,
- Collection<ReceiveCommand> cmds) {
- for (ReceiveCommand cmd : cmds) {
- processedRefs.add(cmd.getRefName());
- }
- }
- });
- return rp;
- }
- });
+ testProtocol = new TestProtocol<>(null, (Object req, Repository db) -> {
+ ReceivePack rp = new ReceivePack(db);
+ rp.setPreReceiveHook((ReceivePack receivePack,
+ Collection<ReceiveCommand> cmds) -> {
+ for (ReceiveCommand cmd : cmds) {
+ processedRefs.add(cmd.getRefName());
+ }
+ });
+ return rp;
+ });
uri = testProtocol.register(ctx, server);
try (ObjectInserter ins = server.newObjectInserter()) {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushOptionsTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushOptionsTest.java
index f26201d56d..fd1c3bf8b8 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushOptionsTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushOptionsTest.java
@@ -69,9 +69,6 @@ import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.transport.resolver.ReceivePackFactory;
-import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
-import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -95,16 +92,11 @@ public class PushOptionsTest extends RepositoryTestCase {
client = newRepo("client");
testProtocol = new TestProtocol<>(null,
- new ReceivePackFactory<Object>() {
- @Override
- public ReceivePack create(Object req, Repository git)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- receivePack = new ReceivePack(git);
- receivePack.setAllowPushOptions(true);
- receivePack.setAtomic(true);
- return receivePack;
- }
+ (Object req, Repository git) -> {
+ receivePack = new ReceivePack(git);
+ receivePack.setAllowPushOptions(true);
+ receivePack.setAtomic(true);
+ return receivePack;
});
uri = testProtocol.register(ctx, server);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TestProtocolTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TestProtocolTest.java
index 1c4d0cfe24..f4c55aa50a 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TestProtocolTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TestProtocolTest.java
@@ -92,11 +92,8 @@ public class TestProtocolTest {
@Override
public UploadPack create(User req, Repository db) {
UploadPack up = new UploadPack(db);
- up.setPostUploadHook(new PostUploadHook() {
- @Override
- public void onPostUpload(PackStatistics stats) {
- havesCount = stats.getHaves();
- }
+ up.setPostUploadHook((PackStatistics stats) -> {
+ havesCount = stats.getHaves();
});
return up;
}
@@ -217,16 +214,12 @@ public class TestProtocolTest {
ObjectId master = remote.branch("master").commit().create();
final AtomicInteger rejected = new AtomicInteger();
- TestProtocol<User> proto = registerProto(new UploadPackFactory<User>() {
- @Override
- public UploadPack create(User req, Repository db)
- throws ServiceNotAuthorizedException {
- if (!"user2".equals(req.name)) {
- rejected.incrementAndGet();
- throw new ServiceNotAuthorizedException();
- }
- return new UploadPack(db);
+ TestProtocol<User> proto = registerProto((User req, Repository db) -> {
+ if (!"user2".equals(req.name)) {
+ rejected.incrementAndGet();
+ throw new ServiceNotAuthorizedException();
}
+ return new UploadPack(db);
}, new DefaultReceive());
// Same repository, different users.
@@ -262,16 +255,12 @@ public class TestProtocolTest {
final AtomicInteger rejected = new AtomicInteger();
TestProtocol<User> proto = registerProto(new DefaultUpload(),
- new ReceivePackFactory<User>() {
- @Override
- public ReceivePack create(User req, Repository db)
- throws ServiceNotAuthorizedException {
- if (!"user2".equals(req.name)) {
- rejected.incrementAndGet();
- throw new ServiceNotAuthorizedException();
- }
- return new ReceivePack(db);
+ (User req, Repository db) -> {
+ if (!"user2".equals(req.name)) {
+ rejected.incrementAndGet();
+ throw new ServiceNotAuthorizedException();
}
+ return new ReceivePack(db);
});
// Same repository, different users.
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
index 9fd7483787..9ffcbccc8f 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
@@ -47,9 +47,6 @@ import org.eclipse.jgit.revwalk.RevTag;
import org.eclipse.jgit.revwalk.RevTree;
import org.eclipse.jgit.storage.pack.PackStatistics;
import org.eclipse.jgit.transport.UploadPack.RequestPolicy;
-import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
-import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
-import org.eclipse.jgit.transport.resolver.UploadPackFactory;
import org.eclipse.jgit.util.io.NullOutputStream;
import org.hamcrest.Matchers;
import org.junit.After;
@@ -102,17 +99,11 @@ public class UploadPackTest {
}
private static TestProtocol<Object> generateReachableCommitUploadPackProtocol() {
- return new TestProtocol<>(
- new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- up.setRequestPolicy(RequestPolicy.REACHABLE_COMMIT);
- return up;
- }
- }, null);
+ return new TestProtocol<>((Object req, Repository db) -> {
+ UploadPack up = new UploadPack(db);
+ up.setRequestPolicy(RequestPolicy.REACHABLE_COMMIT);
+ return up;
+ }, null);
}
@Test
@@ -122,20 +113,14 @@ public class UploadPackTest {
RevCommit tip = remote.commit().message("2").parent(commit1).create();
remote.update("master", tip);
- testProtocol = new TestProtocol<>(
- new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- up.setRequestPolicy(RequestPolicy.REACHABLE_COMMIT);
- // assume client has a shallow commit
- up.getRevWalk().assumeShallow(
- Collections.singleton(commit1.getId()));
- return up;
- }
- }, null);
+ testProtocol = new TestProtocol<>((Object req, Repository db) -> {
+ UploadPack up = new UploadPack(db);
+ up.setRequestPolicy(RequestPolicy.REACHABLE_COMMIT);
+ // assume client has a shallow commit
+ up.getRevWalk()
+ .assumeShallow(Collections.singleton(commit1.getId()));
+ return up;
+ }, null);
uri = testProtocol.register(ctx, server);
assertFalse(client.getObjectDatabase().has(commit0.toObjectId()));
@@ -222,14 +207,9 @@ public class UploadPackTest {
server2.getConfig().setBoolean("uploadpack", null, "allowfilter",
true);
- testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- return up;
- }
+ testProtocol = new TestProtocol<>((Object req, Repository db) -> {
+ UploadPack up = new UploadPack(db);
+ return up;
}, null);
uri = testProtocol.register(ctx, server2);
@@ -260,14 +240,9 @@ public class UploadPackTest {
server2.getConfig().setBoolean("uploadpack", null, "allowfilter",
true);
- testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- return up;
- }
+ testProtocol = new TestProtocol<>((Object req, Repository db) -> {
+ UploadPack up = new UploadPack(db);
+ return up;
}, null);
uri = testProtocol.register(ctx, server2);
@@ -297,14 +272,9 @@ public class UploadPackTest {
server2.getConfig().setBoolean("uploadpack", null, "allowfilter",
true);
- testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- return up;
- }
+ testProtocol = new TestProtocol<>((Object req, Repository db) -> {
+ UploadPack up = new UploadPack(db);
+ return up;
}, null);
uri = testProtocol.register(ctx, server2);
@@ -340,14 +310,9 @@ public class UploadPackTest {
new DfsGarbageCollector(server2).pack(null);
server2.scanForRepoChanges();
- testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- return up;
- }
+ testProtocol = new TestProtocol<>((Object req, Repository db) -> {
+ UploadPack up = new UploadPack(db);
+ return up;
}, null);
uri = testProtocol.register(ctx, server2);
@@ -380,14 +345,9 @@ public class UploadPackTest {
new DfsGarbageCollector(server2).pack(null);
server2.scanForRepoChanges();
- testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- return up;
- }
+ testProtocol = new TestProtocol<>((Object req, Repository db) -> {
+ UploadPack up = new UploadPack(db);
+ return up;
}, null);
uri = testProtocol.register(ctx, server2);
@@ -416,14 +376,9 @@ public class UploadPackTest {
server2.getConfig().setBoolean("uploadpack", null, "allowfilter",
false);
- testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- return up;
- }
+ testProtocol = new TestProtocol<>((Object req, Repository db) -> {
+ UploadPack up = new UploadPack(db);
+ return up;
}, null);
uri = testProtocol.register(ctx, server2);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java
index 6f61912f2b..0303ea2404 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java
@@ -582,26 +582,23 @@ public class FileTreeIteratorTest extends RepositoryTestCase {
}
}
- private final FileTreeIterator.FileModeStrategy NO_GITLINKS_STRATEGY =
- new FileTreeIterator.FileModeStrategy() {
- @Override
- public FileMode getMode(File f, FS.Attributes attributes) {
- if (attributes.isSymbolicLink()) {
- return FileMode.SYMLINK;
- } else if (attributes.isDirectory()) {
- // NOTE: in the production DefaultFileModeStrategy, there is
- // a check here for a subdirectory called '.git', and if it
- // exists, we create a GITLINK instead of recursing into the
- // tree. In this custom strategy, we ignore nested git dirs
- // and treat all directories the same.
- return FileMode.TREE;
- } else if (attributes.isExecutable()) {
- return FileMode.EXECUTABLE_FILE;
- } else {
- return FileMode.REGULAR_FILE;
- }
- }
- };
+ private final FileTreeIterator.FileModeStrategy NO_GITLINKS_STRATEGY = (
+ File f, FS.Attributes attributes) -> {
+ if (attributes.isSymbolicLink()) {
+ return FileMode.SYMLINK;
+ } else if (attributes.isDirectory()) {
+ // NOTE: in the production DefaultFileModeStrategy, there is
+ // a check here for a subdirectory called '.git', and if it
+ // exists, we create a GITLINK instead of recursing into the
+ // tree. In this custom strategy, we ignore nested git dirs
+ // and treat all directories the same.
+ return FileMode.TREE;
+ } else if (attributes.isExecutable()) {
+ return FileMode.EXECUTABLE_FILE;
+ } else {
+ return FileMode.REGULAR_FILE;
+ }
+ };
private Repository createNestedRepo() throws IOException {
File gitdir = createUniqueTestGitDir(false);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java
index 831865a2db..9ebcf9fd0f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java
@@ -402,12 +402,8 @@ public class DescribeCommand extends GitCommand<String> {
if (candidates.isEmpty())
return null;
- Candidate best = Collections.min(candidates, new Comparator<Candidate>() {
- @Override
- public int compare(Candidate o1, Candidate o2) {
- return o1.depth - o2.depth;
- }
- });
+ Candidate best = Collections.min(candidates,
+ (Candidate o1, Candidate o2) -> o1.depth - o2.depth);
return best.describe(target);
} catch (IOException e) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java
index 29a51a0f02..e0eafc7533 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java
@@ -53,7 +53,6 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import org.eclipse.jgit.api.errors.GitAPIException;
@@ -134,12 +133,8 @@ public class ListBranchCommand extends GitCommand<List<Ref>> {
throw new JGitInternalException(e.getMessage(), e);
}
- Collections.sort(resultRefs, new Comparator<Ref>() {
- @Override
- public int compare(Ref o1, Ref o2) {
- return o1.getName().compareTo(o2.getName());
- }
- });
+ Collections.sort(resultRefs,
+ (Ref o1, Ref o2) -> o1.getName().compareTo(o2.getName()));
setCallable(false);
return resultRefs;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListTagCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ListTagCommand.java
index 01c1991846..c894d056a0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListTagCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ListTagCommand.java
@@ -45,7 +45,6 @@ package org.eclipse.jgit.api;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import org.eclipse.jgit.api.errors.GitAPIException;
@@ -87,12 +86,8 @@ public class ListTagCommand extends GitCommand<List<Ref>> {
} catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e);
}
- Collections.sort(tags, new Comparator<Ref>() {
- @Override
- public int compare(Ref o1, Ref o2) {
- return o1.getName().compareTo(o2.getName());
- }
- });
+ Collections.sort(tags,
+ (Ref o1, Ref o2) -> o1.getName().compareTo(o2.getName()));
setCallable(false);
return tags;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
index 667634f7f8..eeab03d011 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
@@ -111,14 +111,12 @@ public class DirCache {
private static final byte[] NO_CHECKSUM = {};
- static final Comparator<DirCacheEntry> ENT_CMP = new Comparator<DirCacheEntry>() {
- @Override
- public int compare(DirCacheEntry o1, DirCacheEntry o2) {
- final int cr = cmp(o1, o2);
- if (cr != 0)
- return cr;
- return o1.getStage() - o2.getStage();
- }
+ static final Comparator<DirCacheEntry> ENT_CMP = (DirCacheEntry o1,
+ DirCacheEntry o2) -> {
+ final int cr = cmp(o1, o2);
+ if (cr != 0)
+ return cr;
+ return o1.getStage() - o2.getStage();
};
static int cmp(DirCacheEntry a, DirCacheEntry b) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java
index 74ba97fb8d..5b8e11f330 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java
@@ -75,13 +75,11 @@ import org.eclipse.jgit.util.Paths;
* @see DirCacheBuilder
*/
public class DirCacheEditor extends BaseDirCacheEditor {
- private static final Comparator<PathEdit> EDIT_CMP = new Comparator<PathEdit>() {
- @Override
- public int compare(PathEdit o1, PathEdit o2) {
- final byte[] a = o1.path;
- final byte[] b = o2.path;
- return cmp(a, a.length, b, b.length);
- }
+ private static final Comparator<PathEdit> EDIT_CMP = (PathEdit o1,
+ PathEdit o2) -> {
+ final byte[] a = o1.path;
+ final byte[] b = o2.path;
+ return cmp(a, a.length, b, b.length);
};
private final List<PathEdit> edits;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheTree.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheTree.java
index 11a3474a35..80e1084fe0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheTree.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheTree.java
@@ -81,25 +81,26 @@ public class DirCacheTree {
private static final DirCacheTree[] NO_CHILDREN = {};
- private static final Comparator<DirCacheTree> TREE_CMP = new Comparator<DirCacheTree>() {
- @Override
- public int compare(DirCacheTree o1, DirCacheTree o2) {
- final byte[] a = o1.encodedName;
- final byte[] b = o2.encodedName;
- final int aLen = a.length;
- final int bLen = b.length;
- int cPos;
- for (cPos = 0; cPos < aLen && cPos < bLen; cPos++) {
- final int cmp = (a[cPos] & 0xff) - (b[cPos] & 0xff);
- if (cmp != 0)
- return cmp;
+ private static final Comparator<DirCacheTree> TREE_CMP = (DirCacheTree o1,
+ DirCacheTree o2) -> {
+ final byte[] a = o1.encodedName;
+ final byte[] b = o2.encodedName;
+ final int aLen = a.length;
+ final int bLen = b.length;
+ int cPos;
+ for (cPos = 0; cPos < aLen && cPos < bLen; cPos++) {
+ final int cmp = (a[cPos] & 0xff) - (b[cPos] & 0xff);
+ if (cmp != 0) {
+ return cmp;
}
- if (aLen == bLen)
- return 0;
- if (aLen < bLen)
- return '/' - (b[cPos] & 0xff);
- return (a[cPos] & 0xff) - '/';
}
+ if (aLen == bLen) {
+ return 0;
+ }
+ if (aLen < bLen) {
+ return '/' - (b[cPos] & 0xff);
+ }
+ return (a[cPos] & 0xff) - '/';
};
/** Tree this tree resides in; null if we are the root. */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/KetchLeader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/KetchLeader.java
index fa32b267df..c0364acdd1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/KetchLeader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/KetchLeader.java
@@ -385,12 +385,7 @@ public abstract class KetchLeader {
private void scheduleLeader() {
idle = false;
- system.getExecutor().execute(new Runnable() {
- @Override
- public void run() {
- runLeader();
- }
- });
+ system.getExecutor().execute(this::runLeader);
}
private void runLeader() {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/LocalReplica.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/LocalReplica.java
index 6f1f5c5c2c..cd0ded5e38 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/LocalReplica.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/LocalReplica.java
@@ -123,21 +123,18 @@ public class LocalReplica extends KetchReplica {
/** {@inheritDoc} */
@Override
protected void startPush(ReplicaPushRequest req) {
- getSystem().getExecutor().execute(new Runnable() {
- @Override
- public void run() {
- MonotonicClock clk = getSystem().getClock();
- try (Repository git = getLeader().openRepository();
- ProposedTimestamp ts = clk.propose()) {
- try {
- update(git, req, ts);
- req.done(git);
- } catch (Throwable err) {
- req.setException(git, err);
- }
- } catch (IOException err) {
- req.setException(null, err);
+ getSystem().getExecutor().execute(() -> {
+ MonotonicClock clk = getSystem().getClock();
+ try (Repository git = getLeader().openRepository();
+ ProposedTimestamp ts = clk.propose()) {
+ try {
+ update(git, req, ts);
+ req.done(git);
+ } catch (Throwable err) {
+ req.setException(git, err);
}
+ } catch (IOException err) {
+ req.setException(null, err);
}
});
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/RemoteGitReplica.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/RemoteGitReplica.java
index b61274ef4a..3c9b187c47 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/RemoteGitReplica.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/RemoteGitReplica.java
@@ -139,19 +139,16 @@ public class RemoteGitReplica extends KetchReplica {
/** {@inheritDoc} */
@Override
protected void startPush(ReplicaPushRequest req) {
- getSystem().getExecutor().execute(new Runnable() {
- @Override
- public void run() {
- try (Repository git = getLeader().openRepository()) {
- try {
- push(git, req);
- req.done(git);
- } catch (Throwable err) {
- req.setException(git, err);
- }
- } catch (IOException err) {
- req.setException(null, err);
+ getSystem().getExecutor().execute(() -> {
+ try (Repository git = getLeader().openRepository()) {
+ try {
+ push(git, req);
+ req.done(git);
+ } catch (Throwable err) {
+ req.setException(git, err);
}
+ } catch (IOException err) {
+ req.setException(null, err);
}
});
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java
index 127ee6bf11..6f3f2bd8e7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java
@@ -469,12 +469,8 @@ public class DfsPackCompactor {
continue SCAN;
want.add(new ObjectIdWithOffset(id, ent.getOffset()));
}
- Collections.sort(want, new Comparator<ObjectIdWithOffset>() {
- @Override
- public int compare(ObjectIdWithOffset a, ObjectIdWithOffset b) {
- return Long.signum(a.offset - b.offset);
- }
- });
+ Collections.sort(want, (ObjectIdWithOffset a,
+ ObjectIdWithOffset b) -> Long.signum(a.offset - b.offset));
return want;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java
index 1a5553d7a8..c75b88f3bd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java
@@ -287,14 +287,12 @@ public class DfsReader extends ObjectReader implements ObjectReuseAsIs {
return Collections.emptySet();
}
- private static final Comparator<FoundObject<?>> FOUND_OBJECT_SORT = new Comparator<FoundObject<?>>() {
- @Override
- public int compare(FoundObject<?> a, FoundObject<?> b) {
- int cmp = a.packIndex - b.packIndex;
- if (cmp == 0)
- cmp = Long.signum(a.offset - b.offset);
- return cmp;
- }
+ private static final Comparator<FoundObject<?>> FOUND_OBJECT_SORT = (
+ FoundObject<?> a, FoundObject<?> b) -> {
+ int cmp = a.packIndex - b.packIndex;
+ if (cmp == 0)
+ cmp = Long.signum(a.offset - b.offset);
+ return cmp;
};
private static class FoundObject<T extends ObjectId> {
@@ -565,12 +563,9 @@ public class DfsReader extends ObjectReader implements ObjectReuseAsIs {
return new DfsObjectToPack(objectId, type);
}
- private static final Comparator<DfsObjectToPack> OFFSET_SORT = new Comparator<DfsObjectToPack>() {
- @Override
- public int compare(DfsObjectToPack a, DfsObjectToPack b) {
- return Long.signum(a.getOffset() - b.getOffset());
- }
- };
+ private static final Comparator<DfsObjectToPack> OFFSET_SORT = (
+ DfsObjectToPack a,
+ DfsObjectToPack b) -> Long.signum(a.getOffset() - b.getOffset());
@Override
public void selectObjectRepresentation(PackWriter packer,
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
index 5ced68646f..d82d29e4cf 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
@@ -62,8 +62,6 @@ import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.attributes.AttributesNode;
import org.eclipse.jgit.attributes.AttributesNodeProvider;
import org.eclipse.jgit.errors.ConfigInvalidException;
-import org.eclipse.jgit.events.ConfigChangedEvent;
-import org.eclipse.jgit.events.ConfigChangedListener;
import org.eclipse.jgit.events.IndexChangedEvent;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.storage.file.ObjectDirectory.AlternateHandle;
@@ -206,12 +204,7 @@ public class FileRepository extends Repository {
loadUserConfig();
loadRepoConfig();
- repoConfig.addChangeListener(new ConfigChangedListener() {
- @Override
- public void onConfigChanged(ConfigChangedEvent event) {
- fireEvent(event);
- }
- });
+ repoConfig.addChangeListener(this::fireEvent);
final long repositoryFormatVersion = getConfig().getLong(
ConfigConstants.CONFIG_CORE_SECTION, null,
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
index f0ee22d57a..a4fc1a2ac4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
@@ -116,12 +116,8 @@ public class LockFile {
}
/** Filter to skip over active lock files when listing a directory. */
- static final FilenameFilter FILTER = new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return !name.endsWith(LOCK_SUFFIX);
- }
- };
+ static final FilenameFilter FILTER = (File dir,
+ String name) -> !name.endsWith(LOCK_SUFFIX);
private final File ref;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
index eff7958748..9941ff3740 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
@@ -45,7 +45,6 @@ package org.eclipse.jgit.internal.storage.file;
import java.text.MessageFormat;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
@@ -133,12 +132,8 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
for (int i = 0; i < entries.size(); i++) {
positionEntries.add(new PositionEntry(entries.get(i), i));
}
- Collections.sort(entries, new Comparator<ObjectToPack>() {
- @Override
- public int compare(ObjectToPack a, ObjectToPack b) {
- return Long.signum(a.getOffset() - b.getOffset());
- }
- });
+ Collections.sort(entries, (ObjectToPack a, ObjectToPack b) -> Long
+ .signum(a.getOffset() - b.getOffset()));
for (int i = 0; i < entries.size(); i++) {
PositionEntry e = positionEntries.get(entries.get(i));
e.offsetPosition = i;
@@ -310,57 +305,55 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
public Iterable<StoredEntry> getCompressedBitmaps() {
// Add order is from oldest to newest. The reverse add order is the
// output order.
- return new Iterable<StoredEntry>() {
+ return () -> new Iterator<StoredEntry>() {
+
+ private int index = byAddOrder.size() - 1;
+
@Override
- public Iterator<StoredEntry> iterator() {
- return new Iterator<StoredEntry>() {
- private int index = byAddOrder.size() - 1;
+ public boolean hasNext() {
+ return index >= 0;
+ }
- @Override
- public boolean hasNext() {
- return index >= 0;
+ @Override
+ public StoredEntry next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ StoredBitmap item = byAddOrder.get(index);
+ int bestXorOffset = 0;
+ EWAHCompressedBitmap bestBitmap = item.getBitmap();
+
+ // Attempt to compress the bitmap with an XOR of the
+ // previously written entries.
+ for (int i = 1; i <= MAX_XOR_OFFSET_SEARCH; i++) {
+ int curr = i + index;
+ if (curr >= byAddOrder.size()) {
+ break;
}
- @Override
- public StoredEntry next() {
- if (!hasNext())
- throw new NoSuchElementException();
- StoredBitmap item = byAddOrder.get(index);
- int bestXorOffset = 0;
- EWAHCompressedBitmap bestBitmap = item.getBitmap();
-
- // Attempt to compress the bitmap with an XOR of the
- // previously written entries.
- for (int i = 1; i <= MAX_XOR_OFFSET_SEARCH; i++) {
- int curr = i + index;
- if (curr >= byAddOrder.size())
- break;
-
- StoredBitmap other = byAddOrder.get(curr);
- EWAHCompressedBitmap bitmap = other.getBitmap()
- .xor(item.getBitmap());
-
- if (bitmap.sizeInBytes()
- < bestBitmap.sizeInBytes()) {
- bestBitmap = bitmap;
- bestXorOffset = i;
- }
- }
- index--;
-
- PositionEntry entry = positionEntries.get(item);
- if (entry == null)
- throw new IllegalStateException();
- bestBitmap.trim();
- return new StoredEntry(entry.namePosition, bestBitmap,
- bestXorOffset, item.getFlags());
- }
+ StoredBitmap other = byAddOrder.get(curr);
+ EWAHCompressedBitmap bitmap = other.getBitmap()
+ .xor(item.getBitmap());
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
+ if (bitmap.sizeInBytes() < bestBitmap.sizeInBytes()) {
+ bestBitmap = bitmap;
+ bestXorOffset = i;
}
- };
+ }
+ index--;
+
+ PositionEntry entry = positionEntries.get(item);
+ if (entry == null) {
+ throw new IllegalStateException();
+ }
+ bestBitmap.trim();
+ return new StoredEntry(entry.namePosition, bestBitmap,
+ bestXorOffset, item.getFlags());
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
}
};
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
index d834b1a729..c1aac23726 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
@@ -101,12 +101,8 @@ import org.eclipse.jgit.util.RawParseUtils;
*/
public class PackFile implements Iterable<PackIndex.MutableEntry> {
/** Sorts PackFiles to be most recently created to least recently created. */
- public static final Comparator<PackFile> SORT = new Comparator<PackFile>() {
- @Override
- public int compare(PackFile a, PackFile b) {
- return b.packLastModified - a.packLastModified;
- }
- };
+ public static final Comparator<PackFile> SORT = (PackFile a,
+ PackFile b) -> b.packLastModified - a.packLastModified;
private final File packFile;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaTask.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaTask.java
index 0347644324..a211d164c4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaTask.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaTask.java
@@ -46,7 +46,6 @@ package org.eclipse.jgit.internal.storage.pack;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -212,12 +211,8 @@ final class DeltaTask implements Callable<Object> {
}
// Sort by starting index to identify gaps later.
- Collections.sort(topPaths, new Comparator<WeightedPath>() {
- @Override
- public int compare(WeightedPath a, WeightedPath b) {
- return a.slice.beginIndex - b.slice.beginIndex;
- }
- });
+ Collections.sort(topPaths, (WeightedPath a,
+ WeightedPath b) -> a.slice.beginIndex - b.slice.beginIndex);
bytesPerUnit = 1;
while (MAX_METER <= (totalWeight / bytesPerUnit)) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
index b6e6a6c497..2f7e1a656a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
@@ -62,7 +62,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -1418,32 +1417,33 @@ public class PackWriter implements AutoCloseable {
// applies "Linus' Law" which states that newer files tend to be the
// bigger ones, because source files grow and hardly ever shrink.
//
- Arrays.sort(list, 0, cnt, new Comparator<ObjectToPack>() {
- @Override
- public int compare(ObjectToPack a, ObjectToPack b) {
- int cmp = (a.isDoNotDelta() ? 1 : 0)
- - (b.isDoNotDelta() ? 1 : 0);
- if (cmp != 0)
- return cmp;
-
- cmp = a.getType() - b.getType();
- if (cmp != 0)
- return cmp;
-
- cmp = (a.getPathHash() >>> 1) - (b.getPathHash() >>> 1);
- if (cmp != 0)
- return cmp;
-
- cmp = (a.getPathHash() & 1) - (b.getPathHash() & 1);
- if (cmp != 0)
- return cmp;
-
- cmp = (a.isEdge() ? 0 : 1) - (b.isEdge() ? 0 : 1);
- if (cmp != 0)
- return cmp;
-
- return b.getWeight() - a.getWeight();
+ Arrays.sort(list, 0, cnt, (ObjectToPack a, ObjectToPack b) -> {
+ int cmp = (a.isDoNotDelta() ? 1 : 0) - (b.isDoNotDelta() ? 1 : 0);
+ if (cmp != 0) {
+ return cmp;
}
+
+ cmp = a.getType() - b.getType();
+ if (cmp != 0) {
+ return cmp;
+ }
+
+ cmp = (a.getPathHash() >>> 1) - (b.getPathHash() >>> 1);
+ if (cmp != 0) {
+ return cmp;
+ }
+
+ cmp = (a.getPathHash() & 1) - (b.getPathHash() & 1);
+ if (cmp != 0) {
+ return cmp;
+ }
+
+ cmp = (a.isEdge() ? 0 : 1) - (b.isEdge() ? 0 : 1);
+ if (cmp != 0) {
+ return cmp;
+ }
+
+ return b.getWeight() - a.getWeight();
});
// Above we stored the objects we cannot delta onto the end.
@@ -1564,14 +1564,11 @@ public class PackWriter implements AutoCloseable {
// asynchronous execution. Wrap everything and hope it
// can schedule these for us.
for (DeltaTask task : taskBlock.tasks) {
- executor.execute(new Runnable() {
- @Override
- public void run() {
- try {
- task.call();
- } catch (Throwable failure) {
- errors.add(failure);
- }
+ executor.execute(() -> {
+ try {
+ task.call();
+ } catch (Throwable failure) {
+ errors.add(failure);
}
});
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java
index 99db74956c..d3b5e128d1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java
@@ -91,12 +91,9 @@ class PackWriterBitmapPreparer {
private static final int DAY_IN_SECONDS = 24 * 60 * 60;
- private static final Comparator<RevCommit> ORDER_BY_REVERSE_TIMESTAMP = new Comparator<RevCommit>() {
- @Override
- public int compare(RevCommit a, RevCommit b) {
- return Integer.signum(b.getCommitTime() - a.getCommitTime());
- }
- };
+ private static final Comparator<RevCommit> ORDER_BY_REVERSE_TIMESTAMP = (
+ RevCommit a, RevCommit b) -> Integer
+ .signum(b.getCommitTime() - a.getCommitTime());
private final ObjectReader reader;
private final ProgressMonitor pm;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
index f37c310752..42d1330af9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
@@ -352,12 +352,7 @@ public class IndexDiff {
public WorkingTreeIterator getWorkingTreeIterator(Repository repo);
}
- private WorkingTreeIteratorFactory wTreeIt = new WorkingTreeIteratorFactory() {
- @Override
- public WorkingTreeIterator getWorkingTreeIterator(Repository repo) {
- return new FileTreeIterator(repo);
- }
- };
+ private WorkingTreeIteratorFactory wTreeIt = FileTreeIterator::new;
/**
* Allows higher layers to set the factory for WorkingTreeIterators.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
index b242f98ef7..aac63e9d24 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
@@ -1277,11 +1277,8 @@ public abstract class Repository implements AutoCloseable {
CorruptObjectException, IOException {
// we want DirCache to inform us so that we can inform registered
// listeners about index changes
- IndexChangedListener l = new IndexChangedListener() {
- @Override
- public void onIndexChanged(IndexChangedEvent event) {
- notifyIndexChanged(true);
- }
+ IndexChangedListener l = (IndexChangedEvent event) -> {
+ notifyIndexChanged(true);
};
return DirCache.lock(this, l);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
index 400342b1bd..27befba5a4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
@@ -255,14 +255,11 @@ public class RepositoryCache {
if (delay == RepositoryCacheConfig.NO_CLEANUP) {
return;
}
- cleanupTask = scheduler.scheduleWithFixedDelay(new Runnable() {
- @Override
- public void run() {
- try {
- cache.clearAllExpired();
- } catch (Throwable e) {
- LOG.error(e.getMessage(), e);
- }
+ cleanupTask = scheduler.scheduleWithFixedDelay(() -> {
+ try {
+ cache.clearAllExpired();
+ } catch (Throwable e) {
+ LOG.error(e.getMessage(), e);
}
}, delay, delay, TimeUnit.MILLISECONDS);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java
index 7289ce7b6c..2b27df2b84 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java
@@ -115,36 +115,26 @@ public class Daemon {
repositoryResolver = (RepositoryResolver<DaemonClient>) RepositoryResolver.NONE;
- uploadPackFactory = new UploadPackFactory<DaemonClient>() {
- @Override
- public UploadPack create(DaemonClient req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- up.setTimeout(getTimeout());
- up.setPackConfig(getPackConfig());
- return up;
- }
+ uploadPackFactory = (DaemonClient req, Repository db) -> {
+ UploadPack up = new UploadPack(db);
+ up.setTimeout(getTimeout());
+ up.setPackConfig(getPackConfig());
+ return up;
};
- receivePackFactory = new ReceivePackFactory<DaemonClient>() {
- @Override
- public ReceivePack create(DaemonClient req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- ReceivePack rp = new ReceivePack(db);
-
- InetAddress peer = req.getRemoteAddress();
- String host = peer.getCanonicalHostName();
- if (host == null)
- host = peer.getHostAddress();
- String name = "anonymous"; //$NON-NLS-1$
- String email = name + "@" + host; //$NON-NLS-1$
- rp.setRefLogIdent(new PersonIdent(name, email));
- rp.setTimeout(getTimeout());
-
- return rp;
- }
+ receivePackFactory = (DaemonClient req, Repository db) -> {
+ ReceivePack rp = new ReceivePack(db);
+
+ InetAddress peer = req.getRemoteAddress();
+ String host = peer.getCanonicalHostName();
+ if (host == null)
+ host = peer.getHostAddress();
+ String name = "anonymous"; //$NON-NLS-1$
+ String email = name + "@" + host; //$NON-NLS-1$
+ rp.setRefLogIdent(new PersonIdent(name, email));
+ rp.setTimeout(getTimeout());
+
+ return rp;
};
services = new DaemonService[] {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PostReceiveHook.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PostReceiveHook.java
index ba5d2f3c8f..28a146dde5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PostReceiveHook.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PostReceiveHook.java
@@ -63,12 +63,9 @@ import java.util.Collection;
*/
public interface PostReceiveHook {
/** A simple no-op hook. */
- PostReceiveHook NULL = new PostReceiveHook() {
- @Override
- public void onPostReceive(final ReceivePack rp,
- final Collection<ReceiveCommand> commands) {
- // Do nothing.
- }
+ PostReceiveHook NULL = (final ReceivePack rp,
+ final Collection<ReceiveCommand> commands) -> {
+ // Do nothing.
};
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PostUploadHook.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PostUploadHook.java
index 3aa3b127e5..251bfe271a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PostUploadHook.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PostUploadHook.java
@@ -57,11 +57,8 @@ import org.eclipse.jgit.storage.pack.PackStatistics;
*/
public interface PostUploadHook {
/** A simple no-op hook. */
- PostUploadHook NULL = new PostUploadHook() {
- @Override
- public void onPostUpload(PackStatistics stats) {
- // Do nothing.
- }
+ PostUploadHook NULL = (PackStatistics stats) -> {
+ // Do nothing.
};
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PreReceiveHook.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PreReceiveHook.java
index 30845d3b68..b91756bd5e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PreReceiveHook.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PreReceiveHook.java
@@ -79,12 +79,9 @@ import java.util.Collection;
*/
public interface PreReceiveHook {
/** A simple no-op hook. */
- PreReceiveHook NULL = new PreReceiveHook() {
- @Override
- public void onPreReceive(final ReceivePack rp,
- final Collection<ReceiveCommand> commands) {
- // Do nothing.
- }
+ PreReceiveHook NULL = (final ReceivePack rp,
+ final Collection<ReceiveCommand> commands) -> {
+ // Do nothing.
};
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java
index aeca63500a..14afc44eec 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java
@@ -57,7 +57,6 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -193,81 +192,78 @@ public class PushCertificateStore implements AutoCloseable {
* close resources.
*/
public Iterable<PushCertificate> getAll(String refName) {
- return new Iterable<PushCertificate>() {
- @Override
- public Iterator<PushCertificate> iterator() {
- return new Iterator<PushCertificate>() {
- private final String path = pathName(refName);
- private PushCertificate next;
+ return () -> new Iterator<PushCertificate>() {
+ private final String path = pathName(refName);
+
+ private PushCertificate next;
+
+ private RevWalk rw;
+ {
+ try {
+ if (reader == null) {
+ load();
+ }
+ if (commit != null) {
+ rw = new RevWalk(reader);
+ rw.setTreeFilter(AndTreeFilter.create(
+ PathFilterGroup.create(Collections
+ .singleton(PathFilter.create(path))),
+ TreeFilter.ANY_DIFF));
+ rw.setRewriteParents(false);
+ rw.markStart(rw.parseCommit(commit));
+ } else {
+ rw = null;
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
- private RevWalk rw;
- {
+ @Override
+ public boolean hasNext() {
+ try {
+ if (next == null) {
+ if (rw == null) {
+ return false;
+ }
try {
- if (reader == null) {
- load();
- }
- if (commit != null) {
- rw = new RevWalk(reader);
- rw.setTreeFilter(AndTreeFilter.create(
- PathFilterGroup.create(
- Collections.singleton(PathFilter.create(path))),
- TreeFilter.ANY_DIFF));
- rw.setRewriteParents(false);
- rw.markStart(rw.parseCommit(commit));
+ RevCommit c = rw.next();
+ if (c != null) {
+ try (TreeWalk tw = TreeWalk.forPath(
+ rw.getObjectReader(), path,
+ c.getTree())) {
+ next = read(tw);
+ }
} else {
- rw = null;
+ next = null;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
-
- @Override
- public boolean hasNext() {
- try {
- if (next == null) {
- if (rw == null) {
- return false;
- }
- try {
- RevCommit c = rw.next();
- if (c != null) {
- try (TreeWalk tw = TreeWalk.forPath(
- rw.getObjectReader(), path, c.getTree())) {
- next = read(tw);
- }
- } else {
- next = null;
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- return next != null;
- } finally {
- if (next == null && rw != null) {
- rw.close();
- rw = null;
- }
- }
+ return next != null;
+ } finally {
+ if (next == null && rw != null) {
+ rw.close();
+ rw = null;
}
+ }
+ }
- @Override
- public PushCertificate next() {
- hasNext();
- PushCertificate n = next;
- if (n == null) {
- throw new NoSuchElementException();
- }
- next = null;
- return n;
- }
+ @Override
+ public PushCertificate next() {
+ hasNext();
+ PushCertificate n = next;
+ if (n == null) {
+ throw new NoSuchElementException();
+ }
+ next = null;
+ return n;
+ }
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
}
};
}
@@ -442,13 +438,8 @@ public class PushCertificateStore implements AutoCloseable {
}
private static void sortPending(List<PendingCert> pending) {
- Collections.sort(pending, new Comparator<PendingCert>() {
- @Override
- public int compare(PendingCert a, PendingCert b) {
- return Long.signum(
- a.ident.getWhen().getTime() - b.ident.getWhen().getTime());
- }
- });
+ Collections.sort(pending, (PendingCert a, PendingCert b) -> Long.signum(
+ a.ident.getWhen().getTime() - b.ident.getWhen().getTime()));
}
private DirCache newDirCache() throws IOException {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefFilter.java
index d6d6198f5b..d19c652c25 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefFilter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefFilter.java
@@ -61,12 +61,7 @@ public interface RefFilter {
/**
* The default filter, allows all refs to be shown.
*/
- RefFilter DEFAULT = new RefFilter() {
- @Override
- public Map<String, Ref> filter (Map<String, Ref> refs) {
- return refs;
- }
- };
+ RefFilter DEFAULT = (Map<String, Ref> refs) -> refs;
/**
* Filters a {@code Map} of refs before it is advertised to the client.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshSessionFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshSessionFactory.java
index 005a0c2d0e..fdb19df91a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshSessionFactory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshSessionFactory.java
@@ -100,13 +100,9 @@ public abstract class SshSessionFactory {
* @since 5.2
*/
public static String getLocalUserName() {
- return AccessController.doPrivileged(new PrivilegedAction<String>() {
- @Override
- public String run() {
- return SystemReader.getInstance()
- .getProperty(Constants.OS_USER_NAME_KEY);
- }
- });
+ return AccessController
+ .doPrivileged((PrivilegedAction<String>) () -> SystemReader
+ .getInstance().getProperty(Constants.OS_USER_NAME_KEY));
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java
index fbb2c44100..f2a2b0a1c2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java
@@ -188,12 +188,8 @@ class TransportLocal extends Transport implements PackTransport {
&& !"git upload-pack".equals(up)) //$NON-NLS-1$
return new ForkLocalFetchConnection();
- UploadPackFactory<Void> upf = new UploadPackFactory<Void>() {
- @Override
- public UploadPack create(Void req, Repository db) {
- return createUploadPack(db);
- }
- };
+ UploadPackFactory<Void> upf = (Void req,
+ Repository db) -> createUploadPack(db);
return new InternalFetchConnection<>(this, upf, null, openRepo());
}
@@ -205,12 +201,8 @@ class TransportLocal extends Transport implements PackTransport {
&& !"git receive-pack".equals(rp)) //$NON-NLS-1$
return new ForkLocalPushConnection();
- ReceivePackFactory<Void> rpf = new ReceivePackFactory<Void>() {
- @Override
- public ReceivePack create(Void req, Repository db) {
- return createReceivePack(db);
- }
- };
+ ReceivePackFactory<Void> rpf = (Void req,
+ Repository db) -> createReceivePack(db);
return new InternalPushConnection<>(this, rpf, null, openRepo());
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/ReceivePackFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/ReceivePackFactory.java
index b850d1ef94..5d36e58c01 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/ReceivePackFactory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/ReceivePackFactory.java
@@ -57,12 +57,8 @@ public interface ReceivePackFactory<C> {
/**
* A factory disabling the ReceivePack service for all repositories
*/
- ReceivePackFactory<?> DISABLED = new ReceivePackFactory<Object>() {
- @Override
- public ReceivePack create(Object req, Repository db)
- throws ServiceNotEnabledException {
- throw new ServiceNotEnabledException();
- }
+ ReceivePackFactory<?> DISABLED = (Object req, Repository db) -> {
+ throw new ServiceNotEnabledException();
};
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/RepositoryResolver.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/RepositoryResolver.java
index 4816f21bcc..dd24b7a0f2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/RepositoryResolver.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/RepositoryResolver.java
@@ -57,12 +57,8 @@ public interface RepositoryResolver<C> {
/**
* Resolver configured to open nothing.
*/
- RepositoryResolver<?> NONE = new RepositoryResolver<Object>() {
- @Override
- public Repository open(Object req, String name)
- throws RepositoryNotFoundException {
- throw new RepositoryNotFoundException(name);
- }
+ RepositoryResolver<?> NONE = (Object req, String name) -> {
+ throw new RepositoryNotFoundException(name);
};
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/UploadPackFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/UploadPackFactory.java
index bb43b136d8..b8673f5eb5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/UploadPackFactory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/UploadPackFactory.java
@@ -57,12 +57,8 @@ public interface UploadPackFactory<C> {
/**
* A factory disabling the UploadPack service for all repositories.
*/
- UploadPackFactory<?> DISABLED = new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException {
- throw new ServiceNotEnabledException();
- }
+ UploadPackFactory<?> DISABLED = (Object req, Repository db) -> {
+ throw new ServiceNotEnabledException();
};
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
index b768acd050..c0c24872b2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
@@ -774,14 +774,10 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
return attributesNode;
}
- private static final Comparator<Entry> ENTRY_CMP = new Comparator<Entry>() {
- @Override
- public int compare(Entry a, Entry b) {
- return Paths.compare(
- a.encodedName, 0, a.encodedNameLen, a.getMode().getBits(),
- b.encodedName, 0, b.encodedNameLen, b.getMode().getBits());
- }
- };
+ private static final Comparator<Entry> ENTRY_CMP = (Entry a,
+ Entry b) -> Paths.compare(a.encodedName, 0, a.encodedNameLen,
+ a.getMode().getBits(), b.encodedName, 0, b.encodedNameLen,
+ b.getMode().getBits());
/**
* Constructor helper.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
index 536e4f1dfa..53685029db 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -463,13 +463,9 @@ public abstract class FS {
* @return the user's home directory; null if the user does not have one.
*/
protected File userHomeImpl() {
- final String home = AccessController
- .doPrivileged(new PrivilegedAction<String>() {
- @Override
- public String run() {
- return System.getProperty("user.home"); //$NON-NLS-1$
- }
- });
+ final String home = AccessController.doPrivileged(
+ (PrivilegedAction<String>) () -> System.getProperty("user.home") //$NON-NLS-1$
+ );
if (home == null || home.length() == 0)
return null;
return new File(home).getAbsoluteFile();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java
index e5c8d9d398..9a163e8e38 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java
@@ -80,12 +80,9 @@ public class FS_Win32_Cygwin extends FS_Win32 {
*/
public static boolean isCygwin() {
final String path = AccessController
- .doPrivileged(new PrivilegedAction<String>() {
- @Override
- public String run() {
- return System.getProperty("java.library.path"); //$NON-NLS-1$
- }
- });
+ .doPrivileged((PrivilegedAction<String>) () -> System
+ .getProperty("java.library.path") //$NON-NLS-1$
+ );
if (path == null)
return false;
File found = FS.searchPath(path, "cygpath.exe"); //$NON-NLS-1$
@@ -141,13 +138,9 @@ public class FS_Win32_Cygwin extends FS_Win32 {
/** {@inheritDoc} */
@Override
protected File userHomeImpl() {
- final String home = AccessController
- .doPrivileged(new PrivilegedAction<String>() {
- @Override
- public String run() {
- return System.getenv("HOME"); //$NON-NLS-1$
- }
- });
+ final String home = AccessController.doPrivileged(
+ (PrivilegedAction<String>) () -> System.getenv("HOME") //$NON-NLS-1$
+ );
if (home == null || home.length() == 0)
return super.userHomeImpl();
return resolve(new File("."), home); //$NON-NLS-1$
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
index 953c9768f9..5feacffdb3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
@@ -368,12 +368,9 @@ public abstract class SystemReader {
}
private String getOsName() {
- return AccessController.doPrivileged(new PrivilegedAction<String>() {
- @Override
- public String run() {
- return getProperty("os.name"); //$NON-NLS-1$
- }
- });
+ return AccessController.doPrivileged(
+ (PrivilegedAction<String>) () -> getProperty("os.name") //$NON-NLS-1$
+ );
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/IsolatedOutputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/IsolatedOutputStream.java
index 8ea8723194..18de7052d9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/IsolatedOutputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/IsolatedOutputStream.java
@@ -102,12 +102,9 @@ public class IsolatedOutputStream extends OutputStream {
public void write(byte[] buf, int pos, int cnt)
throws IOException {
checkClosed();
- execute(new Callable<Void>() {
- @Override
- public Void call() throws IOException {
- dst.write(buf, pos, cnt);
- return null;
- }
+ execute(() -> {
+ dst.write(buf, pos, cnt);
+ return null;
});
}
@@ -115,12 +112,9 @@ public class IsolatedOutputStream extends OutputStream {
@Override
public void flush() throws IOException {
checkClosed();
- execute(new Callable<Void>() {
- @Override
- public Void call() throws IOException {
- dst.flush();
- return null;
- }
+ execute(() -> {
+ dst.flush();
+ return null;
});
}
@@ -159,12 +153,9 @@ public class IsolatedOutputStream extends OutputStream {
}
private void cleanClose() throws IOException {
- execute(new Callable<Void>() {
- @Override
- public Void call() throws IOException {
- dst.close();
- return null;
- }
+ execute(() -> {
+ dst.close();
+ return null;
});
}
@@ -178,12 +169,9 @@ public class IsolatedOutputStream extends OutputStream {
Future<Void> close;
try {
- close = copier.submit(new Callable<Void>() {
- @Override
- public Void call() throws IOException {
- dst.close();
- return null;
- }
+ close = copier.submit(() -> {
+ dst.close();
+ return null;
});
} catch (RejectedExecutionException e) {
throw new IOException(e);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/ThrowingPrintWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/ThrowingPrintWriter.java
index caabcef574..9431aafbde 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/ThrowingPrintWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/ThrowingPrintWriter.java
@@ -68,12 +68,10 @@ public class ThrowingPrintWriter extends Writer {
*/
public ThrowingPrintWriter(Writer out) {
this.out = out;
- LF = AccessController.doPrivileged(new PrivilegedAction<String>() {
- @Override
- public String run() {
- return SystemReader.getInstance().getProperty("line.separator"); //$NON-NLS-1$
- }
- });
+ LF = AccessController
+ .doPrivileged((PrivilegedAction<String>) () -> SystemReader
+ .getInstance().getProperty("line.separator") //$NON-NLS-1$
+ );
}
/** {@inheritDoc} */