Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wizzardo committed Oct 9, 2023
1 parent 7c45ad6 commit 2bbafa0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
5 changes: 0 additions & 5 deletions src/main/java/com/wizzardo/http/AbstractHttpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ protected IOThread<? extends T> createIOThread(int number, int divider) {
};
} else {
server = new FallbackServerSocket<T>(host, port, this) {
@Override
public void onRead(T connection, ByteBufferProvider bufferProvider) throws IOException {
process(connection, bufferProvider);
}

@Override
protected SelectorConnectionWrapper createConnection(SocketChannel client) throws IOException {
SelectorConnectionWrapper connection = super.createConnection(client);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/wizzardo/http/FallbackServerSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ public void close() {
IOTools.close(data);

IOTools.close(channel);
try {
onDisconnect(ByteBufferProvider.current());
} catch (IOException ignored) {
}
}

@Override
Expand Down Expand Up @@ -420,6 +424,7 @@ protected SelectorConnectionWrapper createConnection(SocketChannel client) throw
}

public void onRead(T connection, ByteBufferProvider bufferProvider) throws IOException {
connection.onRead(bufferProvider);
}

@Override
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/wizzardo/http/HttpWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ protected void process(T connection) throws IOException {
if (!connection.processingBy.compareAndSet(null, this))
return;

connection.process(this);

connection.processingBy.set(null);
try {
connection.process(this);
} finally {
connection.processingBy.set(null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,11 @@ protected static Mapper<Request, Object> createPojoMapper(Class type, String par

if (request.isMultipart()) {
MultiPartEntry entry = request.entry(parameterName);
if (entry != null && entry.contentType().toLowerCase().startsWith(Header.VALUE_APPLICATION_JSON.value)) {
return JsonTools.parse(entry.asBytes(), type);
if (entry != null) {
String entryContentType = entry.contentType();
if (entryContentType != null && entryContentType.toLowerCase().startsWith(Header.VALUE_APPLICATION_JSON.value)) {
return JsonTools.parse(entry.asBytes(), type);
}
}
}

Expand Down

0 comments on commit 2bbafa0

Please sign in to comment.