-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove all checked exception servlets and add some unchecked exception
servlets
- Loading branch information
Showing
21 changed files
with
364 additions
and
143 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/org/t246osslab/easybuggy/exceptions/BufferOverflowExceptionServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.t246osslab.easybuggy.exceptions; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.io.RandomAccessFile; | ||
import java.nio.MappedByteBuffer; | ||
import java.nio.channels.FileChannel; | ||
import java.nio.channels.FileChannel.MapMode; | ||
|
||
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.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@SuppressWarnings("serial") | ||
@WebServlet(urlPatterns = { "/boe" }) | ||
public class BufferOverflowExceptionServlet extends HttpServlet { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(BufferOverflowExceptionServlet.class); | ||
|
||
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | ||
try { | ||
File f = new File("test.txt"); | ||
RandomAccessFile raf = new RandomAccessFile(f, "rw"); | ||
FileChannel ch = raf.getChannel(); | ||
MappedByteBuffer buf = ch.map(MapMode.READ_WRITE, 0, f.length()); | ||
final byte[] src = new byte[10]; | ||
buf.put(src); | ||
} catch (FileNotFoundException e) { | ||
log.error("FileNotFoundException occurs: ", e); | ||
} catch (IOException e) { | ||
log.error("IOException occurs: ", e); | ||
} | ||
} | ||
} |
9 changes: 4 additions & 5 deletions
9
...buggy/exceptions/IIOExceptionServlet.java → ...ions/BufferUnderflowExceptionServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
package org.t246osslab.easybuggy.exceptions; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.ByteBuffer; | ||
|
||
import javax.imageio.ImageIO; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
@SuppressWarnings("serial") | ||
@WebServlet(urlPatterns = { "/iioe" }) | ||
public class IIOExceptionServlet extends HttpServlet { | ||
@WebServlet(urlPatterns = { "/bue" }) | ||
public class BufferUnderflowExceptionServlet extends HttpServlet { | ||
|
||
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | ||
ImageIO.read(new File("not-exist-file-names")); | ||
ByteBuffer.wrap(new byte[]{1}).getDouble(); | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
...ceptions/UnknownHostExceptionServlet.java → ...xceptions/CannotRedoExceptionServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
package org.t246osslab.easybuggy.exceptions; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
|
||
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 javax.swing.undo.UndoManager; | ||
|
||
@SuppressWarnings("serial") | ||
@WebServlet(urlPatterns = { "/uhe" }) | ||
public class UnknownHostExceptionServlet extends HttpServlet { | ||
@WebServlet(urlPatterns = { "/cre" }) | ||
public class CannotRedoExceptionServlet extends HttpServlet { | ||
|
||
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | ||
new URL("https://nonexisting.com/nonexisting").openStream(); | ||
new UndoManager().redo(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/org/t246osslab/easybuggy/exceptions/CannotUndoExceptionServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.t246osslab.easybuggy.exceptions; | ||
|
||
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 javax.swing.undo.UndoManager; | ||
|
||
@SuppressWarnings("serial") | ||
@WebServlet(urlPatterns = { "/cue" }) | ||
public class CannotUndoExceptionServlet extends HttpServlet { | ||
|
||
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | ||
new UndoManager().undo(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/org/t246osslab/easybuggy/exceptions/EmptyStackExceptionServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.t246osslab.easybuggy.exceptions; | ||
|
||
import java.io.IOException; | ||
import java.util.Stack; | ||
|
||
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.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@SuppressWarnings("serial") | ||
@WebServlet(urlPatterns = { "/ese" }) | ||
public class EmptyStackExceptionServlet extends HttpServlet { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(EmptyStackExceptionServlet.class); | ||
|
||
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | ||
Stack<String> stack = new Stack<String>(); | ||
String tmp = null; | ||
while (null != (tmp = (String) stack.pop())) { | ||
log.debug("Stack.pop(): " + tmp); | ||
} | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
src/main/java/org/t246osslab/easybuggy/exceptions/FileNotFoundExceptionServlet.java
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
src/main/java/org/t246osslab/easybuggy/exceptions/IllegalMonitorStateExceptionServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.t246osslab.easybuggy.exceptions; | ||
|
||
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.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@SuppressWarnings("serial") | ||
@WebServlet(urlPatterns = { "/imse" }) | ||
public class IllegalMonitorStateExceptionServlet extends HttpServlet { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(IllegalMonitorStateExceptionServlet.class); | ||
|
||
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | ||
Thread thread = new Thread(); | ||
thread.start(); | ||
try { | ||
thread.wait(); | ||
} catch (InterruptedException e) { | ||
log.error("InterruptedException occurs: ", e); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/org/t246osslab/easybuggy/exceptions/IllegalPathStateExceptionServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.t246osslab.easybuggy.exceptions; | ||
|
||
import java.awt.geom.GeneralPath; | ||
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; | ||
|
||
@SuppressWarnings("serial") | ||
@WebServlet(urlPatterns = { "/ipse" }) | ||
public class IllegalPathStateExceptionServlet extends HttpServlet { | ||
|
||
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | ||
GeneralPath subPath = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 100); | ||
subPath.closePath(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/t246osslab/easybuggy/exceptions/IllegalStateExceptionServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.t246osslab.easybuggy.exceptions; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
@SuppressWarnings("serial") | ||
@WebServlet(urlPatterns = { "/iase" }) | ||
public class IllegalStateExceptionServlet extends HttpServlet { | ||
|
||
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | ||
List<String> alphabet = new ArrayList<String>(Arrays.asList("a", "b, c")); | ||
for (final Iterator<String> itr = alphabet.iterator(); itr.hasNext();) { | ||
itr.remove(); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/t246osslab/easybuggy/exceptions/ImagingOpExceptionServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.t246osslab.easybuggy.exceptions; | ||
|
||
import java.awt.geom.AffineTransform; | ||
import java.awt.image.AffineTransformOp; | ||
import java.awt.image.BufferedImage; | ||
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; | ||
|
||
@SuppressWarnings("serial") | ||
@WebServlet(urlPatterns = { "/imoe" }) | ||
public class ImagingOpExceptionServlet extends HttpServlet { | ||
|
||
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | ||
BufferedImage img = new BufferedImage(1, 40000, BufferedImage.TYPE_INT_RGB); | ||
AffineTransformOp flipAtop = new AffineTransformOp(AffineTransform.getScaleInstance(1, 1), | ||
AffineTransformOp.TYPE_NEAREST_NEIGHBOR); | ||
flipAtop.filter(img, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/org/t246osslab/easybuggy/exceptions/NoSuchElementExceptionServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.t246osslab.easybuggy.exceptions; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
@SuppressWarnings("serial") | ||
@WebServlet(urlPatterns = { "/nsee" }) | ||
public class NoSuchElementExceptionServlet extends HttpServlet { | ||
|
||
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | ||
new ArrayList<String>().iterator().next(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/org/t246osslab/easybuggy/exceptions/UnsupportedOperationExceptionServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.t246osslab.easybuggy.exceptions; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
@SuppressWarnings("serial") | ||
@WebServlet(urlPatterns = { "/uoe" }) | ||
public class UnsupportedOperationExceptionServlet extends HttpServlet { | ||
|
||
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | ||
List<String> alphabet = Arrays.asList("a", "b", "c"); | ||
Iterator<String> i = alphabet.iterator(); | ||
while(i.hasNext()){ | ||
String name = i.next(); | ||
if(!name.equals("a")){ | ||
i.remove(); | ||
} | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ybuggy/others/IntegerOverflowServlet.java → ...uggy/troubles/IntegerOverflowServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...y/others/LossOfTrailingDigitsServlet.java → ...troubles/LossOfTrailingDigitsServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...asybuggy/others/RoundOffErrorServlet.java → ...ybuggy/troubles/RoundOffErrorServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ybuggy/others/TruncationErrorServlet.java → ...uggy/troubles/TruncationErrorServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.