Skip to content

Commit 96c1389

Browse files
sschepensjakubdyszkiewicz
authored andcommitted
replace usages of onError with closeWithError
Signed-off-by: Sebastian Schepens <[email protected]>
1 parent 61382e0 commit 96c1389

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

server/src/main/java/io/envoyproxy/controlplane/server/DiscoveryServer.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,10 @@ public void onNext(DiscoveryRequest request) {
228228

229229
if (defaultTypeUrl.equals(ANY_TYPE_URL)) {
230230
if (requestTypeUrl.isEmpty()) {
231-
synchronized (responseObserver) {
232-
if (!isClosing) {
233-
isClosing = true;
234-
responseObserver.onError(
235-
Status.UNKNOWN
236-
.withDescription(String.format("[%d] type URL is required for ADS", streamId))
237-
.asRuntimeException());
238-
}
239-
}
231+
closeWithError(
232+
Status.UNKNOWN
233+
.withDescription(String.format("[%d] type URL is required for ADS", streamId))
234+
.asRuntimeException());
240235

241236
return;
242237
}
@@ -297,12 +292,7 @@ public void onError(Throwable t) {
297292

298293
try {
299294
callbacks.forEach(cb -> cb.onStreamCloseWithError(streamId, defaultTypeUrl, t));
300-
synchronized (responseObserver) {
301-
if (!isClosing) {
302-
isClosing = true;
303-
responseObserver.onError(Status.fromThrowable(t).asException());
304-
}
305-
}
295+
closeWithError(Status.fromThrowable(t).asException());
306296
} finally {
307297
cancel();
308298
}

0 commit comments

Comments
 (0)