Skip to content

Commit 46f0510

Browse files
authored
Throw IllegalStateException if the writer is not in a good state (#1097)
1 parent 7773afc commit 46f0510

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

core/src/main/java/software/amazon/smithy/java/core/serde/event/DefaultEventStreamWriter.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,20 @@ public void setInitialEvent(IE initialEvent) {
102102

103103
@Override
104104
public void addFrameProcessor(FrameProcessor<F> frameProcessor) {
105+
if (this.encoderFactory == null) {
106+
throw new IllegalStateException("encoderFactory is null. The encoder factory" +
107+
" has not been set or activate has been already called");
108+
}
105109
this.encoderFactory =
106110
encoderFactory.withFrameProcessor(Objects.requireNonNull(frameProcessor, "frameProcessor"));
107111
}
108112

109113
@Override
110114
public void activate() {
115+
if (this.encoderFactory == null) {
116+
throw new IllegalStateException("encoderFactory is null. The encoder factory" +
117+
" has not been set or activate has been already called");
118+
}
111119
setEventStreamEncoders();
112120
writeInitialEvent(initialEvent);
113121
}

0 commit comments

Comments
 (0)