Fix code stylings

This commit is contained in:
Blue (Lukas Rieger) 2020-10-04 12:38:09 +02:00
parent 961e65b3b3
commit 981a12e349
No known key found for this signature in database
GPG Key ID: 904C4995F9E1F800
4 changed files with 39 additions and 39 deletions

View File

@ -127,11 +127,11 @@ public class Plugin {
}
webServer = new WebServer(
webServerConfig.getWebserverPort(),
webServerConfig.getWebserverMaxConnections(),
webServerConfig.getWebserverBindAdress(),
requestHandler,
false
webServerConfig.getWebserverPort(),
webServerConfig.getWebserverMaxConnections(),
webServerConfig.getWebserverBindAdress(),
requestHandler,
false
);
webServer.start();
}

View File

@ -46,21 +46,21 @@ public class HttpConnection implements Runnable {
private Socket connection;
private InputStream in;
private OutputStream out;
private final boolean verbose;
public HttpConnection(ServerSocket server, Socket connection, HttpRequestHandler handler, int timeout, TimeUnit timeoutUnit, boolean verbose) throws IOException {
this.server = server;
this.connection = connection;
this.handler = handler;
this.verbose = verbose;
if (isClosed()){
throw new IOException("Socket already closed!");
}
connection.setSoTimeout((int) timeoutUnit.toMillis(timeout));
in = this.connection.getInputStream();
out = this.connection.getOutputStream();
}
@ -91,42 +91,42 @@ public class HttpConnection implements Runnable {
break;
}
}
try {
close();
} catch (IOException e){
Logger.global.logError("Error while closing HttpConnection!", e);
}
}
private void log(HttpRequest request, HttpResponse response) {
private void log(HttpRequest request, HttpResponse response) {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
Logger.global.logInfo(
connection.getInetAddress().toString()
+ " [ "
+ dateFormat.format(date)
+ " ] \""
+ request.getMethod()
+ " " + request.getPath()
+ " " + request.getVersion()
+ "\" "
+ response.getStatusCode().toString());
}
connection.getInetAddress().toString()
+ " [ "
+ dateFormat.format(date)
+ " ] \""
+ request.getMethod()
+ " " + request.getPath()
+ " " + request.getVersion()
+ "\" "
+ response.getStatusCode().toString());
}
private void sendResponse(HttpResponse response) throws IOException {
response.write(out);
out.flush();
}
private HttpRequest acceptRequest() throws ConnectionClosedException, InvalidRequestException, IOException {
return HttpRequest.read(in);
}
public boolean isClosed(){
return !connection.isBound() || connection.isClosed() || !connection.isConnected() || connection.isOutputShutdown() || connection.isInputShutdown();
}
public void close() throws IOException {
try {
in.close();
@ -138,13 +138,13 @@ public class HttpConnection implements Runnable {
}
}
}
public static class ConnectionClosedException extends IOException {
private static final long serialVersionUID = 1L;
}
public static class InvalidRequestException extends IOException {
private static final long serialVersionUID = 1L;
}
}

View File

@ -41,7 +41,7 @@ public class WebServer extends Thread {
private final int port;
private final int maxConnections;
private final InetAddress bindAdress;
private final boolean verbose;
private final boolean verbose;
private HttpRequestHandler handler;

View File

@ -234,13 +234,13 @@ public class BlueMapCLI {
WebServerConfig config = blueMap.getWebServerConfig();
HttpRequestHandler requestHandler = new FileRequestHandler(config.getWebRoot().toPath(), "BlueMap v" + BlueMap.VERSION);
WebServer webServer = new WebServer(
config.getWebserverPort(),
config.getWebserverMaxConnections(),
config.getWebserverBindAdress(),
requestHandler,
verbose
config.getWebserverPort(),
config.getWebserverMaxConnections(),
config.getWebserverBindAdress(),
requestHandler,
verbose
);
webServer.start();
}
@ -375,9 +375,9 @@ public class BlueMapCLI {
.desc("Sets the minecraft-version, used e.g. to load resource-packs correctly. Defaults to the latest compatible version.")
.build()
);
options.addOption("w", "webserver", false, "Starts the web-server, configured in the 'webserver.conf' file");
options.addOption("b", "verbose", false, "Causes the web-server to log requests to the console");
options.addOption("b", "verbose", false, "Causes the web-server to log requests to the console");
options.addOption("g", "generate-webapp", false, "Generates the files for the web-app to the folder, configured in the 'render.conf' file (this is done automatically when rendering if the 'index.html' file in the webroot can't be found)");
options.addOption("s", "generate-websettings", false, "Generates the settings for the web-app, using the settings from the 'render.conf' file (this is done automatically when rendering)");