This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new b6016b0 [PERF] Re-use a regex in FileSystemBlobStrategy
b6016b0 is described below
commit b6016b02765b639bc1c4fffc4c114950bf0cf908
Author: Benoit Tellier <[email protected]>
AuthorDate: Sat Feb 19 17:24:11 2022 +0700
[PERF] Re-use a regex in FileSystemBlobStrategy
---
.../org/apache/james/queue/activemq/FileSystemBlobStrategy.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git
a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java
b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java
index 3568e5c..91c2b38 100644
---
a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java
+++
b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java
@@ -26,6 +26,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.security.SecureRandom;
+import java.util.regex.Pattern;
import javax.jms.JMSException;
@@ -44,12 +45,13 @@ import org.apache.james.filesystem.api.FileSystem;
* {@link BlobMessage}
*/
public class FileSystemBlobStrategy implements BlobUploadStrategy,
BlobDownloadStrategy, ActiveMQSupport {
+ private static final Pattern PATTERN = Pattern.compile("[:\\\\/*?|<>]");
+ private static final SecureRandom RANDOM = new SecureRandom();
private final FileSystem fileSystem;
private final BlobTransferPolicy policy;
private final int splitCount;
private final Object lock = new Object();
- private static final SecureRandom RANDOM = new SecureRandom();
public FileSystemBlobStrategy(BlobTransferPolicy policy, FileSystem
fileSystem, int splitCount) {
this.fileSystem = fileSystem;
@@ -116,7 +118,7 @@ public class FileSystemBlobStrategy implements
BlobUploadStrategy, BlobDownloadS
// Make sure it works on windows in all cases and make sure
// we use the JMS Message ID as filename so we are safe in the case
// we try to stream from and to the same mail
- String filename =
message.getJMSMessageID().replaceAll("[:\\\\/*?|<>]", "_");
+ String filename =
PATTERN.matcher(message.getJMSMessageID()).replaceAll("_");
int i = RANDOM.nextInt(splitCount) + 1;
String queueUrl = policy.getUploadUrl() + "/" + i;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]