summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit
diff options
context:
space:
mode:
authorJames Moger <james.moger@gmail.com>2015-06-30 08:48:35 -0400
committerJames Moger <james.moger@gmail.com>2015-06-30 08:48:35 -0400
commitb5c7332f5976cc19ab681ed4b82501a62c6a2f61 (patch)
tree2216dc503fd52a6ad95b3d173e5d6621cf0b4c1f /src/main/java/com/gitblit
parent009226281fbca9b49a61719e70f5e1327f491169 (diff)
parent2f361800ae381f365c5f33fbc2c5e3ffd5b90e2b (diff)
downloadgitblit-b5c7332f5976cc19ab681ed4b82501a62c6a2f61.tar.gz
gitblit-b5c7332f5976cc19ab681ed4b82501a62c6a2f61.zip
Merge pull request #277 from mrjoel/mrjoel-serverNPEfix
NPE server fix
Diffstat (limited to 'src/main/java/com/gitblit')
-rw-r--r--src/main/java/com/gitblit/GitBlitServer.java35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/main/java/com/gitblit/GitBlitServer.java b/src/main/java/com/gitblit/GitBlitServer.java
index a1fd071f..d56d9c0c 100644
--- a/src/main/java/com/gitblit/GitBlitServer.java
+++ b/src/main/java/com/gitblit/GitBlitServer.java
@@ -509,22 +509,25 @@ public class GitBlitServer {
@Override
public void run() {
- logger.info("Shutdown Monitor listening on port " + socket.getLocalPort());
- Socket accept;
- try {
- accept = socket.accept();
- BufferedReader reader = new BufferedReader(new InputStreamReader(
- accept.getInputStream()));
- reader.readLine();
- logger.info(Constants.BORDER);
- logger.info("Stopping " + Constants.NAME);
- logger.info(Constants.BORDER);
- server.stop();
- server.setStopAtShutdown(false);
- accept.close();
- socket.close();
- } catch (Exception e) {
- logger.warn("Failed to shutdown Jetty", e);
+ // Only run if the socket was able to be created (not already in use, failed to bind, etc.)
+ if (null != socket) {
+ logger.info("Shutdown Monitor listening on port " + socket.getLocalPort());
+ Socket accept;
+ try {
+ accept = socket.accept();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ accept.getInputStream()));
+ reader.readLine();
+ logger.info(Constants.BORDER);
+ logger.info("Stopping " + Constants.NAME);
+ logger.info(Constants.BORDER);
+ server.stop();
+ server.setStopAtShutdown(false);
+ accept.close();
+ socket.close();
+ } catch (Exception e) {
+ logger.warn("Failed to shutdown Jetty", e);
+ }
}
}
}