Commit Graph

5899 Commits

Author SHA1 Message Date
David Pursehouse 7bd2a4a7c6 DirCache: Suppress resource warning related to TemporaryBuffer
In #writeTo, the TemporaryBuffer can't be opened in try-with-resource
because it's referenced in the finally block. Instead it is explicitly
closed within the try block. Suppress the warning with an explanatory
comment.

Change-Id: I02009f77f9630d5d55afc34eb86d304ff103b8b0
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-15 07:57:02 +09:00
David Pursehouse 3e1066d0a4 Add SilentFileInputStream to allow ignoring exceptions raised by close()
There are several cases where a FileInputStream is opened outside of
a try-with-resource because we want to explicitly close it and ignore
any IOException that is raised by the close() method.

Introduce a helper class, SilentFileInputStream, that overrides the
close method and ignores the exceptions. This allows to open the stream
in a try-with-resource block and remove the explicit handling of the
close method.

Change-Id: I8612f948a1a5b3d1031344922ad75ce4492cfc61
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-15 06:39:57 +09:00
David Pursehouse aa563091d5 WorkingTreeIterator#idSubmodule: Refactor to open Repository in try-with-resource
Change-Id: I991f0096c833da721b98c1e0423a8dadc67cd64f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-14 10:44:23 +09:00
David Pursehouse 67df4986ce UploadPack: Suppress resource warning about PackWriter
PackWriter is auto-closeable and should be opened in try-with-resource,
but this is not possible since the variable is being referenced in the
finally block before being explicitly closed there.

Suppress the warning and add an explanatory comment.

Change-Id: I161923f35142132234fd951c0146d3cb30920b7b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-14 10:44:23 +09:00
David Pursehouse ed9ede3446 ShowPackDelta: Refactor to use try-with-resource
Remove the resource warning suppression and refactor the code to open
the TemporaryBuffer and InflaterInputStream in a try-with-resource.

Change-Id: I3082e5ac7565c5000d5a4364f750dd0a0952fc6e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-14 10:44:23 +09:00
David Pursehouse 6344e7a071 SubmoduleWalk#forIndex: Suppress resource warning and update Javadoc
SubmoduleWalk is auto-closeable, and Eclipse warns that is is not
managed by try-with-resource. However in this case the resource should
not be closed, because the caller needs to use it. Instead, it is the
responsibility of the caller to close it after use.

Update the Javadoc to clarify this, and suppress the warning.

Change-Id: Ib7ba349353bfd3341bdcbe4bb19abaeb9f3aeba5
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-14 10:44:23 +09:00
David Pursehouse 4775a394c0 SubmoduleWalk: Open Repository in try-with-resource
Change-Id: Ib29aaf26b49aa94a5a7cc0b0264a0a93ecff0c16
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-14 10:44:23 +09:00
David Pursehouse 98667d3851 RepositoryFilter: Refactor doFilter to open Repository in try-with-resource
Change-Id: Ic4a056eebe567ff933519d6a805edb7e97c71b22
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-14 10:44:23 +09:00
David Pursehouse fe6c97bc4c NetRC: Open BufferedReader in try-with-resource
Change-Id: Ie0688b0ce19f657834a23438f112569a86491b3b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-14 10:44:23 +09:00
David Pursehouse 3e437da6ba PackParser: Refactor to open InputStream in try-with-resource
Change-Id: I8d002ccc8f168f5891492a4c5742c82f8cb7a0b6
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-14 10:44:23 +09:00
David Pursehouse 48554989d3 AutoLFInputStreamTest: Use try-with-resource
Change-Id: I162bfa6b2f87f2ce9154f3ed6bb628c4cda88f50
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-14 10:44:23 +09:00
David Pursehouse bac3efbe67 DfsInserter: Refactor writePackIndex to use try-with-resource
Refactor to allow the temporary buffer to be opened in try-with-resource.

Change-Id: Id913e6c3ed3913fd5d79d66238b779e0c225b47d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-14 10:44:23 +09:00
David Pursehouse 6eb4cd276c AmazonS3: Refactor error method to avoid 'should be managed by try-with-resource' warning
Change-Id: I205fc1c77777870b0a036e52fa9954de5d9f60b5
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-13 22:21:36 +01:00
David Pursehouse 9450a55f76 CommandCatalog: Simplify scan method using try-with-resource
The IOExceptions caught in the nested try blocks are all ignored,
so we can just wrap them all up into a single try-with-resource
block.

Change-Id: Id85850b3f54c408af73063220e6fead20cb0fd80
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-13 22:21:35 +01:00
David Pursehouse 7392d3b304 Transport: Simplify scan method using try-with-resource
The IOExceptions caught in the nested try blocks are all ignored,
so we can just wrap them all up into a single try-with-resource
block.

Change-Id: I536d682f1017c5088b94ff9f98ffa2b7c783d8bf
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-13 22:21:35 +01:00
David Pursehouse da3d76f00e Use CHARSET in FileOutputStream instead of hard-coded "UTF-8"
Change-Id: I63ad25e1ebd94081c8848f4d21044cf9041f971d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-13 22:21:35 +01:00
David Pursehouse bf757cd1c6 TemporaryBufferTest: Suppress "should be managed by try-with-resource"
In most of the tests, the temporary buffer is explicitly destroyed in
a finally block after being closed. This is not possible if using the
try-with-resource construct, because the variable is not accessible in
the finally block scope.

Change-Id: I3bab30695ddd12e1a0ae107989638428fe3ef551
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-13 22:21:34 +01:00
David Pursehouse 5c70be0085 Open auto-closeable resources in try-with-resource
When an auto-closeable resources is not opened in try-with-resource,
the warning "should be managed by try-with-resource" is emitted by
Eclipse.

Fix the ones that can be silenced simply by moving the declaration of
the variable into a try-with-resource.

In cases where we explicitly call the close() method, for example in
tests where we are testing specific behavior caused by the close(),
suppress the warning.

Leave the ones that will require more significant refcactoring to fix.
They can be done in separate commits that can be reviewed and tested
in isolation.

Change-Id: I9682cd20fb15167d3c7f9027cecdc82bc50b83c4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-13 22:16:06 +01:00
Matthias Sohn e23b09ad6e Implement --force option in FetchCommand and CLI fetch command
Change-Id: I42cdb57b8fb54ce466d1958391f12f911045327f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-13 02:20:29 +01:00
Matthias Sohn 6f82de449f Merge "Introduce SshSupport to centralize SSH related utility code" 2018-03-12 19:52:43 -04:00
Markus Duft 4ca9bb5ab9 Introduce SshSupport to centralize SSH related utility code
As discussed with Thomas here:
https://git.eclipse.org/r/#/c/83506/31/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java@349

Move the code from ConfigureGerritAfterCloneTask to SshSupport and
eliminate the slightly modified copy of the code from
LfsConnectionFactory. Separate EGit commit will eliminate the code from
ConfigureGerritAfterCloneTask.

Change-Id: Ifb5adb1342e0fc1f2a70cddf693408d4e0ef7906
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
2018-03-12 07:53:35 +01:00
David Pursehouse d88d5b94c6 UploadPack: Remove redundant suppression of deprecation warning
Change-Id: I9a7f46e1da42fd86adedc18b3394d5f755722624
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-12 10:52:03 +09:00
David Pursehouse f07b60239c Consistently use Constants.CHARSET rather than StandardCharsets.UTF_8
Change-Id: I6714fc3666e1bced22abba94ceb700477349586e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-11 22:46:52 +01:00
David Pursehouse 62bc48df60 Constants: Initialize CHARSET and CHARACTER_ENCODING from StandardCharsets.UTF_8
Change-Id: Ib4e0a35429892fa1581db09a9b77717120d03275
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-11 22:28:30 +01:00
Matthias Sohn b7651da4e8 Remove deprecated LfsProtocolServlet#getLargeFileRepository
Use LfsProtocolServlet##getLargeFileRepository(LfsRequest, String,
String) instead.

Change-Id: If68d06f2e6edbf843dc9d3b4e3b99c33b0fab766
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:33 +01:00
Matthias Sohn b0e06a733b Remove deprecated Lfs#Lfs(Path)
Use Lfs#Lfs(Repository) instead.

Change-Id: I7303987ed047b42fd1bac8e27ed49333080e556b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:32 +01:00
Matthias Sohn bfe89332a4 Remove deprecated StreamCopyThread#flush
StreamCopyThread: Do not let flush interrupt a write.
flush calls interrupt() to interrupt a pending read and trigger a
flush.  Unfortunately that interrupt() call can also interrupt a
pending write, putting Jsch in a bad state and triggering "Short read
of block" errors.

Change-Id: I11f8a014fd72df06617cc8731d992eb14cc32a67
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:31 +01:00
Matthias Sohn 50436cc829 Remove deprecated SafeBufferedOutputStream
Use Java 8 BufferedOutputStream instead. Java 8 fixed the silent flush
during close issue by FilterOutputStream (base class of
BufferedOutputStream) using try-with-resources to close the stream,
getting a behavior matching what JGit's SafeBufferedOutputStream
was doing

Change-Id: Ieeab59f49b44519585abda213d287b19c7863b17
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:30 +01:00
Matthias Sohn e940db9f15 Remove deprecated EolCanonicalizingInputStream
Use AutoLFInputStream instead.

Change-Id: If3765c425eed3a52d0c6aa8c7ea4925bb2e87395
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:30 +01:00
Matthias Sohn 5fc1705f5b Remove deprecated FileUtils#relativize(String, String)
Use the more-clearly-named
FileUtils#relativizeNativePath(String, String)
instead, or directly call
FileUtils#relativizePath(String, String, String, boolean).

Change-Id: I9b56302c94630c75293d8cf5510e1d2f22f2b778
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:29 +01:00
Matthias Sohn 62f3b47eb4 Remove deprecated FileUtil using Java 7 NIO
Change-Id: I180a7a0bf9fe36c42edab9fffc6c05d983c229a7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:28 +01:00
Matthias Sohn 164b3e9699 Remove deprecated TreeWalk#getEolStreamType
Use TreeWalk#getEolStreamType(OperationType) instead.

Change-Id: I0f102ddf36102ff55a71448e376ed08743da5d1f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:27 +01:00
Matthias Sohn 4772569036 Remove deprecated FileTreeIterator(WorkingTreeIterator, File, FS)
Use FileTreeIterator#FileTreeIterator(FileTreeIterator, File, FS)
instead.

Change-Id: I675e14863a1a387e7da9fc5148feffaf55d4ad39
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:27 +01:00
Matthias Sohn 39a1b4d325 Remove deprecated TransportHttp#httpOpen(String, URL)
Use TransportHttp#httpOpen(String, URL, AcceptEncoding) instead.

Change-Id: I4ad423175daa5499caad9cccb88076d371331569
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:26 +01:00
Matthias Sohn 211d94e135 Remove deprecated ResolveMerger#processEntry method
Change-Id: I687965f6e9f3bcafa28afd62621fea240b36939d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:25 +01:00
Matthias Sohn e1cfe09bfa Remove deprecated Repository#getRef
Use Repository#exactRef(String) or Repository#findRef(String) instead.

Change-Id: I5c547a26604b4cd792111c699df5f3c9d955d3f2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:24 +01:00
Matthias Sohn d061343619 Remove deprecated BitmapBuilder#add
Use BitmapBuilder#or or BitmapBuilder#addObject instead.

Change-Id: I4bd71a842cf9f6ba2f9a17015e8a36ac380bfd3a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:23 +01:00
Matthias Sohn cc8dfe79a9 Remove deprecated LockFile(File, FS) constructor
Use org.eclipse.jgit.internal.storage.file.LockFile#LockFile(File)
instead.

Change-Id: I107d9879c02a2006799a238ccaddf87c89f33f77
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:23 +01:00
Matthias Sohn f0ab2d07b8 Remove deprecated IgnoreNode#isIgnored method
Parameter negateFirstMatch is not honored anymore

Change-Id: Idff1a92643c1431c7e34a7730f8414135e1ac196
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:41:22 +01:00
David Pursehouse 9441508682 Fix misspelled class name: EmtpyCommitException -> EmptyCommitException
Change-Id: I55196020146f26951988988c14ac9a6f85061ae2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-10 19:40:55 +01:00
Matthias Sohn cc19f64966 Remove deprecated Statistics, UploadPackLogger, UploadPackLoggerChain
Use PackStatistics and PostUploadHook and PostUploadHookChain instead.
Also remove
- UploadPack#getPackStatistics replaced by #getStatistics
- UploadPack#getLogger and UploadPack#setLogger

Change-Id: I70881c539af3094d68d594f19983dea0973604e8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-10 19:38:36 +01:00
Matthias Sohn f9a4112ecc Remove deprecated StoredObjectRepresentationnotAvailableException ctor
Use #StoredObjectRepresentationNotAvailableException(ObjectToPack,
Throwable) instead.

Change-Id: I766e00bc7292c7bd025aa2d7c54f10d278c7fabd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-09 23:57:36 +01:00
Matthias Sohn 653b31a903 Remove deprecated ArchiveCommand#putEntry method
Use #putEntry(Closeable, ObjectId, String, FileMode, ObjectLoader)}
instead.

Change-Id: I2c58c07da00c6033c583eb2dc6c3a0889661f5f5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-09 23:55:43 +01:00
Matthias Sohn d0f1f5eef6 Prepare 5.0.0-SNAPSHOT builds
Change-Id: I2d2f50ed8a12f310e7cac68eed5536bd460c403f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-08 23:09:18 +01:00
Matthias Sohn 2187920216 Merge branch 'stable-4.11'
* stable-4.11:
  Prepare 4.11.1-SNAPSHOT builds
  JGit v4.11.0.201803080745-r

Change-Id: I225b9a6a9be6bda1d6fc8f605917645ff1fec852
2018-03-08 23:08:28 +01:00
Matthias Sohn f389e18a28 Prepare 4.11.1-SNAPSHOT builds
Change-Id: Id9aa6b7e8f56de5183b6cd57ef0e790ec9debd4d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-08 21:10:08 +01:00
Matthias Sohn f944063517 JGit v4.11.0.201803080745-r
Change-Id: Ie24a33bc8a24c30db06fe7b175f405efb95776ec
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-08 13:43:46 +01:00
Thomas Wolf e00f59b7fe Remove useless for(;;) loop
Change-Id: Ic9a7824cc178e92f44126acc8e77b0304b20ef4f
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-03-07 23:56:35 +01:00
Thomas Wolf 7d3040368f Fix DiffFormatter for diffs against working tree with autocrlf=true
The WorkingTreeSource produced an ObjectLoader that returned
inconsistent sizes: the file size in getSize(), but then a
correctly filtered smaller stream in openStream(). This resulted
either in an IOE "short read of block" or in an EOFException
depending on the resulting filtered size.

Fix this by ensuring that getSize() does return the size of the
filtered stream.

Bug: 530106
Change-Id: I7c7c85036047dc10030ed29c1d5a6c7f34f2bdff
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-03-07 23:25:22 +01:00
Matthias Sohn 0d79bcf151 Merge branch 'stable-4.10'
* stable-4.10:
  Don't subclass ThreadLocal to avoid memory leak in NLS
  Set context classloader to null in WorkQueue

Change-Id: Idacf9a15a27f8e1d73357a80ed11a02237eea49e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-07 22:37:50 +01:00