Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
gessnerfl committed Sep 7, 2023
1 parent 11e44c8 commit 62d59bc
Show file tree
Hide file tree
Showing 4 changed files with 1,510 additions and 1,062 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "pl.allegro.tech.build.axion-release" version "1.15.3"
id "org.springframework.boot" version "3.1.1"
id "org.sonarqube" version "4.2.1.3168"
id "pl.allegro.tech.build.axion-release" version "1.15.4"
id "org.springframework.boot" version "3.1.3"
id "org.sonarqube" version "4.3.1.3277"
id 'com.google.cloud.tools.jib' version '3.3.2'
id "com.github.node-gradle.node" version "5.0.0"
}
Expand Down Expand Up @@ -48,12 +48,12 @@ dependencies {
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
implementation('org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0')

runtimeOnly("com.h2database:h2:2.1.214")
runtimeOnly("com.h2database:h2:2.2.222")
runtimeOnly("io.micrometer:micrometer-registry-prometheus")

testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.ow2.asm:asm:9.5")
testImplementation("org.apache.commons:commons-lang3:3.12.0")
testImplementation("org.apache.commons:commons-lang3:3.13.0")
testImplementation("org.hamcrest:hamcrest-core:2.2")
}

Expand Down Expand Up @@ -144,7 +144,7 @@ jacocoTestReport {

jib {
from {
image = 'amazoncorretto:17.0.7-al2023-headless'
image = 'amazoncorretto:17.0.8-al2023-headless'
container {
ports = ["8080", "8081", "8025"]
creationTime = 'USE_CURRENT_TIMESTAMP'
Expand Down
97 changes: 49 additions & 48 deletions src/main/java/de/gessnerfl/fakesmtp/smtp/command/DataCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

import de.gessnerfl.fakesmtp.smtp.RejectException;
import de.gessnerfl.fakesmtp.smtp.io.DotTerminatedInputStream;
Expand All @@ -11,51 +10,53 @@
import de.gessnerfl.fakesmtp.smtp.server.Session;

public class DataCommand extends BaseCommand {
private static final int BUFFER_SIZE = 1024 * 32; // 32k seems reasonable

public DataCommand() {
super(CommandVerb.DATA, "Following text is collected as the message.\n" + "End data with <CR><LF>.<CR><LF>");
}

@Override
public void execute(final String commandString, final Session sess) throws IOException {
if (!sess.isMailTransactionInProgress()) {
sess.sendResponse("503 5.5.1 Error: need MAIL command");
return;
}
if (sess.getRecipientCount() == 0) {
sess.sendResponse("503 Error: need RCPT command");
return;
}

sess.sendResponse("354 End data with <CR><LF>.<CR><LF>");

InputStream stream = sess.getRawInput();
stream = new BufferedInputStream(stream, BUFFER_SIZE);
stream = new DotTerminatedInputStream(stream);
stream = new DotUnstuffingInputStream(stream);
stream = new ReceivedHeaderStream(stream,
sess.getHelo(),
sess.getRemoteAddress().getAddress(),
sess.getServer().getHostName(),
sess.getServer().getSoftwareName(),
sess.getSessionId(),
sess.getSingleRecipient());

try {
sess.getMessageHandler().data(stream);
while (stream.read() != -1) {
// Just in case the handler didn't consume all the data, we might as well
// suck it up so it doesn't pollute further exchanges. This code used to
// throw an exception, but this seems an arbitrary part of the contract that
// we might as well relax.
}
} catch (final RejectException ex) {
sess.sendResponse(ex.getErrorResponse());
return;
}

sess.sendResponse("250 Ok");
sess.resetMailTransaction();
}
private static final int BUFFER_SIZE = 1024 * 32; // 32k seems reasonable

public DataCommand() {
super(CommandVerb.DATA, "Following text is collected as the message.\n" + "End data with <CR><LF>.<CR><LF>");
}

@Override
public void execute(final String commandString, final Session sess) throws IOException {
if (!sess.isMailTransactionInProgress()) {
sess.sendResponse("503 5.5.1 Error: need MAIL command");
return;
}
if (sess.getRecipientCount() == 0) {
sess.sendResponse("503 Error: need RCPT command");
return;
}

sess.sendResponse("354 End data with <CR><LF>.<CR><LF>");

final var rhs = buildReceivedHeaderStream(sess);
try {
sess.getMessageHandler().data(rhs);
while (rhs.read() != -1) {
// Just in case the handler didn't consume all the data, we might as well
// suck it up so it doesn't pollute further exchanges. This code used to
// throw an exception, but this seems an arbitrary part of the contract that
// we might as well relax.
}
} catch (final RejectException ex) {
sess.sendResponse(ex.getErrorResponse());
return;
}

sess.sendResponse("250 Ok");
sess.resetMailTransaction();
}

private static ReceivedHeaderStream buildReceivedHeaderStream(Session sess) {
final var bis = new BufferedInputStream(sess.getRawInput(), BUFFER_SIZE);
final var btis = new DotTerminatedInputStream(bis);
final var duis = new DotUnstuffingInputStream(btis);
return new ReceivedHeaderStream(duis,
sess.getHelo(),
sess.getRemoteAddress().getAddress(),
sess.getServer().getHostName(),
sess.getServer().getSoftwareName(),
sess.getSessionId(),
sess.getSingleRecipient());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,6 @@ public void sessionEnded(final Session session) {
connectionPermits.release();
}

private static final class SocketSession {
final Socket socket;
final Session session;

public SocketSession(Socket socket, Session session) {
this.socket = socket;
this.session = session;
}
private record SocketSession(Socket socket, Session session) {
}
}
Loading

0 comments on commit 62d59bc

Please sign in to comment.