mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-25 18:17:37 +01:00
Better exception handling.
This commit is contained in:
parent
89c8d564a4
commit
38ee8657e8
@ -79,6 +79,7 @@ public class MapManager extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void renderFullWorld(Location l) {
|
void renderFullWorld(Location l) {
|
||||||
|
synchronized (lock) {
|
||||||
debugger.debug("Full render starting...");
|
debugger.debug("Full render starting...");
|
||||||
for (MapType map : maps) {
|
for (MapType map : maps) {
|
||||||
HashSet<MapTile> found = new HashSet<MapTile>();
|
HashSet<MapTile> found = new HashSet<MapTile>();
|
||||||
@ -135,6 +136,7 @@ public class MapManager extends Thread {
|
|||||||
}
|
}
|
||||||
debugger.debug("Full render finished.");
|
debugger.debug("Full render finished.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private MapType[] loadMapTypes(ConfigurationNode configuration) {
|
private MapType[] loadMapTypes(ConfigurationNode configuration) {
|
||||||
List<?> configuredMaps = (List<?>) configuration.getProperty("maps");
|
List<?> configuredMaps = (List<?>) configuration.getProperty("maps");
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.dynmap.web;
|
package org.dynmap.web;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public interface HttpHandler {
|
public interface HttpHandler {
|
||||||
void handle(String path, HttpRequest request, HttpResponse response) throws IOException;
|
void handle(String path, HttpRequest request, HttpResponse response) throws Exception;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public class HttpServerConnection extends Thread {
|
|||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
socket.setSoTimeout(30000);
|
socket.setSoTimeout(5000);
|
||||||
|
|
||||||
HttpRequest request = new HttpRequest();
|
HttpRequest request = new HttpRequest();
|
||||||
if (!readRequestHeader(socket.getInputStream(), request)) {
|
if (!readRequestHeader(socket.getInputStream(), request)) {
|
||||||
@ -106,10 +106,13 @@ public class HttpServerConnection extends Thread {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
handler.handle(relativePath, request, response);
|
handler.handle(relativePath, request, response);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.log(Level.SEVERE, "HttpHandler '" + handler + "' has thown an exception", e);
|
log.log(Level.SEVERE, "HttpHandler '" + handler + "' has thown an exception", e);
|
||||||
e.printStackTrace();
|
if (socket != null) {
|
||||||
socket.close();
|
socket.close();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.dynmap.web.handlers;
|
package org.dynmap.web.handlers;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -16,7 +15,7 @@ public class ClientConfigurationHandler implements HttpHandler {
|
|||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void handle(String path, HttpRequest request, HttpResponse response) throws IOException {
|
public void handle(String path, HttpRequest request, HttpResponse response) throws Exception {
|
||||||
String s = Json.stringifyJson(configuration);
|
String s = Json.stringifyJson(configuration);
|
||||||
|
|
||||||
byte[] bytes = s.getBytes();
|
byte[] bytes = s.getBytes();
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.dynmap.web.handlers;
|
package org.dynmap.web.handlers;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -26,7 +25,7 @@ public class ClientUpdateHandler implements HttpHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(String path, HttpRequest request, HttpResponse response) throws IOException {
|
public void handle(String path, HttpRequest request, HttpResponse response) throws Exception {
|
||||||
long current = System.currentTimeMillis();
|
long current = System.currentTimeMillis();
|
||||||
long cutoff = 0;
|
long cutoff = 0;
|
||||||
|
|
||||||
|
@ -56,9 +56,11 @@ public abstract class FileHandler implements HttpHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(String path, HttpRequest request, HttpResponse response) throws IOException {
|
public void handle(String path, HttpRequest request, HttpResponse response) throws Exception {
|
||||||
|
InputStream fileInput = null;
|
||||||
|
try {
|
||||||
path = formatPath(path);
|
path = formatPath(path);
|
||||||
InputStream fileInput = getFileInput(path);
|
fileInput = getFileInput(path);
|
||||||
if (fileInput == null) {
|
if (fileInput == null) {
|
||||||
response.statusCode = 404;
|
response.statusCode = 404;
|
||||||
response.statusMessage = "Not found";
|
response.statusMessage = "Not found";
|
||||||
@ -81,5 +83,11 @@ public abstract class FileHandler implements HttpHandler {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
fileInput.close();
|
fileInput.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (fileInput != null) {
|
||||||
|
try { fileInput.close(); } catch (IOException ex) { }
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user