Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump axon.version from 4.5.3 to 4.5.4 #133

Merged
merged 3 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,44 @@
import org.axonframework.serialization.Serializer;
import org.axonframework.serialization.xml.XStreamSerializer;
import org.bson.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.invoke.MethodHandles;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Supplier;

import static com.mongodb.client.model.Projections.include;
import static org.axonframework.common.BuilderUtils.assertNonNull;

/**
* Implementations of the SagaRepository that stores Sagas and their associations in a Mongo Database. Each Saga and
* its associations is stored as a single document.
* Implementations of the SagaRepository that stores Sagas and their associations in a Mongo Database. Each Saga and its
* associations is stored as a single document.
*
* @author Jettro Coenradie
* @author Allard Buijze
* @since 2.0
*/
public class MongoSagaStore implements SagaStore<Object> {

private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

private final MongoTemplate mongoTemplate;
private final Serializer serializer;

/**
* Instantiate a {@link MongoSagaStore} based on the fields contained in the {@link Builder}.
* <p>
* Will assert that the {@link MongoTemplate} is not {@code null}, and will throw an
* {@link AxonConfigurationException} if it is {@code null}.
* Will assert that the {@link MongoTemplate} is not {@code null}, and will throw an {@link
* AxonConfigurationException} if it is {@code null}.
*
* @param builder the {@link Builder} used to instantiate a {@link MongoSagaStore} instance
*/
protected MongoSagaStore(Builder builder) {
builder.validate();
this.mongoTemplate = builder.mongoTemplate;
this.serializer = builder.serializer;
this.serializer = builder.serializer.get();
}

/**
Expand Down Expand Up @@ -156,7 +162,7 @@ private String getSagaTypeName(Class<?> sagaType) {
public static class Builder {

private MongoTemplate mongoTemplate;
private Serializer serializer = XStreamSerializer.builder().build();
private Supplier<Serializer> serializer;

/**
* Sets the {@link MongoTemplate} providing access to the collections.
Expand All @@ -178,7 +184,7 @@ public Builder mongoTemplate(MongoTemplate mongoTemplate) {
*/
public Builder serializer(Serializer serializer) {
assertNonNull(serializer, "Serializer may not be null");
this.serializer = serializer;
this.serializer = () -> serializer;
return this;
}

Expand All @@ -199,6 +205,16 @@ public MongoSagaStore build() {
*/
protected void validate() throws AxonConfigurationException {
assertNonNull(mongoTemplate, "The MongoTemplate is a hard requirement and should be provided");
if (serializer == null) {
logger.warn(
"The default XStreamSerializer is used, whereas it is strongly recommended to configure"
+ " the security context of the XStream instance.",
new AxonConfigurationException(
"A default XStreamSerializer is used, without specifying the security context"
)
);
serializer = XStreamSerializer::defaultSerializer;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.mongodb.client.ListIndexesIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import com.thoughtworks.xstream.XStream;
import org.axonframework.eventhandling.GlobalSequenceTrackingToken;
import org.axonframework.eventhandling.TrackingToken;
import org.axonframework.eventhandling.tokenstore.TokenStore;
Expand Down Expand Up @@ -276,7 +277,9 @@ void testConcurrentAccess() throws Exception {
@Test
void testStoreAndFetchTokenResultsInTheSameTokenWithXStreamSerializer() {
TokenStore tokenStore = MongoTokenStore.builder()
.serializer(XStreamSerializer.builder().build())
.serializer(XStreamSerializer.builder()
.xStream(new XStream())
.build())
.mongoTemplate(mongoTemplate)
.claimTimeout(claimTimeout)
.contentType(contentType)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<axon.version>4.5.3</axon.version>
<axon.version>4.5.4</axon.version>
<mongo.driver.version>4.3.2</mongo.driver.version>

<slf4j.version>1.7.32</slf4j.version>
Expand Down