Skip to content

Commit

Permalink
streamnative#386: Check serializability of crypto key reader and encr…
Browse files Browse the repository at this point in the history
…yption keys.
  • Loading branch information
objecttrouve committed Sep 15, 2021
1 parent 50b9e9b commit a0b27ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
import java.util.Set;
import java.util.concurrent.CompletableFuture;

import static org.apache.flink.util.InstantiationUtil.isSerializable;
import static org.apache.flink.util.Preconditions.checkNotNull;
import static org.apache.flink.util.Preconditions.checkState;

/**
* Write data to Flink.
Expand Down Expand Up @@ -136,6 +138,8 @@ public FlinkPulsarSink<T> build(){
if ((cryptoKeyReader == null) != (encryptionKeys.isEmpty())){
throw new IllegalStateException("Set crypto key reader and encryption keys in conjunction.");
}
checkState(isSerializable(cryptoKeyReader));
checkState(isSerializable(encryptionKeys));
return new FlinkPulsarSink<>(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@
import static org.apache.flink.streaming.connectors.pulsar.internal.metrics.PulsarSourceMetrics.COMMITS_FAILED_METRICS_COUNTER;
import static org.apache.flink.streaming.connectors.pulsar.internal.metrics.PulsarSourceMetrics.COMMITS_SUCCEEDED_METRICS_COUNTER;
import static org.apache.flink.streaming.connectors.pulsar.internal.metrics.PulsarSourceMetrics.PULSAR_SOURCE_METRICS_GROUP;
import static org.apache.flink.util.InstantiationUtil.isSerializable;
import static org.apache.flink.util.Preconditions.checkArgument;
import static org.apache.flink.util.Preconditions.checkNotNull;
import static org.apache.flink.util.Preconditions.checkState;


/**
* Pulsar data source.
Expand Down Expand Up @@ -168,6 +171,7 @@ public FlinkPulsarSource<T> build(){
if (clientConf == null){
throw new IllegalStateException("Client conf mustn't be null. Either provide a client conf or a service URL plus properties.");
}
checkState(isSerializable(cryptoKeyReader));
return new FlinkPulsarSource<>(this);
}

Expand Down

0 comments on commit a0b27ca

Please sign in to comment.