Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Client connections on GlobalEventExecutor thread that are not propaga…
…ted to the application - fixes #2670
- Loading branch information
Showing
7 changed files
with
129 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/test/java/io/vertx/core/impl/GlobalEventExecutorNotificationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright (c) 2014 Red Hat, Inc. and others | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
* which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
*/ | ||
package io.vertx.core.impl; | ||
|
||
import io.netty.channel.Channel; | ||
import io.netty.channel.ChannelFactory; | ||
import io.vertx.core.Vertx; | ||
import io.vertx.core.VertxOptions; | ||
import io.vertx.core.net.NetClientOptions; | ||
import io.vertx.core.net.ProxyOptions; | ||
import io.vertx.core.net.ProxyType; | ||
import io.vertx.core.net.impl.transport.Transport; | ||
import io.vertx.test.core.AsyncTestBase; | ||
import org.junit.After; | ||
import org.junit.Test; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
|
||
public class GlobalEventExecutorNotificationTest extends AsyncTestBase { | ||
|
||
private Vertx vertx; | ||
|
||
@After | ||
public void after() throws Exception { | ||
if (vertx != null) { | ||
CountDownLatch latch = new CountDownLatch(1); | ||
vertx.close(v -> latch.countDown()); | ||
awaitLatch(latch); | ||
} | ||
} | ||
|
||
@Test | ||
public void testConnectErrorNotifiesOnEventLoop() { | ||
testConnectErrorNotifiesOnEventLoop(new NetClientOptions()); | ||
} | ||
|
||
@Test | ||
public void testConnectToProxyErrorNotifiesOnEventLoop() { | ||
testConnectErrorNotifiesOnEventLoop(new NetClientOptions() | ||
.setProxyOptions(new ProxyOptions() | ||
.setPort(1234) | ||
.setType(ProxyType.SOCKS5) | ||
.setHost("localhost"))); | ||
} | ||
|
||
private void testConnectErrorNotifiesOnEventLoop(NetClientOptions options) { | ||
RuntimeException cause = new RuntimeException(); | ||
vertx = VertxImpl.vertx(new VertxOptions(), new Transport() { | ||
@Override | ||
public ChannelFactory<? extends Channel> channelFactory(boolean domain) { | ||
return new ChannelFactory<Channel>() { | ||
@Override | ||
public Channel newChannel() { | ||
throw cause; | ||
} | ||
}; | ||
} | ||
}); | ||
|
||
vertx.createNetServer().connectHandler(so -> { | ||
fail(); | ||
}).listen(1234, "localhost", onSuccess(v -> { | ||
vertx.createNetClient(options).connect(1234, "localhost", onFailure(err -> { | ||
assertSame(err, cause); | ||
testComplete(); | ||
})); | ||
})); | ||
await(); | ||
} | ||
} |