Skip to content

Commit

Permalink
Merge pull request #149 from mimecast/dependabot/maven/org.json-json-…
Browse files Browse the repository at this point in the history
…20241224

Bump org.json:json from 20240303 to 20241224
  • Loading branch information
vmarian2 authored Jan 2, 2025
2 parents 53fc2e8 + 35c8cd5 commit 1fc4342
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 29 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,3 @@ jobs:
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<groupId>com.mimecast</groupId>
<artifactId>robin</artifactId>
<name>robin</name>
<version>1.3.1-SNAPSHOT</version>
<version>1.3.2-SNAPSHOT</version>
<packaging>jar</packaging>
<description>Debug and development tool for MTA architects.</description>

<properties>
<jdk.version>11</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javamail.version>1.6.2</javamail.version>
<guava.version>33.3.1-jre</guava.version>
<log4j.version>2.24.1</log4j.version>
<guava.version>33.4.0-jre</guava.version>
<log4j.version>2.24.3</log4j.version>
<jmh.version>1.37</jmh.version>
</properties>

Expand Down Expand Up @@ -67,7 +67,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.17.0</version>
<version>2.18.0</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
Expand All @@ -87,7 +87,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20240303</version>
<version>20241224</version>
</dependency>
<dependency>
<groupId>com.googlecode.juniversalchardet</groupId>
Expand Down Expand Up @@ -134,14 +134,14 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.11.3</version>
<version>5.11.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.11.3</version>
<version>1.11.4</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -186,7 +186,7 @@
<!-- JUnit 5 requires Surefire version 2.22.0 or higher -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.1</version>
<version>3.5.2</version>
<configuration>
<skipTests>false</skipTests>
<skip>false</skip>
Expand All @@ -213,7 +213,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.10.1</version>
<version>3.11.2</version>
<configuration>
<stylesheetfile>${basedir}/src/main/resources/javadoc.css</stylesheetfile>
<show>private</show>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,7 @@ protected Pair<Map, String> getObjectMap() {
public String getFile(String path) {
StringBuilder stringBuilder = new StringBuilder();

try {
LineInputStream stream = new LineInputStream(new MagicInputStream(new FileInputStream(path)));

try (LineInputStream stream = new LineInputStream(new MagicInputStream(new FileInputStream(path)))) {
byte[] bytes;
while ((bytes = stream.readLine()) != null) {
stringBuilder.append(Magic.magicReplace(new String(bytes), connection.getSession()));
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/com/mimecast/robin/main/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ public class Client extends Foundation {
/**
* Session instance.
*/
private Session session;
protected Session session;

/**
* Connection instance.
*/
private Connection connection;
protected Connection connection;

/**
* Have assertions been skipped?
*/
protected Boolean skipped = false;

/**
* Constructs a new RequestClient instance with given Session instance.
* Constructs a new Client instance with given Session instance.
*
* @param session Session instance.
*/
Expand Down Expand Up @@ -85,14 +85,21 @@ public Client send(CaseConfig caseConfig) throws AssertException {
session.map(caseConfig);

// Send.
EmailDelivery emailDelivery = new EmailDelivery(session).send();
connection = emailDelivery.getConnection();
deliver();

// Assert.
assertion(connection);
return this;
}

/**
* Deliver email.
*/
protected void deliver() {
EmailDelivery emailDelivery = new EmailDelivery(session).send();
connection = emailDelivery.getConnection();
}

/**
* Assert delivery successfull if any.
*
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/mimecast/robin/main/RequestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ public RequestClient request(String casePath) throws AssertException, IOExceptio
return this;
}

protected String getUrlHost(String url) {
/**
* Gets host from URL.
*
* @param url URL string.
* @return hostname string.
*/
public static String getUrlHost(String url) {
try {
return new URI(url).getHost();
} catch (URISyntaxException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ protected InputStream getStream(Connection connection, boolean bdat) throws IOEx
Map<String, String> headers = envelope.getHeaders();
if (!headers.isEmpty()) {
List<String> prependHeaders = new ArrayList<>();
headers.forEach((name, value) -> {
prependHeaders.add(name + ": " + value + "\r\n");
});
headers.forEach((name, value) -> prependHeaders.add(name + ": " + value + "\r\n"));
inputStream = new SequenceInputStream(Collections.enumeration(Arrays.asList(new ByteArrayInputStream(String.join("", prependHeaders).getBytes()), inputStream)));
}
}
Expand Down Expand Up @@ -153,7 +151,10 @@ protected boolean processData(String verb, InputStream inputStream) throws IOExc
if (envelope.getTerminateAfterBytes() > 0) {
log.debug("Terminating after {} bytes.", envelope.getTerminateAfterBytes());
envelope.setTerminateBeforeDot(true);
inputStream = new BoundedInputStream(inputStream, envelope.getTerminateAfterBytes());
inputStream = BoundedInputStream.builder()
.setInputStream(inputStream)
.setMaxCount(envelope.getTerminateAfterBytes())
.get();
}

connection.stream(
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/mimecast/robin/storage/StorageCleaner.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ public static void cleanDirectory(File directory, boolean remove, List<Pattern>
} else {
for (Pattern p : patterns) {
if (p.matcher(file.getName()).find()) {
file.delete();
log.trace("Removed file: {}", file.getAbsolutePath());
if (file.delete()) {
log.trace("Removed file: {}", file.getAbsolutePath());
}
break;
}
}
Expand All @@ -72,8 +73,9 @@ public static void cleanDirectory(File directory, boolean remove, List<Pattern>

files = directory.listFiles();
if (remove && files != null && files.length == 0) {
directory.delete();
log.debug("Removed folder: {}", directory.getAbsolutePath());
if (directory.delete()) {
log.debug("Removed folder: {}", directory.getAbsolutePath());
}
}

} catch (Exception e) {
Expand Down

0 comments on commit 1fc4342

Please sign in to comment.