Skip to content

Commit

Permalink
Issue #611: fixed that CharSequences were hold in Immutable types ins…
Browse files Browse the repository at this point in the history
…tead of Strings making them not immutable

Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch.io>
  • Loading branch information
thjaeckle committed Mar 27, 2020
1 parent f62f867 commit 713e0e5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
Expand Up @@ -12,6 +12,8 @@
*/
package org.eclipse.ditto.services.gateway.streaming;

import static org.eclipse.ditto.model.base.common.ConditionChecker.checkNotNull;

import java.time.Instant;
import java.util.Objects;
import java.util.Optional;
Expand All @@ -29,7 +31,7 @@
public final class Connect {

private final ActorRef eventAndResponsePublisher;
private final CharSequence connectionCorrelationId;
private final String connectionCorrelationId;
private final String type;
private final JsonSchemaVersion jsonSchemaVersion;
@Nullable private final Instant sessionExpirationTime;
Expand All @@ -49,7 +51,8 @@ public Connect(final ActorRef eventAndResponsePublisher,
final JsonSchemaVersion jsonSchemaVersion,
@Nullable final Instant sessionExpirationTime) {
this.eventAndResponsePublisher = eventAndResponsePublisher;
this.connectionCorrelationId = connectionCorrelationId;
this.connectionCorrelationId = checkNotNull(connectionCorrelationId, "connectionCorrelationId")
.toString();
this.type = type;
this.jsonSchemaVersion = jsonSchemaVersion;
this.sessionExpirationTime = sessionExpirationTime;
Expand All @@ -59,7 +62,7 @@ public ActorRef getEventAndResponsePublisher() {
return eventAndResponsePublisher;
}

public CharSequence getConnectionCorrelationId() {
public String getConnectionCorrelationId() {
return connectionCorrelationId;
}

Expand Down
Expand Up @@ -33,7 +33,7 @@
public final class StartStreaming implements StreamControlMessage {

private final StreamingType streamingType;
private final CharSequence connectionCorrelationId;
private final String connectionCorrelationId;
private final AuthorizationContext authorizationContext;
private final List<String> namespaces;
@Nullable private final String filter;
Expand Down Expand Up @@ -71,7 +71,7 @@ public StreamingType getStreamingType() {
return streamingType;
}

public CharSequence getConnectionCorrelationId() {
public String getConnectionCorrelationId() {
return connectionCorrelationId;
}

Expand Down Expand Up @@ -145,7 +145,7 @@ public String toString() {
public static final class StartStreamingBuilder {

private final StreamingType streamingType;
private final CharSequence connectionCorrelationId;
private final String connectionCorrelationId;
private final AuthorizationContext authorizationContext;

@Nullable private Collection<String> namespaces;
Expand All @@ -156,7 +156,8 @@ private StartStreamingBuilder(final StreamingType streamingType, final CharSeque
final AuthorizationContext authorizationContext) {

this.streamingType = checkNotNull(streamingType, "streamingType");
this.connectionCorrelationId = checkNotNull(connectionCorrelationId, "connectionCorrelationId");
this.connectionCorrelationId = checkNotNull(connectionCorrelationId, "connectionCorrelationId")
.toString();
this.authorizationContext = checkNotNull(authorizationContext, "authorizationContext");
namespaces = null;
filter = null;
Expand Down
Expand Up @@ -28,7 +28,7 @@
public final class StopStreaming implements StreamControlMessage {

private final StreamingType streamingType;
private final CharSequence connectionCorrelationId;
private final String connectionCorrelationId;

/**
* Constructs a new {@code StopStreaming} object.
Expand All @@ -39,7 +39,8 @@ public final class StopStreaming implements StreamControlMessage {
*/
public StopStreaming(final StreamingType streamingType, final CharSequence connectionCorrelationId) {
this.streamingType = checkNotNull(streamingType, "streamingType");
this.connectionCorrelationId = checkNotNull(connectionCorrelationId, "connectionCorrelationId");
this.connectionCorrelationId = checkNotNull(connectionCorrelationId, "connectionCorrelationId")
.toString();
}

/**
Expand All @@ -49,7 +50,7 @@ public StreamingType getStreamingType() {
return streamingType;
}

public CharSequence getConnectionCorrelationId() {
public String getConnectionCorrelationId() {
return connectionCorrelationId;
}

Expand Down
Expand Up @@ -64,7 +64,7 @@ public Receive createReceive() {
// Initially, this Actor can only receive the Connect message:
return ReceiveBuilder.create()
.match(Connect.class, connect -> {
final CharSequence connectionCorrelationId = connect.getConnectionCorrelationId();
final String connectionCorrelationId = connect.getConnectionCorrelationId();
logger.withCorrelationId(connectionCorrelationId).debug("Established new connection: {}",
connectionCorrelationId);
getContext().become(connected(connectionCorrelationId));
Expand Down
Expand Up @@ -126,11 +126,11 @@ public Receive createReceive() {
.match(Connect.class, connect -> {
final ActorRef eventAndResponsePublisher = connect.getEventAndResponsePublisher();
eventAndResponsePublisher.forward(connect, getContext());
final CharSequence connectionCorrelationId = connect.getConnectionCorrelationId();
final String connectionCorrelationId = connect.getConnectionCorrelationId();
getContext().actorOf(
StreamingSessionActor.props(connect, dittoProtocolSub, eventAndResponsePublisher,
streamingConfig.getAcknowledgementConfig()),
connectionCorrelationId.toString());
connectionCorrelationId);
})
.match(StartStreaming.class,
startStreaming -> forwardToSessionActor(startStreaming.getConnectionCorrelationId(),
Expand Down
Expand Up @@ -73,7 +73,7 @@
final class StreamingSessionActor extends AbstractActor {

private final JsonSchemaVersion jsonSchemaVersion;
private final CharSequence connectionCorrelationId;
private final String connectionCorrelationId;
private final String type;
private final DittoProtocolSub dittoProtocolSub;
private final ActorRef eventAndResponsePublisher;
Expand Down

0 comments on commit 713e0e5

Please sign in to comment.