diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2020-12-04 01:51:37 +0100 |
---|---|---|
committer | Christian Halstrick <christian.halstrick@sap.com> | 2020-12-17 18:42:00 +0100 |
commit | 1ed6353962296a3f70d6673d68dc4784f2766c4e (patch) | |
tree | 863ef88c85dcbfbf136304ea4e66d6e159315727 /org.eclipse.jgit.test/tst/org | |
parent | cc7a1891ee383af61d0982fd8b8313ba68987b3c (diff) | |
download | jgit-1ed6353962296a3f70d6673d68dc4784f2766c4e.tar.gz jgit-1ed6353962296a3f70d6673d68dc4784f2766c4e.zip |
[spotbugs] Fix potential NPE in PackFileSnapshotTest
Path#getFileName can return null. Fix the warning by asserting the file
name isn't null.
Change-Id: I7f2fe75b46113d8be1d14e3f18dd77da27df25ed
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileSnapshotTest.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileSnapshotTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileSnapshotTest.java index ac65c33621..1f1e094385 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileSnapshotTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileSnapshotTest.java @@ -11,6 +11,7 @@ package org.eclipse.jgit.internal.storage.file; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; @@ -208,8 +209,11 @@ public class PackFileSnapshotTest extends RepositoryTestCase { // Repack to create initial packfile. Make a copy of it PackFile pf = repackAndCheck(5, null, null, null); Path packFilePath = pf.getPackFile().toPath(); - Path packFileBasePath = packFilePath.resolveSibling( - packFilePath.getFileName().toString().replaceAll(".pack", "")); + Path fn = packFilePath.getFileName(); + assertNotNull(fn); + String packFileName = fn.toString(); + Path packFileBasePath = packFilePath + .resolveSibling(packFileName.replaceAll(".pack", "")); AnyObjectId chk1 = pf.getPackChecksum(); String name = pf.getPackName(); Long length = Long.valueOf(pf.getPackFile().length()); |