diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java index 195dff961..75611eec9 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java @@ -77,7 +77,7 @@ abstract class SmartServiceInfoRefs implements Filter { SmartServiceInfoRefs(String service, List filters) { this.svc = service; - this.filters = filters.toArray(new Filter[filters.size()]); + this.filters = filters.toArray(new Filter[0]); } /** {@inheritDoc} */ diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java index 18650eb95..f16749775 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java @@ -98,7 +98,7 @@ abstract class ServletBinderImpl implements ServletBinder { * @return the configured filters; zero-length array if none. */ protected Filter[] getFilters() { - return filters.toArray(new Filter[filters.size()]); + return filters.toArray(new Filter[0]); } /** @return the pipeline that matches and executes this chain. */ diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java index 9309fe707..9aef086b7 100644 --- a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java +++ b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java @@ -349,7 +349,7 @@ public class AppServer { sec.setAuthenticator(authType); sec.setLoginService(users); sec.setConstraintMappings( - mappings.toArray(new ConstraintMapping[mappings.size()])); + mappings.toArray(new ConstraintMapping[0])); sec.setHandler(ctx); contexts.removeHandler(ctx); diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java index de4449f5e..a20c1d96f 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java @@ -201,7 +201,7 @@ public class LfsPrePushHook extends PrePushHook { private Map requestBatchUpload(HttpConnection api, Set toPush) throws IOException { - LfsPointer[] res = toPush.toArray(new LfsPointer[toPush.size()]); + LfsPointer[] res = toPush.toArray(new LfsPointer[0]); Map oidStr2ptr = new HashMap<>(); for (LfsPointer p : res) { oidStr2ptr.put(p.getOid().name(), p); diff --git a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java index 44ad79def..81875f11b 100644 --- a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java +++ b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java @@ -230,7 +230,7 @@ public class CLIGitCommand extends Main { } if (r.length() > 0) list.add(r.toString()); - return list.toArray(new String[list.size()]); + return list.toArray(new String[0]); } public static class Result { 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 afeb5ef6e..ecc00d37f 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 @@ -544,7 +544,7 @@ public class ArchiveTest extends CLIRepositoryTestCase { byte[] result = CLIGitCommand.executeRaw( "git archive --format=zip HEAD", db).outBytes(); - assertArrayEquals(l.toArray(new String[l.size()]), + assertArrayEquals(l.toArray(new String[0]), listZipEntries(result)); } @@ -564,7 +564,7 @@ public class ArchiveTest extends CLIRepositoryTestCase { byte[] result = CLIGitCommand.executeRaw( "git archive --format=tar HEAD", db).outBytes(); - assertArrayEquals(l.toArray(new String[l.size()]), + assertArrayEquals(l.toArray(new String[0]), listTarEntries(result)); } @@ -697,7 +697,7 @@ public class ArchiveTest extends CLIRepositoryTestCase { while ((e = in.getNextEntry()) != null) l.add(e.getName()); } - return l.toArray(new String[l.size()]); + return l.toArray(new String[0]); } private static Future writeAsync(OutputStream stream, byte[] data) { @@ -730,7 +730,7 @@ public class ArchiveTest extends CLIRepositoryTestCase { while ((line = reader.readLine()) != null) l.add(line); - return l.toArray(new String[l.size()]); + return l.toArray(new String[0]); } finally { writing.get(); proc.destroy(); @@ -754,7 +754,7 @@ public class ArchiveTest extends CLIRepositoryTestCase { String line; while ((line = reader.readLine()) != null) l.add(line); - return l.toArray(new String[l.size()]); + return l.toArray(new String[0]); } // not found @@ -774,7 +774,7 @@ public class ArchiveTest extends CLIRepositoryTestCase { while ((line = reader.readLine()) != null) l.add(line); - return l.toArray(new String[l.size()]); + return l.toArray(new String[0]); } finally { writing.get(); proc.destroy(); 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 5754d7c44..2b0e5a717 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 @@ -114,7 +114,7 @@ public class CommandCatalog { } private static CommandRef[] toSortedArray(Collection c) { - final CommandRef[] r = c.toArray(new CommandRef[c.size()]); + final CommandRef[] r = c.toArray(new CommandRef[0]); Arrays.sort(r, new Comparator() { @Override public int compare(CommandRef o1, CommandRef o2) { diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Describe.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Describe.java index f9c1cf5d3..f91474859 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Describe.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Describe.java @@ -73,7 +73,7 @@ class Describe extends TextBuiltin { if (tree != null) cmd.setTarget(tree); cmd.setLong(longDesc); - cmd.setMatch(patterns.toArray(new String[patterns.size()])); + cmd.setMatch(patterns.toArray(new String[0])); String result = null; try { result = cmd.call(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java index ac53de976..6fa92d3b0 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java @@ -285,7 +285,7 @@ public class Main { final TextBuiltin cmd = subcommand; init(cmd); try { - cmd.execute(arguments.toArray(new String[arguments.size()])); + cmd.execute(arguments.toArray(new String[0])); } finally { if (cmd.outw != null) { cmd.outw.flush(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java index 3308e18f2..63eba15ab 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java @@ -130,7 +130,7 @@ class Remote extends TextBuiltin { fetchArgs.add(name); } - fetch.execute(fetchArgs.toArray(new String[fetchArgs.size()])); + fetch.execute(fetchArgs.toArray(new String[0])); // flush the streams fetch.outw.flush(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java index 5cc98ca8a..b97aa5b7a 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java @@ -177,7 +177,7 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { } try { - super.parseArgument(tmp.toArray(new String[tmp.size()])); + super.parseArgument(tmp.toArray(new String[0])); } catch (Die e) { if (!seenHelp) { throw e; diff --git a/org.eclipse.jgit.test/src/org/eclipse/jgit/events/ChangeRecorder.java b/org.eclipse.jgit.test/src/org/eclipse/jgit/events/ChangeRecorder.java index c5582a860..228df35c7 100644 --- a/org.eclipse.jgit.test/src/org/eclipse/jgit/events/ChangeRecorder.java +++ b/org.eclipse.jgit.test/src/org/eclipse/jgit/events/ChangeRecorder.java @@ -74,11 +74,11 @@ public class ChangeRecorder implements WorkingTreeModifiedListener { } private String[] getModified() { - return modified.toArray(new String[modified.size()]); + return modified.toArray(new String[0]); } private String[] getDeleted() { - return deleted.toArray(new String[deleted.size()]); + return deleted.toArray(new String[0]); } private void reset() { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ReflogCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ReflogCommandTest.java index b07c7033f..892283713 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ReflogCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ReflogCommandTest.java @@ -89,7 +89,7 @@ public class ReflogCommandTest extends RepositoryTestCase { Collection reflog = git.reflog().call(); assertNotNull(reflog); assertEquals(3, reflog.size()); - ReflogEntry[] reflogs = reflog.toArray(new ReflogEntry[reflog.size()]); + ReflogEntry[] reflogs = reflog.toArray(new ReflogEntry[0]); assertEquals(reflogs[2].getComment(), "commit (initial): Initial commit"); assertEquals(reflogs[2].getNewId(), commit1.getId()); @@ -114,7 +114,7 @@ public class ReflogCommandTest extends RepositoryTestCase { .setRef(Constants.R_HEADS + "b1").call(); assertNotNull(reflog); assertEquals(2, reflog.size()); - ReflogEntry[] reflogs = reflog.toArray(new ReflogEntry[reflog.size()]); + ReflogEntry[] reflogs = reflog.toArray(new ReflogEntry[0]); assertEquals(reflogs[0].getComment(), "commit: Removed file"); assertEquals(reflogs[0].getNewId(), commit2.getId()); assertEquals(reflogs[0].getOldId(), commit1.getId()); @@ -136,7 +136,7 @@ public class ReflogCommandTest extends RepositoryTestCase { Collection reflog = git.reflog().call(); assertNotNull(reflog); assertEquals(4, reflog.size()); - ReflogEntry[] reflogs = reflog.toArray(new ReflogEntry[reflog.size()]); + ReflogEntry[] reflogs = reflog.toArray(new ReflogEntry[0]); assertEquals(reflogs[3].getComment(), "commit (initial): Initial commit"); assertEquals(reflogs[3].getNewId(), commit1.getId()); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/PathFilterGroupTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/PathFilterGroupTest.java index 71a2f327c..15d03d38e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/PathFilterGroupTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/PathFilterGroupTest.java @@ -231,8 +231,8 @@ public class PathFilterGroupTest { } } - String[] e = expect.toArray(new String[expect.size()]); - String[] a = actual.toArray(new String[actual.size()]); + String[] e = expect.toArray(new String[0]); + String[] a = actual.toArray(new String[0]); Arrays.sort(e); Arrays.sort(a); assertArrayEquals(e, a); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java index bad71de8a..ca1e3ab27 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java @@ -513,7 +513,7 @@ public class DirCacheCheckout { if (!conflicts.isEmpty()) { if (failOnConflict) - throw new CheckoutConflictException(conflicts.toArray(new String[conflicts.size()])); + throw new CheckoutConflictException(conflicts.toArray(new String[0])); else cleanUpConflicts(); } 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 bc5ba3926..fa32b267d 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 @@ -274,8 +274,8 @@ public abstract class KetchLeader { lock.lock(); try { - voters = v.toArray(new KetchReplica[v.size()]); - followers = f.toArray(new KetchReplica[f.size()]); + voters = v.toArray(new KetchReplica[0]); + followers = f.toArray(new KetchReplica[0]); self = me; } finally { lock.unlock(); 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 7ddde6337..6f1f5c5c2 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 @@ -209,7 +209,7 @@ public class LocalReplica extends KetchReplica { checkFailed(failed, accepted); checkFailed(failed, committed); if (!failed.isEmpty()) { - String[] arr = failed.toArray(new String[failed.size()]); + String[] arr = failed.toArray(new String[0]); req.setRefs(refdb.exactRef(arr)); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LocalCachedPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LocalCachedPack.java index 289d89d69..e931c1f9e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LocalCachedPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LocalCachedPack.java @@ -62,13 +62,13 @@ class LocalCachedPack extends CachedPack { LocalCachedPack(ObjectDirectory odb, List packNames) { this.odb = odb; - this.packNames = packNames.toArray(new String[packNames.size()]); + this.packNames = packNames.toArray(new String[0]); } LocalCachedPack(List packs) { odb = null; packNames = null; - this.packs = packs.toArray(new PackFile[packs.size()]); + this.packs = packs.toArray(new PackFile[0]); } /** {@inheritDoc} */ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java index 51c5702fc..24723d850 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java @@ -938,7 +938,7 @@ public class ObjectDirectory extends FileObjectDatabase { if (list.isEmpty()) return new PackList(snapshot, NO_PACKS.packs); - final PackFile[] r = list.toArray(new PackFile[list.size()]); + final PackFile[] r = list.toArray(new PackFile[0]); Arrays.sort(r, PackFile.SORT); return new PackList(snapshot, r); } @@ -1030,7 +1030,7 @@ public class ObjectDirectory extends FileObjectDatabase { l.add(openAlternate(line)); } } - return l.toArray(new AlternateHandle[l.size()]); + return l.toArray(new AlternateHandle[0]); } private static BufferedReader open(File f) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BaseSearch.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BaseSearch.java index d231ccb99..f42b3a546 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BaseSearch.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BaseSearch.java @@ -91,7 +91,7 @@ class BaseSearch { List edges, ObjectReader or) { progress = countingMonitor; reader = or; - baseTrees = bases.toArray(new ObjectId[bases.size()]); + baseTrees = bases.toArray(new ObjectId[0]); objectsMap = objects; edgeObjects = edges; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java index 2c7c6cb06..d1cf1cd9a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java @@ -283,7 +283,7 @@ public class BaseRepositoryBuilder alts = alternateObjectDirectories; if (alts == null) return null; - return alts.toArray(new File[alts.size()]); + return alts.toArray(new File[0]); } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java index aff2a430d..ee18fe7c2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java @@ -177,7 +177,7 @@ public class PlotWalk extends RevWalk { if (list == null) { return PlotCommit.NO_REFS; } else { - Ref[] tags = list.toArray(new Ref[list.size()]); + Ref[] tags = list.toArray(new Ref[0]); Arrays.sort(tags, new PlotRefComparator()); return tags; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProvider.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProvider.java index 811594620..f7a295d63 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProvider.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProvider.java @@ -155,7 +155,7 @@ public abstract class CredentialsProvider { */ public boolean get(URIish uri, List items) throws UnsupportedCredentialItem { - return get(uri, items.toArray(new CredentialItem[items.size()])); + return get(uri, items.toArray(new CredentialItem[0])); } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java index f5ccdc8f1..480055c2e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java @@ -524,7 +524,7 @@ public class OpenSshConfig implements ConfigRepository { if (values == null || values.isEmpty()) { return new String[0]; } - return values.toArray(new String[values.size()]); + return values.toArray(new String[0]); } public void setValue(String key, String value) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java index 9f99e2855..98797dc64 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java @@ -169,7 +169,7 @@ public class FS_Win32 extends FS { if (result.isEmpty()) { return NO_ENTRIES; } - return result.toArray(new Entry[result.size()]); + return result.toArray(new Entry[0]); } /** {@inheritDoc} */