Skip to content

Commit

Permalink
Remove all checked exception servlets and add some unchecked exception
Browse files Browse the repository at this point in the history
servlets
  • Loading branch information
k-tamura committed Mar 21, 2017
1 parent d1010b5 commit f040c6e
Show file tree
Hide file tree
Showing 21 changed files with 364 additions and 143 deletions.
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);
}
}
}
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();
}
}
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();
}
}
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();
}
}
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);
}
}
}

This file was deleted.

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);
}
}
}
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();
}
}
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();
}
}
}
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);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.t246osslab.easybuggy.exceptions;

import java.io.IOException;
import java.util.Scanner;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
Expand All @@ -9,10 +10,10 @@
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
@WebServlet(urlPatterns = { "/uee" })
public class UnsupportedEncodingExceptionServlet extends HttpServlet {
@WebServlet(urlPatterns = { "/ime" })
public class InputMismatchExceptionServlet extends HttpServlet {

protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
req.setCharacterEncoding("Unsupported-Encoding");
new Scanner("a").nextInt();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.t246osslab.easybuggy.exceptions;

import java.io.IOException;
import java.net.URL;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
Expand All @@ -10,10 +9,10 @@
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
@WebServlet(urlPatterns = { "/murle" })
public class MalformedURLExceptionServlet extends HttpServlet {
@WebServlet(urlPatterns = { "/nase" })
public class NegativeArraySizeExceptionServlet extends HttpServlet {

protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
new URL("test");
int[] intArray = new int[-1];
}
}
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();
}
}
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();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.t246osslab.easybuggy.others;
package org.t246osslab.easybuggy.troubles;

import java.io.IOException;
import java.math.BigDecimal;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.t246osslab.easybuggy.others;
package org.t246osslab.easybuggy.troubles;

import java.io.IOException;
import java.util.Locale;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.t246osslab.easybuggy.others;
package org.t246osslab.easybuggy.troubles;

import java.io.IOException;
import java.util.Locale;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.t246osslab.easybuggy.others;
package org.t246osslab.easybuggy.troubles;

import java.io.IOException;
import java.util.Locale;
Expand Down
Loading

0 comments on commit f040c6e

Please sign in to comment.