From 74344a924e831284d222e4b71bc2f45bc7e4d32a Mon Sep 17 00:00:00 2001 From: James Moger Date: Thu, 17 Apr 2014 22:51:54 -0400 Subject: [PATCH] [findbugs] Reorder asserts to avoid potential NPE in JGitUtilsTest --- src/test/java/com/gitblit/tests/JGitUtilsTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/gitblit/tests/JGitUtilsTest.java b/src/test/java/com/gitblit/tests/JGitUtilsTest.java index 05bea915..68cb4f86 100644 --- a/src/test/java/com/gitblit/tests/JGitUtilsTest.java +++ b/src/test/java/com/gitblit/tests/JGitUtilsTest.java @@ -420,6 +420,11 @@ public class JGitUtilsTest extends GitblitUnitTest { String contentA = JGitUtils.getStringContent(repository, (RevTree) null, "java.java"); RevCommit commit = JGitUtils.getCommit(repository, Constants.HEAD); String contentB = JGitUtils.getStringContent(repository, commit.getTree(), "java.java"); + + assertTrue("ContentA is null!", contentA != null && contentA.length() > 0); + assertTrue("ContentB is null!", contentB != null && contentB.length() > 0); + assertTrue(contentA.equals(contentB)); + String contentC = JGitUtils.getStringContent(repository, commit.getTree(), "missing.txt"); // manually construct a blob, calculate the hash, lookup the hash in git @@ -429,9 +434,6 @@ public class JGitUtilsTest extends GitblitUnitTest { String sha1 = StringUtils.getSHA1(sb.toString()); String contentD = JGitUtils.getStringContent(repository, sha1); repository.close(); - assertTrue("ContentA is null!", contentA != null && contentA.length() > 0); - assertTrue("ContentB is null!", contentB != null && contentB.length() > 0); - assertTrue(contentA.equals(contentB)); assertNull(contentC); assertTrue(contentA.equals(contentD)); } -- 2.39.5