Skip to content

Commit

Permalink
Add a servlet which can cause thread leak
Browse files Browse the repository at this point in the history
  • Loading branch information
k-tamura committed Feb 20, 2017
1 parent dc5f747 commit dd31f86
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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) {
}
}
}
}
2 changes: 2 additions & 0 deletions src/main/resources/indexpage_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ function.description.database.connection.leak=Database connection leak occurs ev
(&nbsp;<span class="glyphicon glyphicon-info-sign"></span>&nbsp; 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
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/indexpage_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ function.description.database.connection.leak=\u30da\u30fc\u30b8\u3092\u30ed\u30
(&nbsp;<span class="glyphicon glyphicon-info-sign"></span>&nbsp; \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
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
key="function.name.file.descriptor.leak" /></a> :
<fmt:message key="function.description.file.descriptor.leak" />
</p></li>
<li><p>
<a href="threadleak" target="_blank"><fmt:message
key="function.name.thread.leak" /></a>:
<fmt:message key="function.description.thread.leak" />
</p></li>
</ul>

<h2>
Expand Down

0 comments on commit dd31f86

Please sign in to comment.