Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Commit 2dd28be

Browse files
committed
exception supression fix
1 parent 79bedb1 commit 2dd28be

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/ktt/lib/httpserver/ExchangePacket.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ static ExchangePacket createExchangePacket(HttpExchange exchange, HttpServer ser
196196
* @see #hasPost()
197197
* @since 01.00.00
198198
*/
199+
@SuppressWarnings("rawtypes")
199200
public abstract HashMap getPostMap();
200201

201202
/**

src/ktt/lib/httpserver/RequestHandler.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import ktt.lib.httpserver.http.HTTPCode;
44

55
import java.io.IOException;
6+
import java.io.UncheckedIOException;
67

78
/**
89
* <i>This class is a simplified implementation of {@link com.sun.net.httpserver.HttpHandler}.</i>
@@ -17,14 +18,13 @@
1718
public abstract class RequestHandler implements Authenticator {
1819

1920
/**
20-
* Handles the given request and generates a response; returns code 500 error if no response is sent. Information from the client is provided in an {@link ExchangePacket}. <b>Exceptions thrown are suppressed by the handler and will not throw a response.</b>
21+
* Handles the given request and generates a response; returns code 500 error if no response is sent. Information from the client is provided in an {@link ExchangePacket}.
2122
* @param packet a packet of data containing client information
2223
* @throws IOException internal failure
23-
* @throws Exception any exceptions thrown within the handler
2424
* @see ExchangePacket
2525
* @since 01.00.00
2626
*/
27-
public abstract void handle(ExchangePacket packet) throws Exception;
27+
public abstract void handle(ExchangePacket packet) throws IOException;
2828

2929
/**
3030
* Encapsulates the {@link #handle(ExchangePacket)} for the authenticator. Applications do not normally use this class.
@@ -35,15 +35,16 @@ final void _consume(ExchangePacket packet) {
3535
if(authenticate(packet)){
3636
try {
3737
handle(packet);
38-
} catch (Exception ignored) { /* internal failure */ }
38+
} catch (IOException e) {
39+
throw new UncheckedIOException(e);
40+
}
3941
}else{
4042
try {
4143
packet.send(HTTPCode.HTTP_Unauthorized);
42-
} catch (IOException e) { /* severe failure */ }
44+
} catch (IOException e) {
45+
throw new UncheckedIOException(e);
46+
}
4347
}
44-
try {
45-
packet.send(500);
46-
} catch (IOException ignored) { /* severe failure */ }
4748
packet.close();
4849
}
4950

src/ktt/lib/httpserver/handler/PredicateHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public PredicateHandler(RequestHandler T, RequestHandler F, Predicate<ExchangePa
3434
}
3535

3636
@Override
37-
public final void handle(ExchangePacket packet) throws Exception {
37+
public final void handle(ExchangePacket packet) {
3838
if(predicate.test(packet)){
3939
T.handle(packet);
4040
}else{

0 commit comments

Comments
 (0)