You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ma...@apache.org on 2020/04/30 07:28:36 UTC
[james-project] branch master updated (5e69e0d -> 22d8d93)
This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git.
from 5e69e0d [Refactoring] use a strong type for IMAP MessageSequenceNumber
new aab25b3 [REFACTORING] Remove unused DefaultQuotaModule
new 152aa7d [REFACTORING] MailboxProbeImpl should not rely on mappers
new 647969b [Refactoring] Move Authenticator from mailbox-store to mailbox-api
new 0693d91 [Refactoring] Move Authorizator from mailbox-store to mailbox-api
new ba679b6 [Refactoring] cleanup mailbox-adapter and mpt-imapmailbox-core modules from mailbox-store dependency
new 8035b7d Merge branch 'pr-3341'
new a3b3a20 MAILET-166 AutomaticSentMailDetectorImpl should not fail above 1MB
new fe27fd6 MAILET-166 Remove AutomaticallySentMailDetectorImpl steam limit
new ddfe53f Merge branch 'pr-3337'
new 4c456e2 JAMES-3140: cache when read with the same rule with save, add test
new 22d8d93 JAMES-3140: Hiding technical details into class for CachedBlobStore
The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/james/mailbox}/Authenticator.java | 2 +-
.../org/apache/james/mailbox}/Authorizator.java | 2 +-
.../cassandra/CassandraMailboxManagerProvider.java | 4 +-
.../cassandra/CassandraTestSystemFixture.java | 4 +-
.../CassandraMailboxManagerAttachmentTest.java | 4 +-
...asticSearchListeningMessageSearchIndexTest.java | 2 +-
.../mailbox/jpa/JpaMailboxManagerProvider.java | 4 +-
.../maildir/MaildirMailboxManagerProvider.java | 4 +-
.../manager/InMemoryIntegrationResources.java | 4 +-
.../mailbox/spring/AnonymousAuthenticator.java | 62 ++++----
.../james/mailbox/spring/NoAuthorizator.java | 62 ++++----
.../james/mailbox/store/FakeAuthenticator.java | 1 +
.../james/mailbox/store/FakeAuthorizator.java | 1 +
.../james/mailbox/store/SessionProviderImpl.java | 2 +
.../base/AutomaticallySentMailDetectorImpl.java | 2 +-
.../AutomaticallySentMailDetectorImplTest.java | 53 +++++++
mpt/impl/imap-mailbox/core/pom.xml | 5 -
.../apache/james/mpt/host/JamesImapHostSystem.java | 8 +-
.../blob/cassandra/cache/CachedBlobStore.java | 166 ++++++++++++++++-----
.../blob/cassandra/cache/CachedBlobStoreTest.java | 124 ++++++++++++---
server/container/guice/cassandra-guice/pom.xml | 4 +
.../modules/mailbox/CassandraMailboxModule.java | 8 +-
server/container/guice/jpa-guice/pom.xml | 4 +
.../james/modules/mailbox/JPAMailboxModule.java | 8 +-
server/container/guice/mailbox/pom.xml | 6 +-
.../org/apache/james/modules/MailboxProbeImpl.java | 14 +-
.../james/modules/mailbox/DefaultQuotaModule.java | 49 ------
server/container/guice/memory-guice/pom.xml | 4 +
.../james/modules/mailbox/MemoryMailboxModule.java | 8 +-
server/container/mailbox-adapter/pom.xml | 4 -
.../{store => }/UserRepositoryAuthenticator.java | 4 +-
.../{store => }/UserRepositoryAuthorizator.java | 4 +-
.../UserRepositoryAuthenticatorTest.java | 2 +-
.../UserRepositoryAuthorizatorTest.java | 4 +-
.../apache/james/spring-mailbox-authenticator.xml | 2 +-
.../apache/james/spring-mailbox-authorizator.xml | 2 +-
src/site/xdoc/mailbox/mailbox-spring.xml | 2 +-
37 files changed, 404 insertions(+), 241 deletions(-)
rename mailbox/{store/src/main/java/org/apache/james/mailbox/store => api/src/main/java/org/apache/james/mailbox}/Authenticator.java (97%)
rename mailbox/{store/src/main/java/org/apache/james/mailbox/store => api/src/main/java/org/apache/james/mailbox}/Authorizator.java (97%)
delete mode 100644 server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultQuotaModule.java
rename server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/{store => }/UserRepositoryAuthenticator.java (95%)
rename server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/{store => }/UserRepositoryAuthorizator.java (95%)
rename server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/{store => }/UserRepositoryAuthenticatorTest.java (98%)
rename server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/{store => }/UserRepositoryAuthorizatorTest.java (97%)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 05/11: [Refactoring] cleanup mailbox-adapter and
mpt-imapmailbox-core modules from mailbox-store dependency
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit ba679b608797b5ed9d454e882e3e9e91b7ca8ba5
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Wed Apr 29 10:48:48 2020 +0700
[Refactoring] cleanup mailbox-adapter and mpt-imapmailbox-core modules from mailbox-store dependency
---
mpt/impl/imap-mailbox/core/pom.xml | 5 -----
.../main/java/org/apache/james/mpt/host/JamesImapHostSystem.java | 4 ++--
server/container/guice/cassandra-guice/pom.xml | 4 ++++
.../org/apache/james/modules/mailbox/CassandraMailboxModule.java | 4 ++--
server/container/guice/jpa-guice/pom.xml | 4 ++++
.../java/org/apache/james/modules/mailbox/JPAMailboxModule.java | 4 ++--
server/container/guice/mailbox/pom.xml | 6 +++---
server/container/guice/memory-guice/pom.xml | 4 ++++
.../java/org/apache/james/modules/mailbox/MemoryMailboxModule.java | 4 ++--
server/container/mailbox-adapter/pom.xml | 4 ----
.../adapter/mailbox/{store => }/UserRepositoryAuthenticator.java | 2 +-
.../adapter/mailbox/{store => }/UserRepositoryAuthorizator.java | 2 +-
.../mailbox/{store => }/UserRepositoryAuthenticatorTest.java | 2 +-
.../adapter/mailbox/{store => }/UserRepositoryAuthorizatorTest.java | 2 +-
.../META-INF/org/apache/james/spring-mailbox-authenticator.xml | 2 +-
.../META-INF/org/apache/james/spring-mailbox-authorizator.xml | 2 +-
16 files changed, 29 insertions(+), 26 deletions(-)
diff --git a/mpt/impl/imap-mailbox/core/pom.xml b/mpt/impl/imap-mailbox/core/pom.xml
index 41c8144..30bf0f6 100644
--- a/mpt/impl/imap-mailbox/core/pom.xml
+++ b/mpt/impl/imap-mailbox/core/pom.xml
@@ -37,11 +37,6 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-store</artifactId>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
<artifactId>apache-james-mpt-core</artifactId>
</dependency>
<dependency>
diff --git a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java
index cd365f3..b15d28e 100644
--- a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java
+++ b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java
@@ -23,8 +23,8 @@ import org.apache.commons.configuration2.HierarchicalConfiguration;
import org.apache.commons.configuration2.ex.ConfigurationException;
import org.apache.commons.configuration2.plist.PropertyListConfiguration;
import org.apache.commons.configuration2.tree.ImmutableNode;
-import org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator;
-import org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator;
+import org.apache.james.adapter.mailbox.UserRepositoryAuthenticator;
+import org.apache.james.adapter.mailbox.UserRepositoryAuthorizator;
import org.apache.james.core.Username;
import org.apache.james.domainlist.api.DomainList;
import org.apache.james.imap.api.ImapConfiguration;
diff --git a/server/container/guice/cassandra-guice/pom.xml b/server/container/guice/cassandra-guice/pom.xml
index 07abf29..4c277fa 100644
--- a/server/container/guice/cassandra-guice/pom.xml
+++ b/server/container/guice/cassandra-guice/pom.xml
@@ -258,6 +258,10 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>james-server-mailbox-adapter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>james-server-mailets</artifactId>
</dependency>
<dependency>
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
index 172aca2..7630f5e 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
@@ -22,8 +22,8 @@ import static org.apache.james.modules.Names.MAILBOXMANAGER_NAME;
import javax.inject.Singleton;
-import org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator;
-import org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator;
+import org.apache.james.adapter.mailbox.UserRepositoryAuthenticator;
+import org.apache.james.adapter.mailbox.UserRepositoryAuthorizator;
import org.apache.james.backends.cassandra.components.CassandraModule;
import org.apache.james.mailbox.AttachmentContentLoader;
import org.apache.james.mailbox.AttachmentManager;
diff --git a/server/container/guice/jpa-guice/pom.xml b/server/container/guice/jpa-guice/pom.xml
index a647d38..2b7fef3 100644
--- a/server/container/guice/jpa-guice/pom.xml
+++ b/server/container/guice/jpa-guice/pom.xml
@@ -151,6 +151,10 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>james-server-mailbox-adapter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>james-server-mailets</artifactId>
</dependency>
<dependency>
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
index 0d44707..2f589ab 100644
--- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
+++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
@@ -22,8 +22,8 @@ import static org.apache.james.modules.Names.MAILBOXMANAGER_NAME;
import javax.inject.Singleton;
-import org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator;
-import org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator;
+import org.apache.james.adapter.mailbox.UserRepositoryAuthenticator;
+import org.apache.james.adapter.mailbox.UserRepositoryAuthorizator;
import org.apache.james.mailbox.AttachmentContentLoader;
import org.apache.james.mailbox.Authenticator;
import org.apache.james.mailbox.Authorizator;
diff --git a/server/container/guice/mailbox/pom.xml b/server/container/guice/mailbox/pom.xml
index 01efd03..ecc3efa 100644
--- a/server/container/guice/mailbox/pom.xml
+++ b/server/container/guice/mailbox/pom.xml
@@ -48,15 +48,15 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-guice-configuration</artifactId>
+ <artifactId>apache-james-mailbox-store</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-guice-utils</artifactId>
+ <artifactId>james-server-guice-configuration</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-mailbox-adapter</artifactId>
+ <artifactId>james-server-guice-utils</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
diff --git a/server/container/guice/memory-guice/pom.xml b/server/container/guice/memory-guice/pom.xml
index a84a22f..59311ee 100644
--- a/server/container/guice/memory-guice/pom.xml
+++ b/server/container/guice/memory-guice/pom.xml
@@ -180,6 +180,10 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>james-server-mailbox-adapter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>james-server-mailets</artifactId>
</dependency>
<dependency>
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
index bf0fd08..6f42336 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
@@ -23,8 +23,8 @@ import static org.apache.james.modules.Names.MAILBOXMANAGER_NAME;
import javax.inject.Singleton;
-import org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator;
-import org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator;
+import org.apache.james.adapter.mailbox.UserRepositoryAuthenticator;
+import org.apache.james.adapter.mailbox.UserRepositoryAuthorizator;
import org.apache.james.mailbox.AttachmentContentLoader;
import org.apache.james.mailbox.AttachmentManager;
import org.apache.james.mailbox.Authenticator;
diff --git a/server/container/mailbox-adapter/pom.xml b/server/container/mailbox-adapter/pom.xml
index 934db81..8c63d1f 100644
--- a/server/container/mailbox-adapter/pom.xml
+++ b/server/container/mailbox-adapter/pom.xml
@@ -45,10 +45,6 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-store</artifactId>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
<artifactId>james-server-data-api</artifactId>
</dependency>
<dependency>
diff --git a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthenticator.java b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/UserRepositoryAuthenticator.java
similarity index 97%
rename from server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthenticator.java
rename to server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/UserRepositoryAuthenticator.java
index ffd5704..6d346e1 100644
--- a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthenticator.java
+++ b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/UserRepositoryAuthenticator.java
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.adapter.mailbox.store;
+package org.apache.james.adapter.mailbox;
import javax.inject.Inject;
diff --git a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizator.java b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/UserRepositoryAuthorizator.java
similarity index 98%
rename from server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizator.java
rename to server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/UserRepositoryAuthorizator.java
index 7f256d9..bc10c25 100644
--- a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizator.java
+++ b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/UserRepositoryAuthorizator.java
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.adapter.mailbox.store;
+package org.apache.james.adapter.mailbox;
import javax.inject.Inject;
diff --git a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthenticatorTest.java b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthenticatorTest.java
similarity index 98%
rename from server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthenticatorTest.java
rename to server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthenticatorTest.java
index 7ec82b1..60208bd 100644
--- a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthenticatorTest.java
+++ b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthenticatorTest.java
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.adapter.mailbox.store;
+package org.apache.james.adapter.mailbox;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
diff --git a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizatorTest.java b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthorizatorTest.java
similarity index 98%
rename from server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizatorTest.java
rename to server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthorizatorTest.java
index 2c2fe6c..c1c6ca5 100644
--- a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizatorTest.java
+++ b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/UserRepositoryAuthorizatorTest.java
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.adapter.mailbox.store;
+package org.apache.james.adapter.mailbox;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
diff --git a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-authenticator.xml b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-authenticator.xml
index 900b3ed..89501ef 100644
--- a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-authenticator.xml
+++ b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-authenticator.xml
@@ -27,6 +27,6 @@
Mailbox Authenticator
-->
- <bean id="authenticator" class="org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator"/>
+ <bean id="authenticator" class="org.apache.james.adapter.mailbox.UserRepositoryAuthenticator"/>
</beans>
diff --git a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-authorizator.xml b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-authorizator.xml
index 0185042..36cf718 100644
--- a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-authorizator.xml
+++ b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-mailbox-authorizator.xml
@@ -27,6 +27,6 @@
Mailbox Authorizator
-->
- <bean id="authorizator" class="org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator"/>
+ <bean id="authorizator" class="org.apache.james.adapter.mailbox.UserRepositoryAuthorizator"/>
</beans>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 08/11: MAILET-166 Remove
AutomaticallySentMailDetectorImpl steam limit
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit fe27fd6b413f1a50bb6de97b64585a23615c279a
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Apr 29 08:56:35 2020 +0700
MAILET-166 Remove AutomaticallySentMailDetectorImpl steam limit
As the MDN can optionally include the original message, there is no
reason to expect the size to be limited.
Thus increase the size to 100 MB
---
.../base/AutomaticallySentMailDetectorImpl.java | 6 +---
.../AutomaticallySentMailDetectorImplTest.java | 36 +++++++++++++++++++++-
2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java b/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java
index 6b39613..8953599 100644
--- a/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java
+++ b/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java
@@ -92,7 +92,7 @@ public class AutomaticallySentMailDetectorImpl implements AutomaticallySentMailD
public boolean isMdnSentAutomatically(Mail mail) throws MessagingException {
ResultCollector resultCollector = new ResultCollector(false);
MimeStreamParser parser = new MimeStreamParser(MimeConfig.custom()
- .setMaxContentLen(1024 * 1024) // there's no reason for a mdn report to be bigger than 1MiB
+ .setMaxContentLen(100 * 1024 * 1024)
.setMaxHeaderCount(-1)
.setMaxHeaderLen(-1)
.setMaxLineLen(-1)
@@ -104,10 +104,6 @@ public class AutomaticallySentMailDetectorImpl implements AutomaticallySentMailD
} catch (MimeException e) {
throw new MessagingException("Can not parse Mime", e);
} catch (IOException e) {
- // there's no reason for a mdn report to be bigger than 1MiB
- if (e.getMessage().startsWith("Input stream limit exceeded")) {
- return false;
- }
throw new MessagingException("Can not read content", e);
}
return resultCollector.getResult();
diff --git a/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java b/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java
index 309ced8..d65422b 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java
@@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.Properties;
import javax.activation.DataHandler;
+import javax.mail.BodyPart;
import javax.mail.Session;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
@@ -338,7 +339,7 @@ public class AutomaticallySentMailDetectorImplTest {
.addHeaders()
.setMultipartWithBodyParts(
MimeMessageBuilder.bodyPartBuilder()
- .data("12345678\r\n".repeat(150 * 1024)),
+ .data("12345678\r\n".repeat(150 * 1024)), // ~ 1.5 MB
MimeMessageBuilder.bodyPartBuilder()
.data("12345678\r\n"));
@@ -351,4 +352,37 @@ public class AutomaticallySentMailDetectorImplTest {
assertThat(new AutomaticallySentMailDetectorImpl().isMdnSentAutomatically(fakeMail)).isFalse();
}
+ @Test
+ public void isMdnSentAutomaticallyShouldDetectBigMDN() throws Exception {
+
+ MimeMessage message = MimeMessageUtil.defaultMimeMessage();
+ MimeMultipart multipart = new MimeMultipart();
+ MimeBodyPart scriptPart = new MimeBodyPart();
+ scriptPart.setDataHandler(
+ new DataHandler(
+ new ByteArrayDataSource(
+ Joiner.on("\r\n").join(
+ "Final-Recipient: rfc822;any@any.com",
+ "Disposition: automatic-action/MDN-sent-automatically; displayed",
+ ""),
+ "message/disposition-notification;")
+ ));
+ scriptPart.setHeader("Content-Type", "message/disposition-notification");
+ BodyPart bigBody = MimeMessageBuilder.bodyPartBuilder() // ~3MB
+ .data("12345678\r\n".repeat(300 * 1024))
+ .build();
+ multipart.addBodyPart(bigBody);
+ multipart.addBodyPart(scriptPart);
+ message.setContent(multipart);
+ message.saveChanges();
+
+ FakeMail fakeMail = FakeMail.builder()
+ .name("mail")
+ .sender(MailAddressFixture.ANY_AT_JAMES)
+ .mimeMessage(message)
+ .build();
+
+ assertThat(new AutomaticallySentMailDetectorImpl().isMdnSentAutomatically(fakeMail)).isTrue();
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 02/11: [REFACTORING] MailboxProbeImpl should not
rely on mappers
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 152aa7d125c9814ed635e7d984a7acf9a6ae5567
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Apr 29 11:51:19 2020 +0700
[REFACTORING] MailboxProbeImpl should not rely on mappers
---
.../java/org/apache/james/modules/MailboxProbeImpl.java | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java
index 1d5936a..0ca9380 100644
--- a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java
+++ b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java
@@ -34,7 +34,6 @@ import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MessageManager;
import org.apache.james.mailbox.SubscriptionManager;
import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.exception.MailboxNotFoundException;
import org.apache.james.mailbox.model.ComposedMessageId;
import org.apache.james.mailbox.model.MailboxCounters;
import org.apache.james.mailbox.model.MailboxId;
@@ -43,20 +42,16 @@ import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.search.MailboxQuery;
import org.apache.james.mailbox.model.search.Wildcard;
import org.apache.james.mailbox.probe.MailboxProbe;
-import org.apache.james.mailbox.store.mail.MailboxMapper;
-import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
import org.apache.james.utils.GuiceProbe;
public class MailboxProbeImpl implements GuiceProbe, MailboxProbe {
private final MailboxManager mailboxManager;
- private final MailboxMapperFactory mailboxMapperFactory;
private final SubscriptionManager subscriptionManager;
@Inject
- private MailboxProbeImpl(MailboxManager mailboxManager, MailboxMapperFactory mailboxMapperFactory,
+ private MailboxProbeImpl(MailboxManager mailboxManager,
SubscriptionManager subscriptionManager) {
this.mailboxManager = mailboxManager;
- this.mailboxMapperFactory = mailboxMapperFactory;
this.subscriptionManager = subscriptionManager;
}
@@ -85,12 +80,9 @@ public class MailboxProbeImpl implements GuiceProbe, MailboxProbe {
MailboxSession mailboxSession = null;
try {
mailboxSession = mailboxManager.createSystemSession(username);
- MailboxMapper mailboxMapper = mailboxMapperFactory.getMailboxMapper(mailboxSession);
MailboxPath path = new MailboxPath(namespace, username, name);
- return mailboxMapper.findMailboxByPath(path)
- .blockOptional()
- .orElseThrow(() -> new MailboxNotFoundException(path.asString()))
- .getMailboxId();
+ return mailboxManager.getMailbox(path, mailboxSession)
+ .getId();
} catch (MailboxException e) {
throw new RuntimeException(e);
} finally {
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 09/11: Merge branch 'pr-3337'
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit ddfe53fdd3916de06682ec77ac5792e52f8bcab3
Merge: 8035b7d fe27fd6
Author: Matthieu Baechler <ma...@apache.org>
AuthorDate: Thu Apr 30 09:26:40 2020 +0200
Merge branch 'pr-3337'
.../base/AutomaticallySentMailDetectorImpl.java | 2 +-
.../AutomaticallySentMailDetectorImplTest.java | 53 ++++++++++++++++++++++
2 files changed, 54 insertions(+), 1 deletion(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 03/11: [Refactoring] Move Authenticator from
mailbox-store to mailbox-api
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 647969b02c7ba790ebf3e7fa120332ba0b5d7104
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Wed Apr 29 10:35:37 2020 +0700
[Refactoring] Move Authenticator from mailbox-store to mailbox-api
---
.../org/apache/james/mailbox}/Authenticator.java | 2 +-
.../cassandra/CassandraMailboxManagerProvider.java | 2 +-
.../cassandra/CassandraTestSystemFixture.java | 2 +-
.../CassandraMailboxManagerAttachmentTest.java | 2 +-
.../mailbox/jpa/JpaMailboxManagerProvider.java | 2 +-
.../maildir/MaildirMailboxManagerProvider.java | 2 +-
.../manager/InMemoryIntegrationResources.java | 2 +-
.../mailbox/spring/AnonymousAuthenticator.java | 62 +++++++++++-----------
.../james/mailbox/store/FakeAuthenticator.java | 1 +
.../james/mailbox/store/SessionProviderImpl.java | 1 +
.../apache/james/mpt/host/JamesImapHostSystem.java | 2 +-
.../modules/mailbox/CassandraMailboxModule.java | 2 +-
.../james/modules/mailbox/JPAMailboxModule.java | 2 +-
.../james/modules/mailbox/MemoryMailboxModule.java | 2 +-
.../mailbox/store/UserRepositoryAuthenticator.java | 2 +-
src/site/xdoc/mailbox/mailbox-spring.xml | 2 +-
16 files changed, 46 insertions(+), 44 deletions(-)
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/Authenticator.java b/mailbox/api/src/main/java/org/apache/james/mailbox/Authenticator.java
similarity index 97%
rename from mailbox/store/src/main/java/org/apache/james/mailbox/store/Authenticator.java
rename to mailbox/api/src/main/java/org/apache/james/mailbox/Authenticator.java
index 1dd7857..e9173c3 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/Authenticator.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/Authenticator.java
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.mailbox.store;
+package org.apache.james.mailbox;
import org.apache.james.core.Username;
import org.apache.james.mailbox.exception.MailboxException;
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
index f2bdb06..855fa37 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
@@ -21,6 +21,7 @@ package org.apache.james.mailbox.cassandra;
import org.apache.james.backends.cassandra.CassandraCluster;
import org.apache.james.mailbox.AttachmentContentLoader;
+import org.apache.james.mailbox.Authenticator;
import org.apache.james.mailbox.acl.GroupMembershipResolver;
import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
@@ -37,7 +38,6 @@ import org.apache.james.mailbox.events.MemoryEventDeadLetters;
import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
index d87463f..1e92852 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.mock;
import org.apache.james.backends.cassandra.CassandraCluster;
import org.apache.james.mailbox.AttachmentContentLoader;
+import org.apache.james.mailbox.Authenticator;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
@@ -39,7 +40,6 @@ import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
import org.apache.james.mailbox.quota.CurrentQuotaManager;
import org.apache.james.mailbox.quota.MaxQuotaManager;
import org.apache.james.mailbox.quota.QuotaManager;
-import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
index 9ea857c..1e7207c 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.when;
import org.apache.james.backends.cassandra.CassandraClusterExtension;
import org.apache.james.mailbox.AttachmentContentLoader;
+import org.apache.james.mailbox.Authenticator;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
@@ -36,7 +37,6 @@ import org.apache.james.mailbox.events.InVMEventBus;
import org.apache.james.mailbox.events.MemoryEventDeadLetters;
import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
import org.apache.james.mailbox.store.AbstractMailboxManagerAttachmentTest;
-import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
index 8c23ea2..3bbb723 100644
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
@@ -22,6 +22,7 @@ package org.apache.james.mailbox.jpa;
import javax.persistence.EntityManagerFactory;
import org.apache.james.backends.jpa.JpaTestCluster;
+import org.apache.james.mailbox.Authenticator;
import org.apache.james.mailbox.acl.GroupMembershipResolver;
import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
@@ -33,7 +34,6 @@ import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
import org.apache.james.mailbox.jpa.mail.JPAModSeqProvider;
import org.apache.james.mailbox.jpa.mail.JPAUidProvider;
import org.apache.james.mailbox.jpa.openjpa.OpenJPAMailboxManager;
-import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.SessionProviderImpl;
import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
diff --git a/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java b/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
index 6c02820..1724101 100644
--- a/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
+++ b/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
@@ -21,6 +21,7 @@ package org.apache.james.mailbox.maildir;
import java.io.File;
+import org.apache.james.mailbox.Authenticator;
import org.apache.james.mailbox.acl.GroupMembershipResolver;
import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
@@ -29,7 +30,6 @@ import org.apache.james.mailbox.events.EventBusTestFixture;
import org.apache.james.mailbox.events.InVMEventBus;
import org.apache.james.mailbox.events.MemoryEventDeadLetters;
import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
-import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
index b2027a1..d1c32c4 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
@@ -24,6 +24,7 @@ import java.util.Optional;
import java.util.function.Function;
import org.apache.james.mailbox.AttachmentContentLoader;
+import org.apache.james.mailbox.Authenticator;
import org.apache.james.mailbox.MessageIdManager;
import org.apache.james.mailbox.SessionProvider;
import org.apache.james.mailbox.acl.GroupMembershipResolver;
@@ -47,7 +48,6 @@ import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.quota.QuotaManager;
import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.FakeAuthenticator;
import org.apache.james.mailbox.store.FakeAuthorizator;
diff --git a/mailbox/spring/src/main/java/org/apache/james/mailbox/spring/AnonymousAuthenticator.java b/mailbox/spring/src/main/java/org/apache/james/mailbox/spring/AnonymousAuthenticator.java
index 4b99c0f..2daf54d 100644
--- a/mailbox/spring/src/main/java/org/apache/james/mailbox/spring/AnonymousAuthenticator.java
+++ b/mailbox/spring/src/main/java/org/apache/james/mailbox/spring/AnonymousAuthenticator.java
@@ -1,31 +1,31 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one *
- * or more contributor license agreements. See the NOTICE file *
- * distributed with this work for additional information *
- * regarding copyright ownership. The ASF licenses this file *
- * to you under the Apache License, Version 2.0 (the *
- * "License"); you may not use this file except in compliance *
- * with the License. You may obtain a copy of the License at *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, *
- * software distributed under the License is distributed on an *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
- * KIND, either express or implied. See the License for the *
- * specific language governing permissions and limitations *
- * under the License. *
- ****************************************************************/
-package org.apache.james.mailbox.spring;
-
-import org.apache.james.core.Username;
-import org.apache.james.mailbox.store.Authenticator;
-
-public class AnonymousAuthenticator implements Authenticator {
-
- @Override
- public boolean isAuthentic(Username userid, CharSequence passwd) {
- return true;
- }
-
-}
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+package org.apache.james.mailbox.spring;
+
+import org.apache.james.core.Username;
+import org.apache.james.mailbox.Authenticator;
+
+public class AnonymousAuthenticator implements Authenticator {
+
+ @Override
+ public boolean isAuthentic(Username userid, CharSequence passwd) {
+ return true;
+ }
+
+}
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/FakeAuthenticator.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/FakeAuthenticator.java
index a5eefda..a65a02f 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/FakeAuthenticator.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/FakeAuthenticator.java
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.james.core.Username;
+import org.apache.james.mailbox.Authenticator;
public class FakeAuthenticator implements Authenticator {
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/SessionProviderImpl.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/SessionProviderImpl.java
index 4ced852..b454b5b 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/SessionProviderImpl.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/SessionProviderImpl.java
@@ -24,6 +24,7 @@ import java.util.ArrayList;
import javax.inject.Inject;
import org.apache.james.core.Username;
+import org.apache.james.mailbox.Authenticator;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MailboxSessionIdGenerator;
import org.apache.james.mailbox.SessionProvider;
diff --git a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java
index 2abd31d..4f10fc1 100644
--- a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java
+++ b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java
@@ -33,11 +33,11 @@ import org.apache.james.imap.decode.ImapDecoder;
import org.apache.james.imap.decode.main.ImapRequestStreamHandler;
import org.apache.james.imap.encode.FakeImapSession;
import org.apache.james.imap.encode.ImapEncoder;
+import org.apache.james.mailbox.Authenticator;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mpt.api.Continuation;
import org.apache.james.mpt.api.ImapHostSystem;
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
index 03f864e..cd36137 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
@@ -27,6 +27,7 @@ import org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator;
import org.apache.james.backends.cassandra.components.CassandraModule;
import org.apache.james.mailbox.AttachmentContentLoader;
import org.apache.james.mailbox.AttachmentManager;
+import org.apache.james.mailbox.Authenticator;
import org.apache.james.mailbox.BlobManager;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxPathLocker;
@@ -74,7 +75,6 @@ import org.apache.james.mailbox.indexer.MessageIdReIndexer;
import org.apache.james.mailbox.indexer.ReIndexer;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
index 3a9dd02..c8e6520 100644
--- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
+++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
@@ -25,6 +25,7 @@ import javax.inject.Singleton;
import org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator;
import org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator;
import org.apache.james.mailbox.AttachmentContentLoader;
+import org.apache.james.mailbox.Authenticator;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxPathLocker;
import org.apache.james.mailbox.SessionProvider;
@@ -43,7 +44,6 @@ import org.apache.james.mailbox.jpa.mail.JPAUidProvider;
import org.apache.james.mailbox.jpa.openjpa.OpenJPAMailboxManager;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
index 5433f94..d76a379 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
@@ -27,6 +27,7 @@ import org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator;
import org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator;
import org.apache.james.mailbox.AttachmentContentLoader;
import org.apache.james.mailbox.AttachmentManager;
+import org.apache.james.mailbox.Authenticator;
import org.apache.james.mailbox.BlobManager;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxPathLocker;
@@ -44,7 +45,6 @@ import org.apache.james.mailbox.inmemory.mail.InMemoryModSeqProvider;
import org.apache.james.mailbox.inmemory.mail.InMemoryUidProvider;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
diff --git a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthenticator.java b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthenticator.java
index f8b35bd..ffd5704 100644
--- a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthenticator.java
+++ b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthenticator.java
@@ -22,8 +22,8 @@ package org.apache.james.adapter.mailbox.store;
import javax.inject.Inject;
import org.apache.james.core.Username;
+import org.apache.james.mailbox.Authenticator;
import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.user.api.UsersRepository;
import org.apache.james.user.api.UsersRepositoryException;
diff --git a/src/site/xdoc/mailbox/mailbox-spring.xml b/src/site/xdoc/mailbox/mailbox-spring.xml
index 3e37778..950df43 100644
--- a/src/site/xdoc/mailbox/mailbox-spring.xml
+++ b/src/site/xdoc/mailbox/mailbox-spring.xml
@@ -33,7 +33,7 @@
<p>The module is small. It contains just two classes:</p>
<ul>
<li>SpringMailbox - this loads the spring-mailbox.xml </li>
- <li>AnonymousAuthenticator - provides a dummy org.apache.james.mailbox.store.Authenticator</li>
+ <li>AnonymousAuthenticator - provides a dummy org.apache.james.mailbox.Authenticator</li>
</ul>
<p>SpringMailbox class is used to load the spring application context from <em>spring-mailbox.xml</em>
and provides a method to get beans declared in that context.
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 07/11: MAILET-166 AutomaticSentMailDetectorImpl
should not fail above 1MB
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit a3b3a20a821bdef80e64d3a2e17ad33106851dc8
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Apr 28 13:10:22 2020 +0700
MAILET-166 AutomaticSentMailDetectorImpl should not fail above 1MB
---
.../base/AutomaticallySentMailDetectorImpl.java | 4 ++++
.../base/AutomaticallySentMailDetectorImplTest.java | 19 +++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java b/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java
index 5f42cb6..6b39613 100644
--- a/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java
+++ b/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java
@@ -104,6 +104,10 @@ public class AutomaticallySentMailDetectorImpl implements AutomaticallySentMailD
} catch (MimeException e) {
throw new MessagingException("Can not parse Mime", e);
} catch (IOException e) {
+ // there's no reason for a mdn report to be bigger than 1MiB
+ if (e.getMessage().startsWith("Input stream limit exceeded")) {
+ return false;
+ }
throw new MessagingException("Can not read content", e);
}
return resultCollector.getResult();
diff --git a/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java b/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java
index ad4e551..309ced8 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java
@@ -332,4 +332,23 @@ public class AutomaticallySentMailDetectorImplTest {
assertThat(new AutomaticallySentMailDetectorImpl().isMdnSentAutomatically(fakeMail)).isFalse();
}
+ @Test
+ public void isMdnSentAutomaticallyShouldNotThrowWhenBiggerThan1MB() throws Exception {
+ MimeMessageBuilder message = MimeMessageBuilder.mimeMessageBuilder()
+ .addHeaders()
+ .setMultipartWithBodyParts(
+ MimeMessageBuilder.bodyPartBuilder()
+ .data("12345678\r\n".repeat(150 * 1024)),
+ MimeMessageBuilder.bodyPartBuilder()
+ .data("12345678\r\n"));
+
+ FakeMail fakeMail = FakeMail.builder()
+ .name("mail")
+ .sender(MailAddressFixture.ANY_AT_JAMES)
+ .mimeMessage(message)
+ .build();
+
+ assertThat(new AutomaticallySentMailDetectorImpl().isMdnSentAutomatically(fakeMail)).isFalse();
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 01/11: [REFACTORING] Remove unused
DefaultQuotaModule
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit aab25b310ea1614c0b14ff757057cb7deb7f7971
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Apr 29 11:48:13 2020 +0700
[REFACTORING] Remove unused DefaultQuotaModule
---
.../james/modules/mailbox/DefaultQuotaModule.java | 49 ----------------------
1 file changed, 49 deletions(-)
diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultQuotaModule.java b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultQuotaModule.java
deleted file mode 100644
index 46c8b7c..0000000
--- a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultQuotaModule.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one *
- * or more contributor license agreements. See the NOTICE file *
- * distributed with this work for additional information *
- * regarding copyright ownership. The ASF licenses this file *
- * to you under the Apache License, Version 2.0 (the *
- * "License"); you may not use this file except in compliance *
- * with the License. You may obtain a copy of the License at *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, *
- * software distributed under the License is distributed on an *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
- * KIND, either express or implied. See the License for the *
- * specific language governing permissions and limitations *
- * under the License. *
- ****************************************************************/
-
-package org.apache.james.modules.mailbox;
-
-import org.apache.james.mailbox.quota.MaxQuotaManager;
-import org.apache.james.mailbox.quota.QuotaManager;
-import org.apache.james.mailbox.quota.QuotaRootDeserializer;
-import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.quota.UserQuotaRootResolver;
-import org.apache.james.mailbox.store.quota.DefaultUserQuotaRootResolver;
-import org.apache.james.mailbox.store.quota.NoMaxQuotaManager;
-import org.apache.james.mailbox.store.quota.NoQuotaManager;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
-
-public class DefaultQuotaModule extends AbstractModule {
-
- @Override
- protected void configure() {
- bind(NoQuotaManager.class).in(Scopes.SINGLETON);
- bind(DefaultUserQuotaRootResolver.class).in(Scopes.SINGLETON);
- bind(NoMaxQuotaManager.class).in(Scopes.SINGLETON);
-
- bind(MaxQuotaManager.class).toInstance(new NoMaxQuotaManager());
- bind(QuotaManager.class).to(NoQuotaManager.class);
- bind(QuotaRootResolver.class).to(DefaultUserQuotaRootResolver.class);
- bind(QuotaRootDeserializer.class).to(DefaultUserQuotaRootResolver.class);
- bind(UserQuotaRootResolver.class).to(DefaultUserQuotaRootResolver.class);
- }
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 04/11: [Refactoring] Move Authorizator from
mailbox-store to mailbox-api
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 0693d91fa139993fb41532c452089470f0dc2c15
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Wed Apr 29 10:38:00 2020 +0700
[Refactoring] Move Authorizator from mailbox-store to mailbox-api
---
.../org/apache/james/mailbox}/Authorizator.java | 2 +-
.../cassandra/CassandraMailboxManagerProvider.java | 2 +-
.../cassandra/CassandraTestSystemFixture.java | 2 +-
.../CassandraMailboxManagerAttachmentTest.java | 2 +-
...asticSearchListeningMessageSearchIndexTest.java | 2 +-
.../mailbox/jpa/JpaMailboxManagerProvider.java | 2 +-
.../maildir/MaildirMailboxManagerProvider.java | 2 +-
.../manager/InMemoryIntegrationResources.java | 2 +-
.../james/mailbox/spring/NoAuthorizator.java | 62 +++++++++++-----------
.../james/mailbox/store/FakeAuthorizator.java | 1 +
.../james/mailbox/store/SessionProviderImpl.java | 1 +
.../apache/james/mpt/host/JamesImapHostSystem.java | 2 +-
.../modules/mailbox/CassandraMailboxModule.java | 2 +-
.../james/modules/mailbox/JPAMailboxModule.java | 2 +-
.../james/modules/mailbox/MemoryMailboxModule.java | 2 +-
.../mailbox/store/UserRepositoryAuthorizator.java | 2 +-
.../store/UserRepositoryAuthorizatorTest.java | 2 +-
17 files changed, 47 insertions(+), 45 deletions(-)
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/Authorizator.java b/mailbox/api/src/main/java/org/apache/james/mailbox/Authorizator.java
similarity index 97%
rename from mailbox/store/src/main/java/org/apache/james/mailbox/store/Authorizator.java
rename to mailbox/api/src/main/java/org/apache/james/mailbox/Authorizator.java
index f83ab06..82c9f93 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/Authorizator.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/Authorizator.java
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.mailbox.store;
+package org.apache.james.mailbox;
import org.apache.james.core.Username;
import org.apache.james.mailbox.exception.MailboxException;
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
index 855fa37..ab3dc5d 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
@@ -22,6 +22,7 @@ package org.apache.james.mailbox.cassandra;
import org.apache.james.backends.cassandra.CassandraCluster;
import org.apache.james.mailbox.AttachmentContentLoader;
import org.apache.james.mailbox.Authenticator;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.acl.GroupMembershipResolver;
import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
@@ -38,7 +39,6 @@ import org.apache.james.mailbox.events.MemoryEventDeadLetters;
import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
import org.apache.james.mailbox.store.PreDeletionHooks;
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
index 1e92852..bf2c2e8 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.mock;
import org.apache.james.backends.cassandra.CassandraCluster;
import org.apache.james.mailbox.AttachmentContentLoader;
import org.apache.james.mailbox.Authenticator;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
@@ -40,7 +41,6 @@ import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
import org.apache.james.mailbox.quota.CurrentQuotaManager;
import org.apache.james.mailbox.quota.MaxQuotaManager;
import org.apache.james.mailbox.quota.QuotaManager;
-import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
import org.apache.james.mailbox.store.PreDeletionHooks;
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
index 1e7207c..d0e2910 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.when;
import org.apache.james.backends.cassandra.CassandraClusterExtension;
import org.apache.james.mailbox.AttachmentContentLoader;
import org.apache.james.mailbox.Authenticator;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
@@ -37,7 +38,6 @@ import org.apache.james.mailbox.events.InVMEventBus;
import org.apache.james.mailbox.events.MemoryEventDeadLetters;
import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
import org.apache.james.mailbox.store.AbstractMailboxManagerAttachmentTest;
-import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndexTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndexTest.java
index c04d02f..dcbeb0f 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndexTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndexTest.java
@@ -35,6 +35,7 @@ import org.apache.james.backends.es.DockerElasticSearchExtension;
import org.apache.james.backends.es.ElasticSearchIndexer;
import org.apache.james.backends.es.ReactorElasticSearchClient;
import org.apache.james.core.Username;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.DefaultMailboxes;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MessageUid;
@@ -66,7 +67,6 @@ import org.apache.james.mailbox.model.TestId;
import org.apache.james.mailbox.model.TestMessageId;
import org.apache.james.mailbox.model.UidValidity;
import org.apache.james.mailbox.model.UpdatedFlags;
-import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.FakeAuthenticator;
import org.apache.james.mailbox.store.FakeAuthorizator;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
index 3bbb723..79a6cb1 100644
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
@@ -23,6 +23,7 @@ import javax.persistence.EntityManagerFactory;
import org.apache.james.backends.jpa.JpaTestCluster;
import org.apache.james.mailbox.Authenticator;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.acl.GroupMembershipResolver;
import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
@@ -34,7 +35,6 @@ import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
import org.apache.james.mailbox.jpa.mail.JPAModSeqProvider;
import org.apache.james.mailbox.jpa.mail.JPAUidProvider;
import org.apache.james.mailbox.jpa.openjpa.OpenJPAMailboxManager;
-import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.SessionProviderImpl;
import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreRightManager;
diff --git a/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java b/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
index 1724101..c68f597 100644
--- a/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
+++ b/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
@@ -22,6 +22,7 @@ package org.apache.james.mailbox.maildir;
import java.io.File;
import org.apache.james.mailbox.Authenticator;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.acl.GroupMembershipResolver;
import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
@@ -30,7 +31,6 @@ import org.apache.james.mailbox.events.EventBusTestFixture;
import org.apache.james.mailbox.events.InVMEventBus;
import org.apache.james.mailbox.events.MemoryEventDeadLetters;
import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
-import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
import org.apache.james.mailbox.store.PreDeletionHooks;
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
index d1c32c4..0160d39 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
@@ -25,6 +25,7 @@ import java.util.function.Function;
import org.apache.james.mailbox.AttachmentContentLoader;
import org.apache.james.mailbox.Authenticator;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.MessageIdManager;
import org.apache.james.mailbox.SessionProvider;
import org.apache.james.mailbox.acl.GroupMembershipResolver;
@@ -48,7 +49,6 @@ import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.quota.QuotaManager;
import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.FakeAuthenticator;
import org.apache.james.mailbox.store.FakeAuthorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
diff --git a/mailbox/spring/src/main/java/org/apache/james/mailbox/spring/NoAuthorizator.java b/mailbox/spring/src/main/java/org/apache/james/mailbox/spring/NoAuthorizator.java
index 8418ece..1c1c6be 100644
--- a/mailbox/spring/src/main/java/org/apache/james/mailbox/spring/NoAuthorizator.java
+++ b/mailbox/spring/src/main/java/org/apache/james/mailbox/spring/NoAuthorizator.java
@@ -1,31 +1,31 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one *
- * or more contributor license agreements. See the NOTICE file *
- * distributed with this work for additional information *
- * regarding copyright ownership. The ASF licenses this file *
- * to you under the Apache License, Version 2.0 (the *
- * "License"); you may not use this file except in compliance *
- * with the License. You may obtain a copy of the License at *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, *
- * software distributed under the License is distributed on an *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
- * KIND, either express or implied. See the License for the *
- * specific language governing permissions and limitations *
- * under the License. *
- ****************************************************************/
-package org.apache.james.mailbox.spring;
-
-import org.apache.james.core.Username;
-import org.apache.james.mailbox.store.Authorizator;
-
-public class NoAuthorizator implements Authorizator {
-
- @Override
- public AuthorizationState canLoginAsOtherUser(Username userId, Username otherUserId) {
- return AuthorizationState.NOT_ADMIN;
- }
-
-}
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+package org.apache.james.mailbox.spring;
+
+import org.apache.james.core.Username;
+import org.apache.james.mailbox.Authorizator;
+
+public class NoAuthorizator implements Authorizator {
+
+ @Override
+ public AuthorizationState canLoginAsOtherUser(Username userId, Username otherUserId) {
+ return AuthorizationState.NOT_ADMIN;
+ }
+
+}
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/FakeAuthorizator.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/FakeAuthorizator.java
index 7bbc7f6..095f736 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/FakeAuthorizator.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/FakeAuthorizator.java
@@ -21,6 +21,7 @@ package org.apache.james.mailbox.store;
import java.util.Optional;
import org.apache.james.core.Username;
+import org.apache.james.mailbox.Authorizator;
public class FakeAuthorizator implements Authorizator {
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/SessionProviderImpl.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/SessionProviderImpl.java
index b454b5b..c8353bc 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/SessionProviderImpl.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/SessionProviderImpl.java
@@ -25,6 +25,7 @@ import javax.inject.Inject;
import org.apache.james.core.Username;
import org.apache.james.mailbox.Authenticator;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MailboxSessionIdGenerator;
import org.apache.james.mailbox.SessionProvider;
diff --git a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java
index 4f10fc1..cd365f3 100644
--- a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java
+++ b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/host/JamesImapHostSystem.java
@@ -34,11 +34,11 @@ import org.apache.james.imap.decode.main.ImapRequestStreamHandler;
import org.apache.james.imap.encode.FakeImapSession;
import org.apache.james.imap.encode.ImapEncoder;
import org.apache.james.mailbox.Authenticator;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mpt.api.Continuation;
import org.apache.james.mpt.api.ImapHostSystem;
import org.apache.james.mpt.helper.ByteBufferInputStream;
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
index cd36137..172aca2 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
@@ -28,6 +28,7 @@ import org.apache.james.backends.cassandra.components.CassandraModule;
import org.apache.james.mailbox.AttachmentContentLoader;
import org.apache.james.mailbox.AttachmentManager;
import org.apache.james.mailbox.Authenticator;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.BlobManager;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxPathLocker;
@@ -75,7 +76,6 @@ import org.apache.james.mailbox.indexer.MessageIdReIndexer;
import org.apache.james.mailbox.indexer.ReIndexer;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
import org.apache.james.mailbox.store.SessionProviderImpl;
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
index c8e6520..0d44707 100644
--- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
+++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
@@ -26,6 +26,7 @@ import org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator;
import org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator;
import org.apache.james.mailbox.AttachmentContentLoader;
import org.apache.james.mailbox.Authenticator;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxPathLocker;
import org.apache.james.mailbox.SessionProvider;
@@ -44,7 +45,6 @@ import org.apache.james.mailbox.jpa.mail.JPAUidProvider;
import org.apache.james.mailbox.jpa.openjpa.OpenJPAMailboxManager;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
index d76a379..bf0fd08 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
@@ -28,6 +28,7 @@ import org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator;
import org.apache.james.mailbox.AttachmentContentLoader;
import org.apache.james.mailbox.AttachmentManager;
import org.apache.james.mailbox.Authenticator;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.BlobManager;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxPathLocker;
@@ -45,7 +46,6 @@ import org.apache.james.mailbox.inmemory.mail.InMemoryModSeqProvider;
import org.apache.james.mailbox.inmemory.mail.InMemoryUidProvider;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
diff --git a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizator.java b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizator.java
index 85110ae..7f256d9 100644
--- a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizator.java
+++ b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizator.java
@@ -22,8 +22,8 @@ package org.apache.james.adapter.mailbox.store;
import javax.inject.Inject;
import org.apache.james.core.Username;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.user.api.UsersRepository;
import org.apache.james.user.api.UsersRepositoryException;
diff --git a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizatorTest.java b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizatorTest.java
index cfb2750..2c2fe6c 100644
--- a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizatorTest.java
+++ b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/store/UserRepositoryAuthorizatorTest.java
@@ -24,8 +24,8 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.apache.james.core.Username;
+import org.apache.james.mailbox.Authorizator;
import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.user.api.UsersRepository;
import org.apache.james.user.api.UsersRepositoryException;
import org.junit.Before;
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 11/11: JAMES-3140: Hiding technical details into
class for CachedBlobStore
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 22d8d93ee74e4052f6b191c12330a43cbc76445f
Author: ducnv <du...@gmail.com>
AuthorDate: Tue Apr 28 17:17:37 2020 +0700
JAMES-3140: Hiding technical details into class for CachedBlobStore
---
.../blob/cassandra/cache/CachedBlobStore.java | 141 ++++++++++++---------
1 file changed, 84 insertions(+), 57 deletions(-)
diff --git a/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/cache/CachedBlobStore.java b/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/cache/CachedBlobStore.java
index 86aead0..04857e4 100644
--- a/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/cache/CachedBlobStore.java
+++ b/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/cache/CachedBlobStore.java
@@ -42,6 +42,62 @@ import com.google.common.base.Preconditions;
import reactor.core.publisher.Mono;
public class CachedBlobStore implements BlobStore {
+
+ private static class ReadAheadInputStream {
+
+ @FunctionalInterface
+ interface RequireStream {
+ RequireLength of(InputStream in);
+ }
+
+ interface RequireLength {
+ ReadAheadInputStream length(int length) throws IOException;
+ }
+
+
+ static RequireStream eager() {
+ return in -> length -> {
+ //+1 is to evaluate hasMore
+ var stream = new PushbackInputStream(in, length + 1);
+ var bytes = new byte[length];
+ int readByteCount = IOUtils.read(stream, bytes);
+ Optional<byte[]> firstBytes;
+ boolean hasMore;
+ if (readByteCount < 0) {
+ firstBytes = Optional.empty();
+ hasMore = false;
+ } else {
+ byte[] readBytes = Arrays.copyOf(bytes, readByteCount);
+ hasMore = hasMore(stream);
+ stream.unread(readBytes);
+ firstBytes = Optional.of(readBytes);
+ }
+ return new ReadAheadInputStream(stream, firstBytes, hasMore);
+ };
+ }
+
+ private static boolean hasMore(PushbackInputStream stream) throws IOException {
+ int nextByte = stream.read();
+ if (nextByte >= 0) {
+ stream.unread(nextByte);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ final PushbackInputStream in;
+ final Optional<byte[]> firstBytes;
+ final boolean hasMore;
+
+ private ReadAheadInputStream(PushbackInputStream in, Optional<byte[]> firstBytes, boolean hasMore) {
+ this.in = in;
+ this.firstBytes = firstBytes;
+ this.hasMore = hasMore;
+ }
+
+ }
+
private final BlobStoreCache cache;
private final BlobStore backend;
private final Integer sizeThresholdInBytes;
@@ -61,8 +117,10 @@ public class CachedBlobStore implements BlobStore {
.flatMap(ignored -> readFromCache(blobId)
.flatMap(this::toInputStream))
.switchIfEmpty(readFromBackend(bucketName, blobId)
- .map(this::toPushbackStream)
- .flatMap(pushbackInputStream -> saveInCache(pushbackInputStream, blobId, bucketName)))
+ .flatMap(inputStream ->
+ Mono.fromCallable(() -> ReadAheadInputStream.eager().of(inputStream).length(sizeThresholdInBytes))
+ .flatMap(readAheadInputStream -> putInCacheIfNeeded(bucketName, readAheadInputStream, blobId)
+ .thenReturn(readAheadInputStream.in))))
.blockOptional()
.orElseThrow(() -> new ObjectNotFoundException(String.format("Could not retrieve blob metadata for %s", blobId)));
}
@@ -94,8 +152,7 @@ public class CachedBlobStore implements BlobStore {
Preconditions.checkNotNull(inputStream, "InputStream must not be null");
if (isAbleToCache(bucketName, storagePolicy)) {
- return Mono.fromCallable(() -> toPushbackStream(inputStream))
- .flatMap(pushbackInputStream -> saveInCache(bucketName, pushbackInputStream, storagePolicy));
+ return saveInCache(bucketName, inputStream, storagePolicy);
}
return backend.save(bucketName, inputStream, storagePolicy);
@@ -120,64 +177,47 @@ public class CachedBlobStore implements BlobStore {
return Mono.from(backend.deleteBucket(bucketName));
}
- private Optional<byte[]> fullyReadSmallStream(PushbackInputStream pushbackInputStream) throws IOException {
- byte[] bytes = new byte[sizeThresholdInBytes];
- int readByteCount = IOUtils.read(pushbackInputStream, bytes);
- int extraByte = pushbackInputStream.read();
- try {
- if (extraByte >= 0) {
- return Optional.empty();
- }
- if (readByteCount < 0) {
- return Optional.of(new byte[] {});
- }
- return Optional.of(Arrays.copyOf(bytes, readByteCount));
- } finally {
- if (extraByte >= 0) {
- pushbackInputStream.unread(extraByte);
- }
- if (readByteCount > 0) {
- pushbackInputStream.unread(bytes, 0, readByteCount);
- }
- }
+ private Mono<BlobId> saveInCache(BucketName bucketName, InputStream inputStream, StoragePolicy storagePolicy) {
+ return Mono.fromCallable(() -> ReadAheadInputStream.eager().of(inputStream).length(sizeThresholdInBytes))
+ .flatMap(readAhead -> saveToBackend(bucketName, storagePolicy, readAhead)
+ .flatMap(blobId -> putInCacheIfNeeded(bucketName, storagePolicy, readAhead, blobId)
+ .thenReturn(blobId)));
}
- private Mono<BlobId> saveInCache(BucketName bucketName, PushbackInputStream pushbackInputStream, StoragePolicy storagePolicy) {
- return Mono.fromCallable(() -> fullyReadSmallStream(pushbackInputStream))
- .flatMap(Mono::justOrEmpty)
- .filter(bytes -> isAbleToCache(bucketName, bytes, storagePolicy))
- .flatMap(bytes -> saveInBackend(bucketName, pushbackInputStream, storagePolicy)
- .flatMap(blobId -> saveInCache(blobId, bytes).thenReturn(blobId)))
- .switchIfEmpty(saveInBackend(bucketName, pushbackInputStream, storagePolicy));
+ private Mono<BlobId> saveToBackend(BucketName bucketName, StoragePolicy storagePolicy, ReadAheadInputStream readAhead) {
+ return Mono.from(backend.save(bucketName, readAhead.in, storagePolicy));
}
- private Mono<BlobId> saveInBackend(BucketName bucketName, PushbackInputStream pushbackInputStream, StoragePolicy storagePolicy) {
- return Mono.from(backend.save(bucketName, pushbackInputStream, storagePolicy));
+ private Mono<Void> putInCacheIfNeeded(BucketName bucketName, StoragePolicy storagePolicy, ReadAheadInputStream readAhead, BlobId blobId) {
+ return Mono.justOrEmpty(readAhead.firstBytes)
+ .filter(bytes -> isAbleToCache(bucketName, readAhead, storagePolicy))
+ .flatMap(bytes -> Mono.from(cache.cache(blobId, bytes)));
}
- private Mono<Void> saveInCache(BlobId blobId, byte[] bytes) {
- return Mono.from(cache.cache(blobId, bytes));
+ private Mono<Void> putInCacheIfNeeded(BucketName bucketName, ReadAheadInputStream readAhead, BlobId blobId) {
+ return Mono.justOrEmpty(readAhead.firstBytes)
+ .filter(bytes -> isAbleToCache(readAhead, bucketName))
+ .flatMap(bytes -> Mono.from(cache.cache(blobId, bytes)));
}
- private Mono<InputStream> saveInCache(PushbackInputStream pushbackInputStream, BlobId blobId, BucketName bucketName) {
- return Mono.fromCallable(() -> fullyReadSmallStream(pushbackInputStream))
- .flatMap(Mono::justOrEmpty)
- .filter(bytes -> isAbleToCache(bytes, bucketName))
- .flatMap(bytes -> Mono.from(cache.cache(blobId, bytes))
- .map(ignore -> pushbackBytesArrayRead(pushbackInputStream, bytes)))
- .then(Mono.just(pushbackInputStream));
+ private Mono<Void> saveInCache(BlobId blobId, byte[] bytes) {
+ return Mono.from(cache.cache(blobId, bytes));
}
private boolean isAbleToCache(BucketName bucketName, byte[] bytes, StoragePolicy storagePolicy) {
return isAbleToCache(bucketName, storagePolicy) && isAbleToCache(bytes);
}
+ private boolean isAbleToCache(BucketName bucketName, ReadAheadInputStream readAhead, StoragePolicy storagePolicy) {
+ return isAbleToCache(bucketName, storagePolicy) && !readAhead.hasMore;
+ }
+
private boolean isAbleToCache(BucketName bucketName, StoragePolicy storagePolicy) {
return backend.getDefaultBucketName().equals(bucketName) && !storagePolicy.equals(LOW_COST);
}
- private boolean isAbleToCache(byte[] bytes, BucketName bucketName) {
- return isAbleToCache(bytes) && backend.getDefaultBucketName().equals(bucketName);
+ private boolean isAbleToCache(ReadAheadInputStream readAhead, BucketName bucketName) {
+ return !readAhead.hasMore && backend.getDefaultBucketName().equals(bucketName);
}
private boolean isAbleToCache(byte[] bytes) {
@@ -192,10 +232,6 @@ public class CachedBlobStore implements BlobStore {
return Mono.fromCallable(() -> backend.read(bucketName, blobId));
}
- private PushbackInputStream toPushbackStream(InputStream inputStream) {
- return new PushbackInputStream(inputStream, sizeThresholdInBytes);
- }
-
private Mono<byte[]> readFromCache(BlobId blobId) {
return Mono.from(cache.read(blobId));
}
@@ -203,13 +239,4 @@ public class CachedBlobStore implements BlobStore {
private Mono<byte[]> readBytesFromBackend(BucketName bucketName, BlobId blobId) {
return Mono.from(backend.readBytes(bucketName, blobId));
}
-
- private Mono<Void> pushbackBytesArrayRead(PushbackInputStream pushbackInputStream, byte[] bytes) {
- try {
- pushbackInputStream.unread(bytes);
- } catch (IOException e) {
- // Ignore
- }
- return Mono.empty();
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 10/11: JAMES-3140: cache when read with the same
rule with save, add test
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 4c456e28b15ad26fad9ebdaaae5982e3f1098e39
Author: ducnv <du...@gmail.com>
AuthorDate: Wed Apr 22 18:22:58 2020 +0700
JAMES-3140: cache when read with the same rule with save, add test
---
.../blob/cassandra/cache/CachedBlobStore.java | 101 +++++++++++++----
.../blob/cassandra/cache/CachedBlobStoreTest.java | 124 +++++++++++++++++----
2 files changed, 179 insertions(+), 46 deletions(-)
diff --git a/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/cache/CachedBlobStore.java b/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/cache/CachedBlobStore.java
index 3d4abad..86aead0 100644
--- a/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/cache/CachedBlobStore.java
+++ b/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/cache/CachedBlobStore.java
@@ -57,10 +57,12 @@ public class CachedBlobStore implements BlobStore {
@Override
public InputStream read(BucketName bucketName, BlobId blobId) throws ObjectStoreIOException, ObjectNotFoundException {
return Mono.just(bucketName)
- .filter(backend.getDefaultBucketName()::equals)
- .flatMap(ignored -> Mono.from(cache.read(blobId))
- .<InputStream>flatMap(bytes -> Mono.fromCallable(() -> new ByteArrayInputStream(bytes))))
- .switchIfEmpty(Mono.fromCallable(() -> backend.read(bucketName, blobId)))
+ .filter(getDefaultBucketName()::equals)
+ .flatMap(ignored -> readFromCache(blobId)
+ .flatMap(this::toInputStream))
+ .switchIfEmpty(readFromBackend(bucketName, blobId)
+ .map(this::toPushbackStream)
+ .flatMap(pushbackInputStream -> saveInCache(pushbackInputStream, blobId, bucketName)))
.blockOptional()
.orElseThrow(() -> new ObjectNotFoundException(String.format("Could not retrieve blob metadata for %s", blobId)));
}
@@ -68,9 +70,12 @@ public class CachedBlobStore implements BlobStore {
@Override
public Mono<byte[]> readBytes(BucketName bucketName, BlobId blobId) {
return Mono.just(bucketName)
- .filter(backend.getDefaultBucketName()::equals)
- .flatMap(ignored -> Mono.from(cache.read(blobId)))
- .switchIfEmpty(Mono.from(backend.readBytes(bucketName, blobId)));
+ .filter(getDefaultBucketName()::equals)
+ .flatMap(ignored -> readFromCache(blobId)
+ .switchIfEmpty(readBytesFromBackend(bucketName, blobId)
+ .filter(this::isAbleToCache)
+ .flatMap(bytes -> saveInCache(blobId, bytes).then(Mono.just(bytes)))))
+ .switchIfEmpty(readBytesFromBackend(bucketName, blobId));
}
@Override
@@ -78,7 +83,7 @@ public class CachedBlobStore implements BlobStore {
return Mono.from(backend.save(bucketName, bytes, storagePolicy))
.flatMap(blobId -> {
if (isAbleToCache(bucketName, bytes, storagePolicy)) {
- return Mono.from(cache.cache(blobId, bytes)).thenReturn(blobId);
+ return saveInCache(blobId, bytes).thenReturn(blobId);
}
return Mono.just(blobId);
});
@@ -89,24 +94,13 @@ public class CachedBlobStore implements BlobStore {
Preconditions.checkNotNull(inputStream, "InputStream must not be null");
if (isAbleToCache(bucketName, storagePolicy)) {
- return saveInCache(bucketName, inputStream, storagePolicy);
+ return Mono.fromCallable(() -> toPushbackStream(inputStream))
+ .flatMap(pushbackInputStream -> saveInCache(bucketName, pushbackInputStream, storagePolicy));
}
return backend.save(bucketName, inputStream, storagePolicy);
}
- private Publisher<BlobId> saveInCache(BucketName bucketName, InputStream inputStream, StoragePolicy storagePolicy) {
- PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream, sizeThresholdInBytes);
-
- return Mono.fromCallable(() -> fullyReadSmallStream(pushbackInputStream))
- .flatMap(Mono::justOrEmpty)
- .filter(bytes -> isAbleToCache(bucketName, bytes, storagePolicy))
- .flatMap(bytes -> Mono.from(backend.save(bucketName, pushbackInputStream, storagePolicy))
- .flatMap(blobId -> Mono.from(cache.cache(blobId, bytes))
- .thenReturn(blobId)))
- .switchIfEmpty(Mono.from(backend.save(bucketName, pushbackInputStream, storagePolicy)));
- }
-
@Override
public BucketName getDefaultBucketName() {
return backend.getDefaultBucketName();
@@ -148,11 +142,74 @@ public class CachedBlobStore implements BlobStore {
}
}
+ private Mono<BlobId> saveInCache(BucketName bucketName, PushbackInputStream pushbackInputStream, StoragePolicy storagePolicy) {
+ return Mono.fromCallable(() -> fullyReadSmallStream(pushbackInputStream))
+ .flatMap(Mono::justOrEmpty)
+ .filter(bytes -> isAbleToCache(bucketName, bytes, storagePolicy))
+ .flatMap(bytes -> saveInBackend(bucketName, pushbackInputStream, storagePolicy)
+ .flatMap(blobId -> saveInCache(blobId, bytes).thenReturn(blobId)))
+ .switchIfEmpty(saveInBackend(bucketName, pushbackInputStream, storagePolicy));
+ }
+
+ private Mono<BlobId> saveInBackend(BucketName bucketName, PushbackInputStream pushbackInputStream, StoragePolicy storagePolicy) {
+ return Mono.from(backend.save(bucketName, pushbackInputStream, storagePolicy));
+ }
+
+ private Mono<Void> saveInCache(BlobId blobId, byte[] bytes) {
+ return Mono.from(cache.cache(blobId, bytes));
+ }
+
+ private Mono<InputStream> saveInCache(PushbackInputStream pushbackInputStream, BlobId blobId, BucketName bucketName) {
+ return Mono.fromCallable(() -> fullyReadSmallStream(pushbackInputStream))
+ .flatMap(Mono::justOrEmpty)
+ .filter(bytes -> isAbleToCache(bytes, bucketName))
+ .flatMap(bytes -> Mono.from(cache.cache(blobId, bytes))
+ .map(ignore -> pushbackBytesArrayRead(pushbackInputStream, bytes)))
+ .then(Mono.just(pushbackInputStream));
+ }
+
private boolean isAbleToCache(BucketName bucketName, byte[] bytes, StoragePolicy storagePolicy) {
- return isAbleToCache(bucketName, storagePolicy) && bytes.length <= sizeThresholdInBytes;
+ return isAbleToCache(bucketName, storagePolicy) && isAbleToCache(bytes);
}
private boolean isAbleToCache(BucketName bucketName, StoragePolicy storagePolicy) {
return backend.getDefaultBucketName().equals(bucketName) && !storagePolicy.equals(LOW_COST);
}
+
+ private boolean isAbleToCache(byte[] bytes, BucketName bucketName) {
+ return isAbleToCache(bytes) && backend.getDefaultBucketName().equals(bucketName);
+ }
+
+ private boolean isAbleToCache(byte[] bytes) {
+ return bytes.length <= sizeThresholdInBytes;
+ }
+
+ private Mono<InputStream> toInputStream(byte[] bytes) {
+ return Mono.fromCallable(() -> new ByteArrayInputStream(bytes));
+ }
+
+ private Mono<InputStream> readFromBackend(BucketName bucketName, BlobId blobId) {
+ return Mono.fromCallable(() -> backend.read(bucketName, blobId));
+ }
+
+ private PushbackInputStream toPushbackStream(InputStream inputStream) {
+ return new PushbackInputStream(inputStream, sizeThresholdInBytes);
+ }
+
+ private Mono<byte[]> readFromCache(BlobId blobId) {
+ return Mono.from(cache.read(blobId));
+ }
+
+ private Mono<byte[]> readBytesFromBackend(BucketName bucketName, BlobId blobId) {
+ return Mono.from(backend.readBytes(bucketName, blobId));
+ }
+
+ private Mono<Void> pushbackBytesArrayRead(PushbackInputStream pushbackInputStream, byte[] bytes) {
+ try {
+ pushbackInputStream.unread(bytes);
+ } catch (IOException e) {
+ // Ignore
+ }
+ return Mono.empty();
+ }
}
diff --git a/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/cache/CachedBlobStoreTest.java b/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/cache/CachedBlobStoreTest.java
index debea77..8da8e61 100644
--- a/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/cache/CachedBlobStoreTest.java
+++ b/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/cache/CachedBlobStoreTest.java
@@ -29,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
+import java.time.Duration;
import org.apache.james.backends.cassandra.CassandraCluster;
import org.apache.james.backends.cassandra.CassandraClusterExtension;
@@ -52,8 +53,8 @@ import reactor.core.publisher.Mono;
public class CachedBlobStoreTest implements BlobStoreContract {
- private static final BucketName DEFAULT_BUCKERNAME = DEFAULT;
- private static final BucketName TEST_BUCKERNAME = BucketName.of("test");
+ private static final BucketName DEFAULT_BUCKETNAME = DEFAULT;
+ private static final BucketName TEST_BUCKETNAME = BucketName.of("test");
byte[] APPROXIMATELY_FIVE_KILOBYTES = Strings.repeat("0123456789\n", 500).getBytes(StandardCharsets.UTF_8);
@RegisterExtension
@@ -69,6 +70,7 @@ public class CachedBlobStoreTest implements BlobStoreContract {
backend = CassandraBlobStore.forTesting(cassandra.getConf());
CassandraCacheConfiguration cacheConfig = new CassandraCacheConfiguration.Builder()
.sizeThresholdInBytes(EIGHT_KILOBYTES.length + 1)
+ .timeOut(Duration.ofSeconds(60))
.build();
cache = new CassandraBlobStoreCache(cassandra.getConf(), cacheConfig);
testee = new CachedBlobStore(cache, backend, cacheConfig);
@@ -86,7 +88,7 @@ public class CachedBlobStoreTest implements BlobStoreContract {
@Test
public void shouldCacheWhenDefaultBucketName() {
- BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKERNAME, EIGHT_KILOBYTES, SIZE_BASED)).block();
+ BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKETNAME, EIGHT_KILOBYTES, SIZE_BASED)).block();
byte[] actual = Mono.from(cache.read(blobId)).block();
assertThat(actual).containsExactly(EIGHT_KILOBYTES);
@@ -94,108 +96,182 @@ public class CachedBlobStoreTest implements BlobStoreContract {
@Test
public void shouldNotCacheWhenNotDefaultBucketName() {
- BlobId blobId = Mono.from(testee().save(TEST_BUCKERNAME, EIGHT_KILOBYTES, SIZE_BASED)).block();
+ BlobId blobId = Mono.from(testee().save(TEST_BUCKETNAME, EIGHT_KILOBYTES, SIZE_BASED)).block();
SoftAssertions.assertSoftly(ignored -> {
assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
- assertThat(Mono.from(backend.readBytes(TEST_BUCKERNAME, blobId)).block()).containsExactly(EIGHT_KILOBYTES);
+ assertThat(Mono.from(backend.readBytes(TEST_BUCKETNAME, blobId)).block()).containsExactly(EIGHT_KILOBYTES);
});
}
@Test
public void shouldNotCacheWhenDefaultBucketNameAndBigByteDataAndSizeBase() {
- BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKERNAME, TWELVE_MEGABYTES, SIZE_BASED)).block();
+ BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKETNAME, TWELVE_MEGABYTES, SIZE_BASED)).block();
SoftAssertions.assertSoftly(ignored -> {
assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
- assertThat(Mono.from(backend.readBytes(DEFAULT_BUCKERNAME, blobId)).block()).containsExactly(TWELVE_MEGABYTES);
+ assertThat(Mono.from(backend.readBytes(DEFAULT_BUCKETNAME, blobId)).block()).containsExactly(TWELVE_MEGABYTES);
});
}
@Test
public void shouldSavedBothInCacheAndBackendWhenSizeBase() {
- BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKERNAME, EIGHT_KILOBYTES, SIZE_BASED)).block();
+ BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKETNAME, EIGHT_KILOBYTES, SIZE_BASED)).block();
SoftAssertions.assertSoftly(soflty -> {
assertThat(Mono.from(cache.read(blobId)).block()).containsExactly(EIGHT_KILOBYTES);
- assertThat(Mono.from(backend.readBytes(DEFAULT_BUCKERNAME, blobId)).block()).containsExactly(EIGHT_KILOBYTES);
+ assertThat(Mono.from(backend.readBytes(DEFAULT_BUCKETNAME, blobId)).block()).containsExactly(EIGHT_KILOBYTES);
});
}
@Test
public void shouldSavedBothInCacheAndBackendWhenHighPerformance() {
- BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKERNAME, EIGHT_KILOBYTES, HIGH_PERFORMANCE)).block();
+ BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKETNAME, EIGHT_KILOBYTES, HIGH_PERFORMANCE)).block();
SoftAssertions.assertSoftly(soflty -> {
assertThat(Mono.from(cache.read(blobId)).block()).containsExactly(EIGHT_KILOBYTES);
- assertThat(Mono.from(backend.readBytes(DEFAULT_BUCKERNAME, blobId)).block()).containsExactly(EIGHT_KILOBYTES);
+ assertThat(Mono.from(backend.readBytes(DEFAULT_BUCKETNAME, blobId)).block()).containsExactly(EIGHT_KILOBYTES);
});
}
@Test
public void shouldNotCacheWhenLowCost() {
- BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKERNAME, EIGHT_KILOBYTES, LOW_COST)).block();
+ BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKETNAME, EIGHT_KILOBYTES, LOW_COST)).block();
SoftAssertions.assertSoftly(soflty -> {
assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
- assertThat(Mono.from(backend.readBytes(DEFAULT_BUCKERNAME, blobId)).block()).containsExactly(EIGHT_KILOBYTES);
+ assertThat(Mono.from(backend.readBytes(DEFAULT_BUCKETNAME, blobId)).block()).containsExactly(EIGHT_KILOBYTES);
});
}
@Test
public void shouldCacheWhenEmptyStream() {
- BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKERNAME, new ByteArrayInputStream(EMPTY_BYTEARRAY), SIZE_BASED)).block();
+ BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKETNAME, new ByteArrayInputStream(EMPTY_BYTEARRAY), SIZE_BASED)).block();
SoftAssertions.assertSoftly(soflty -> {
assertThat(new ByteArrayInputStream(Mono.from(cache.read(blobId)).block())).hasSameContentAs(new ByteArrayInputStream(EMPTY_BYTEARRAY));
- assertThat(Mono.from(backend.readBytes(DEFAULT_BUCKERNAME, blobId)).block()).containsExactly(EMPTY_BYTEARRAY);
+ assertThat(Mono.from(backend.readBytes(DEFAULT_BUCKETNAME, blobId)).block()).containsExactly(EMPTY_BYTEARRAY);
});
}
@Test
public void shouldNotCacheWhenEmptyByteArray() {
- BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKERNAME, EMPTY_BYTEARRAY, SIZE_BASED)).block();
+ BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKETNAME, EMPTY_BYTEARRAY, SIZE_BASED)).block();
SoftAssertions.assertSoftly(soflty -> {
assertThat(new ByteArrayInputStream(Mono.from(cache.read(blobId)).block())).hasSameContentAs(new ByteArrayInputStream(EMPTY_BYTEARRAY));
- assertThat(Mono.from(backend.readBytes(DEFAULT_BUCKERNAME, blobId)).block()).containsExactly(EMPTY_BYTEARRAY);
+ assertThat(Mono.from(backend.readBytes(DEFAULT_BUCKETNAME, blobId)).block()).containsExactly(EMPTY_BYTEARRAY);
});
}
@Test
public void shouldCacheWhenFiveKilobytesSteam() {
- BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKERNAME, new ByteArrayInputStream(APPROXIMATELY_FIVE_KILOBYTES), SIZE_BASED)).block();
+ BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKETNAME, new ByteArrayInputStream(APPROXIMATELY_FIVE_KILOBYTES), SIZE_BASED)).block();
SoftAssertions.assertSoftly(soflty -> {
assertThat(new ByteArrayInputStream(Mono.from(cache.read(blobId)).block()))
.hasSameContentAs(new ByteArrayInputStream(APPROXIMATELY_FIVE_KILOBYTES));
- assertThat(new ByteArrayInputStream(Mono.from(backend.readBytes(DEFAULT_BUCKERNAME, blobId)).block()))
+ assertThat(new ByteArrayInputStream(Mono.from(backend.readBytes(DEFAULT_BUCKETNAME, blobId)).block()))
.hasSameContentAs(new ByteArrayInputStream(APPROXIMATELY_FIVE_KILOBYTES));
});
}
@Test
public void shouldCacheWhenFiveKilobytesBytes() {
- BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKERNAME, APPROXIMATELY_FIVE_KILOBYTES, SIZE_BASED)).block();
+ BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKETNAME, APPROXIMATELY_FIVE_KILOBYTES, SIZE_BASED)).block();
SoftAssertions.assertSoftly(soflty -> {
assertThat(new ByteArrayInputStream(Mono.from(cache.read(blobId)).block()))
.hasSameContentAs(new ByteArrayInputStream(APPROXIMATELY_FIVE_KILOBYTES));
- assertThat(new ByteArrayInputStream(Mono.from(backend.readBytes(DEFAULT_BUCKERNAME, blobId)).block()))
+ assertThat(new ByteArrayInputStream(Mono.from(backend.readBytes(DEFAULT_BUCKETNAME, blobId)).block()))
.hasSameContentAs(new ByteArrayInputStream(APPROXIMATELY_FIVE_KILOBYTES));
});
}
@Test
public void shouldRemoveBothInCacheAndBackendWhenDefaultBucketName() {
- BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKERNAME, EIGHT_KILOBYTES, SIZE_BASED)).block();
+ BlobId blobId = Mono.from(testee().save(DEFAULT_BUCKETNAME, EIGHT_KILOBYTES, SIZE_BASED)).block();
SoftAssertions.assertSoftly(ignored -> {
- assertThatCode(Mono.from(testee().delete(DEFAULT_BUCKERNAME, blobId))::block)
+ assertThatCode(Mono.from(testee().delete(DEFAULT_BUCKETNAME, blobId))::block)
.doesNotThrowAnyException();
assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
- assertThatThrownBy(() -> Mono.from(backend.readBytes(DEFAULT_BUCKERNAME, blobId)).block())
+ assertThatThrownBy(() -> Mono.from(backend.readBytes(DEFAULT_BUCKETNAME, blobId)).block())
.isInstanceOf(ObjectNotFoundException.class);
});
}
+
+ @Test
+ public void shouldCacheWhenReadBytesWithDefaultBucket() {
+ BlobId blobId = Mono.from(backend.save(DEFAULT_BUCKETNAME, APPROXIMATELY_FIVE_KILOBYTES, SIZE_BASED)).block();
+
+ SoftAssertions.assertSoftly(soflty -> {
+ assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
+ assertThat(new ByteArrayInputStream(Mono.from(testee().readBytes(DEFAULT_BUCKETNAME, blobId)).block()))
+ .hasSameContentAs(new ByteArrayInputStream(APPROXIMATELY_FIVE_KILOBYTES));
+ assertThat(new ByteArrayInputStream(Mono.from(cache.read(blobId)).block()))
+ .hasSameContentAs(new ByteArrayInputStream(APPROXIMATELY_FIVE_KILOBYTES));
+ });
+ }
+
+ @Test
+ public void shouldCacheWhenReadWithDefaultBucket() {
+ BlobId blobId = Mono.from(backend.save(DEFAULT_BUCKETNAME, APPROXIMATELY_FIVE_KILOBYTES, SIZE_BASED)).block();
+
+ SoftAssertions.assertSoftly(soflty -> {
+ assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
+ assertThat(testee().read(DEFAULT_BUCKETNAME, blobId))
+ .hasSameContentAs(new ByteArrayInputStream(APPROXIMATELY_FIVE_KILOBYTES));
+ assertThat(new ByteArrayInputStream(Mono.from(cache.read(blobId)).block()))
+ .hasSameContentAs(new ByteArrayInputStream(APPROXIMATELY_FIVE_KILOBYTES));
+ });
+ }
+
+ @Test
+ public void shouldNotCacheWhenReadBytesWithOutDefaultBucket() {
+ BlobId blobId = Mono.from(backend.save(TEST_BUCKETNAME, APPROXIMATELY_FIVE_KILOBYTES, SIZE_BASED)).block();
+
+ SoftAssertions.assertSoftly(soflty -> {
+ assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
+ assertThat(new ByteArrayInputStream(Mono.from(testee().readBytes(TEST_BUCKETNAME, blobId)).block()))
+ .hasSameContentAs(new ByteArrayInputStream(APPROXIMATELY_FIVE_KILOBYTES));
+ assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
+ });
+ }
+
+ @Test
+ public void shouldNotCacheWhenReadWithOutDefaultBucket() {
+ BlobId blobId = Mono.from(backend.save(TEST_BUCKETNAME, new ByteArrayInputStream(APPROXIMATELY_FIVE_KILOBYTES), SIZE_BASED)).block();
+
+ SoftAssertions.assertSoftly(soflty -> {
+ assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
+ assertThat(testee().read(TEST_BUCKETNAME, blobId))
+ .hasSameContentAs(new ByteArrayInputStream(APPROXIMATELY_FIVE_KILOBYTES));
+ assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
+ });
+ }
+
+ @Test
+ public void shouldNotCacheWhenReadWithBigByteArray() {
+ BlobId blobId = Mono.from(backend.save(DEFAULT_BUCKETNAME, new ByteArrayInputStream(TWELVE_MEGABYTES), SIZE_BASED)).block();
+
+ SoftAssertions.assertSoftly(soflty -> {
+ assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
+ assertThat(new ByteArrayInputStream(Mono.from(testee().readBytes(DEFAULT_BUCKETNAME, blobId)).block()))
+ .hasSameContentAs(new ByteArrayInputStream(TWELVE_MEGABYTES));
+ assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
+ });
+ }
+
+ @Test
+ public void shouldNotCacheWhenReadWithBigStream() {
+ BlobId blobId = Mono.from(backend.save(DEFAULT_BUCKETNAME, new ByteArrayInputStream(TWELVE_MEGABYTES), SIZE_BASED)).block();
+
+ SoftAssertions.assertSoftly(soflty -> {
+ assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
+ assertThat(testee().read(DEFAULT_BUCKETNAME, blobId))
+ .hasSameContentAs(new ByteArrayInputStream(TWELVE_MEGABYTES));
+ assertThat(Mono.from(cache.read(blobId)).blockOptional()).isEmpty();
+ });
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 06/11: Merge branch 'pr-3341'
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 8035b7d54520afe1bd5f547e34f51176e3bbc1e1
Merge: 152aa7d ba679b6
Author: Matthieu Baechler <ma...@apache.org>
AuthorDate: Thu Apr 30 09:26:03 2020 +0200
Merge branch 'pr-3341'
.../org/apache/james/mailbox}/Authenticator.java | 2 +-
.../org/apache/james/mailbox}/Authorizator.java | 2 +-
.../cassandra/CassandraMailboxManagerProvider.java | 4 +-
.../cassandra/CassandraTestSystemFixture.java | 4 +-
.../CassandraMailboxManagerAttachmentTest.java | 4 +-
...asticSearchListeningMessageSearchIndexTest.java | 2 +-
.../mailbox/jpa/JpaMailboxManagerProvider.java | 4 +-
.../maildir/MaildirMailboxManagerProvider.java | 4 +-
.../manager/InMemoryIntegrationResources.java | 4 +-
.../mailbox/spring/AnonymousAuthenticator.java | 62 +++++++++++-----------
.../james/mailbox/spring/NoAuthorizator.java | 62 +++++++++++-----------
.../james/mailbox/store/FakeAuthenticator.java | 1 +
.../james/mailbox/store/FakeAuthorizator.java | 1 +
.../james/mailbox/store/SessionProviderImpl.java | 2 +
mpt/impl/imap-mailbox/core/pom.xml | 5 --
.../apache/james/mpt/host/JamesImapHostSystem.java | 8 +--
server/container/guice/cassandra-guice/pom.xml | 4 ++
.../modules/mailbox/CassandraMailboxModule.java | 8 +--
server/container/guice/jpa-guice/pom.xml | 4 ++
.../james/modules/mailbox/JPAMailboxModule.java | 8 +--
server/container/guice/mailbox/pom.xml | 6 +--
server/container/guice/memory-guice/pom.xml | 4 ++
.../james/modules/mailbox/MemoryMailboxModule.java | 8 +--
server/container/mailbox-adapter/pom.xml | 4 --
.../{store => }/UserRepositoryAuthenticator.java | 4 +-
.../{store => }/UserRepositoryAuthorizator.java | 4 +-
.../UserRepositoryAuthenticatorTest.java | 2 +-
.../UserRepositoryAuthorizatorTest.java | 4 +-
.../apache/james/spring-mailbox-authenticator.xml | 2 +-
.../apache/james/spring-mailbox-authorizator.xml | 2 +-
src/site/xdoc/mailbox/mailbox-spring.xml | 2 +-
31 files changed, 122 insertions(+), 115 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org