From 30d26a2cc91c2f3d20ce7182c5997fb848781dd5 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Thu, 28 Aug 2014 20:25:10 +0400 Subject: [PATCH] github: fix test * fix NPE on tearDown() * do not call super.tearDown() on exception in beforeTest() --- .../jetbrains/plugins/github/test/GithubTest.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/github/test/org/jetbrains/plugins/github/test/GithubTest.java b/plugins/github/test/org/jetbrains/plugins/github/test/GithubTest.java index 3d3d8201e03a..80930814c791 100644 --- a/plugins/github/test/org/jetbrains/plugins/github/test/GithubTest.java +++ b/plugins/github/test/org/jetbrains/plugins/github/test/GithubTest.java @@ -176,17 +176,19 @@ public abstract class GithubTest extends GitPlatformTest { myHttpAuthService = (GitHttpAuthTestService)ServiceManager.getService(GitHttpAuthService.class); - try { beforeTest(); } catch (Exception e) { try { - tearDown(); + afterTest(); } catch (Exception e2) { e2.printStackTrace(); } + finally { + cleanup(); + } throw e; } } @@ -197,11 +199,15 @@ public abstract class GithubTest extends GitPlatformTest { afterTest(); } finally { - myHttpAuthService.cleanup(); + cleanup(); super.tearDown(); } } + private void cleanup() { + if (myHttpAuthService != null) myHttpAuthService.cleanup(); + } + protected void beforeTest() throws Exception { }