From dd31f86bb35d1622ebb8d31d38b22ee8a9a04f07 Mon Sep 17 00:00:00 2001 From: Kohei Tamura Date: Mon, 20 Feb 2017 15:01:10 +0900 Subject: [PATCH] Add a servlet which can cause thread leak --- .../easybuggy/troubles/ThreadLeakServlet.java | 36 +++++++++++++++++++ src/main/resources/indexpage_en.properties | 2 ++ src/main/resources/indexpage_ja.properties | 2 ++ src/main/resources/messages_en.properties | 1 + src/main/resources/messages_ja.properties | 1 + src/main/webapp/index.jsp | 5 +++ 6 files changed, 47 insertions(+) create mode 100644 src/main/java/org/t246osslab/easybuggy/troubles/ThreadLeakServlet.java diff --git a/src/main/java/org/t246osslab/easybuggy/troubles/ThreadLeakServlet.java b/src/main/java/org/t246osslab/easybuggy/troubles/ThreadLeakServlet.java new file mode 100644 index 00000000..b3df5bf4 --- /dev/null +++ b/src/main/java/org/t246osslab/easybuggy/troubles/ThreadLeakServlet.java @@ -0,0 +1,36 @@ +package org.t246osslab.easybuggy.troubles; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.t246osslab.easybuggy.utils.HTTPResponseCreator; +import org.t246osslab.easybuggy.utils.MessageUtils; + +@SuppressWarnings("serial") +@WebServlet(urlPatterns = { "/threadleak" }) +public class ThreadLeakServlet extends HttpServlet { + + protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + SubThread sub = new SubThread(); + sub.start(); + StringBuilder bodyHtml = new StringBuilder(); + bodyHtml.append(MessageUtils.getMsg("msg.thread.leak.occur", req.getLocale())); + HTTPResponseCreator.createSimpleResponse(res, null, bodyHtml.toString()); + } +} + +class SubThread extends Thread { + public void run() { + while (true) { + try { + Thread.sleep(100000); + } catch (InterruptedException e) { + } + } + } +} diff --git a/src/main/resources/indexpage_en.properties b/src/main/resources/indexpage_en.properties index aa7c2313..1970220e 100644 --- a/src/main/resources/indexpage_en.properties +++ b/src/main/resources/indexpage_en.properties @@ -28,6 +28,8 @@ function.description.database.connection.leak=Database connection leak occurs ev (   Database connection leak occurs if using an external RDBMS such as MySQL) function.name.file.descriptor.leak=File Descriptor Leak function.description.file.descriptor.leak=File descriptor leak occurs every time you load the page. +function.name.thread.leak=Thread Leak +function.description.thread.leak=Thread leak occurs every time you load the page. section.performance.issue=Performance Issue diff --git a/src/main/resources/indexpage_ja.properties b/src/main/resources/indexpage_ja.properties index 80d489bd..5f2fb526 100644 --- a/src/main/resources/indexpage_ja.properties +++ b/src/main/resources/indexpage_ja.properties @@ -28,6 +28,8 @@ function.description.database.connection.leak=\u30da\u30fc\u30b8\u3092\u30ed\u30 (   \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u30ea\u30fc\u30af\u306f\u3001MySQL\u306a\u3069\u306e\u5916\u90e8RDBMS\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u306b\u306e\u307f\u767a\u751f\u3057\u307e\u3059) function.name.file.descriptor.leak=\u30d5\u30a1\u30a4\u30eb\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30bf\u30ea\u30fc\u30af function.description.file.descriptor.leak=\u30da\u30fc\u30b8\u3092\u30ed\u30fc\u30c9\u3059\u308b\u305f\u3073\u306b\u3001\u30d5\u30a1\u30a4\u30eb\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30bf\u30ea\u30fc\u30af\u304c\u767a\u751f\u3057\u307e\u3059\u3002 +function.name.thread.leak=\u30b9\u30ec\u30c3\u30c9\u30ea\u30fc\u30af +function.description.thread.leak=\u30da\u30fc\u30b8\u3092\u30ed\u30fc\u30c9\u3059\u308b\u305f\u3073\u306b\u3001\u30b9\u30ec\u30c3\u30c9\u30ea\u30fc\u30af\u304c\u767a\u751f\u3057\u307e\u3059\u3002 section.performance.issue=\u6027\u80fd\u554f\u984c diff --git a/src/main/resources/messages_en.properties b/src/main/resources/messages_en.properties index ef0cc973..6cb2d8f2 100644 --- a/src/main/resources/messages_en.properties +++ b/src/main/resources/messages_en.properties @@ -62,6 +62,7 @@ msg.socket.leak.occur=Network socket leak occurs every time you load this page. msg.unknown.exception.occur=Unknown exception occurs. msg.update.records=Updated {0} records. msg.select.asc.or.desc=You can update recordes, inserted in a table of RDBMS, in ascending or descending order of ID. +msg.thread.leak.occur=Thread leak occurs every time you load this page. msg.valid.json=Valid JSON! msg.warn.select.asc.or.desc=Please select "asc" or "desc" and click the Update button. msg.warn.enter.name.and.passwd=Please enter your name and password. diff --git a/src/main/resources/messages_ja.properties b/src/main/resources/messages_ja.properties index 97216a4f..d1882222 100644 --- a/src/main/resources/messages_ja.properties +++ b/src/main/resources/messages_ja.properties @@ -62,6 +62,7 @@ msg.socket.leak.occur=\u3053\u306e\u30da\u30fc\u30b8\u3092\u8aad\u307f\u8fbc\u30 msg.unknown.exception.occur=\u4e0d\u660e\u306a\u4f8b\u5916\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002 msg.update.records={0}\u4ef6\u66f4\u65b0\u3057\u307e\u3057\u305f\u3002 msg.select.asc.or.desc=RDBMS\u306e\u30c6\u30fc\u30d6\u30eb\u3067\u7ba1\u7406\u3055\u308c\u305f\u30ec\u30b3\u30fc\u30c9\u3092\u3001ID\u306e\u300c\u6607\u9806\u300d\u307e\u305f\u306f\u300c\u964d\u9806\u300d\u3067\u9806\u6b21\u66f4\u65b0\u3057\u307e\u3059\u3002 +msg.thread.leak.occur=\u3053\u306e\u30da\u30fc\u30b8\u3092\u8aad\u307f\u8fbc\u3080\u305f\u3073\u306b\u3001\u30b9\u30ec\u30c3\u30c9\u30ea\u30fc\u30af\u304c\u767a\u751f\u3057\u307e\u3059\u3002 msg.valid.json=JSON\u3068\u3057\u3066\u6b63\u3057\u3044\u5f62\u5f0f\u3067\u3059\u3002 msg.warn.select.asc.or.desc=\u300c\u6607\u9806\u300d\u307e\u305f\u306f\u300c\u964d\u9806\u300d\u3092\u9078\u629e\u3057\u3066\u3001\u66f4\u65b0\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u4e0b\u3055\u3044\u3002 msg.warn.enter.name.and.passwd=\u540d\u524d\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002 diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index beb2205e..a0f37242 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -88,6 +88,11 @@ key="function.name.file.descriptor.leak" /> :

+
  • + : + +