From fbe265fa787e4be9cb63c6bae2ef30b9400d9afc Mon Sep 17 00:00:00 2001
From: Simon Harrer <simon.harrer@gmail.com>
Date: Thu, 18 Jul 2013 10:11:04 -0400
Subject: [PATCH] Fixes findbugs warning - dereferencing null in exception case

---
 src/main/java/com/gitblit/git/GitDaemon.java |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/gitblit/git/GitDaemon.java b/src/main/java/com/gitblit/git/GitDaemon.java
index 3c45171..b760fbc 100644
--- a/src/main/java/com/gitblit/git/GitDaemon.java
+++ b/src/main/java/com/gitblit/git/GitDaemon.java
@@ -245,8 +245,8 @@
 					//
 				} finally {
 					acceptSocket = null;
-					acceptThread = null;
 				}
+
 			}
 		};
 		acceptThread.start();
@@ -261,9 +261,9 @@
 
 	/** Stop this daemon. */
 	public synchronized void stop() {
-		if (acceptThread != null) {
-			logger.info("Git Daemon stopping...");
+		if (isRunning() && acceptThread != null) {
 			run.set(false);
+			logger.info("Git Daemon stopping...");
 			try {
 				// close the accept socket
 				// this throws a SocketException in the accept thread
@@ -276,6 +276,8 @@
 				logger.info("Git Daemon stopped.");
 			} catch (InterruptedException e) {
 				logger.error("Accept thread join interrupted", e);
+			} finally {
+				acceptThread = null;
 			}
 		}
 	}

--
Gitblit v1.9.1