Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump netty from 4.1.110.Final to 4.1.112.Final vertx from 4.4.9 4.5.9 #4463

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,19 @@
package org.apache.servicecomb.core.transport;

import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Collections;

import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.foundation.common.net.IpPort;
import org.apache.servicecomb.foundation.vertx.VertxUtils;
import org.apache.servicecomb.registry.RegistrationManager;
import org.apache.servicecomb.swagger.invocation.AsyncResponse;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.util.ReflectionUtils;

import com.netflix.config.DynamicProperty;

import mockit.Expectations;
import mockit.Mocked;

public class TestAbstractTransport {
private final Method updatePropertyMethod =
ReflectionUtils.findMethod(DynamicProperty.class, "updateProperty", String.class, Object.class);

private void updateProperty(String key, Object value) {
updatePropertyMethod.setAccessible(true);
ReflectionUtils.invokeMethod(updatePropertyMethod, null, key, value);
}

static class MyAbstractTransport extends AbstractTransport {

@Override
Expand All @@ -71,12 +55,6 @@ public static void classTeardown() {

@Test
public void testSetListenAddressWithoutSchemaChineseSpaceNewSC() throws UnsupportedEncodingException {
new Expectations() {
{
RegistrationManager.getPublishAddress("my", "127.0.0.1:9090");
}
};

MyAbstractTransport transport = new MyAbstractTransport();
transport.setListenAddressWithoutSchema("127.0.0.1:9090", Collections.singletonMap("country", "中 国"));
Assertions.assertEquals("my://127.0.0.1:9090?country=" + URLEncoder.encode("中 国", StandardCharsets.UTF_8.name()),
Expand Down Expand Up @@ -113,7 +91,7 @@ public void testMyAbstractTransport() {
}

@Test(expected = IllegalArgumentException.class)
public void testMyAbstractTransportException(@Mocked TransportManager manager) {
public void testMyAbstractTransportException() {
MyAbstractTransport transport = new MyAbstractTransport();

transport.setListenAddressWithoutSchema(":127.0.0.1:9090");
Expand Down
4 changes: 2 additions & 2 deletions dependencies/default/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<mock-server.version>5.14.0</mock-server.version>
<nacos-client.version>2.2.0</nacos-client.version>
<netflix-commons.version>0.3.0</netflix-commons.version>
<netty.version>4.1.110.Final</netty.version>
<netty.version>4.1.112.Final</netty.version>
<okhttp3.version>4.10.0</okhttp3.version>
<prometheus.version>0.16.0</prometheus.version>
<protobuf.version>3.21.12</protobuf.version>
Expand All @@ -98,7 +98,7 @@
<spring-boot.version>2.7.18</spring-boot.version>
<swagger.version>1.6.9</swagger.version>
<swagger2markup.version>1.3.3</swagger2markup.version>
<vertx.version>4.4.9</vertx.version>
<vertx.version>4.5.9</vertx.version>
<zipkin.version>2.24.0</zipkin.version>
<zipkin-reporter.version>2.16.3</zipkin-reporter.version>
<!-- Base dir of main -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,116 @@
*/
package io.vertx.core.impl;

import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import io.netty.channel.EventLoop;
import io.vertx.codegen.annotations.Nullable;
import io.vertx.core.AsyncResult;
import io.vertx.core.Context;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.Promise;
import io.vertx.core.ThreadingModel;
import io.vertx.core.json.JsonObject;
import io.vertx.core.spi.tracing.VertxTracer;

/**
* This class is created to make vertx unit test easier
*/
@SuppressWarnings({"rawtypes"})
public class SyncContext extends ContextBase implements ContextInternal {
private static final long serialVersionUID = -6209656149925076980L;

public class SyncContext extends EventLoopContext {
protected VertxInternal owner;

protected Executor executor = Executors.newSingleThreadExecutor();

public SyncContext() {
this(null);
this(0);
}

public SyncContext(VertxInternal vertx) {
super(vertx, null, null, null, null, null, null);
public SyncContext(int localsLength) {
super(localsLength);
}

@Override
public VertxInternal owner() {
return owner;
}

public void setOwner(VertxInternal owner) {
this.owner = owner;
@Override
public Context exceptionHandler(@Nullable Handler<Throwable> handler) {
return null;
}

@Override
public @Nullable Handler<Throwable> exceptionHandler() {
return null;
}

@Override
public boolean inThread() {
return false;
}

@Override
public <T> void emit(T t, Handler<T> handler) {

}

@Override
public void execute(Runnable runnable) {

}

@Override
public <T> void execute(T t, Handler<T> handler) {

}

@Override
public void reportException(Throwable throwable) {

}

@Override
public ConcurrentMap<Object, Object> contextData() {
return null;
}

@Override
public ClassLoader classLoader() {
return null;
}

@Override
protected void runOnContext(ContextInternal ctx, Handler<Void> action) {
action.handle(null);
public WorkerPool workerPool() {
return null;
}

@Override
public VertxTracer tracer() {
return null;
}

@Override
public ContextInternal duplicate() {
return null;
}

@Override
public CloseFuture closeFuture() {
return null;
}

public void setOwner(VertxInternal owner) {
this.owner = owner;
}


public static <T> void syncExecuteBlocking(Handler<Promise<T>> blockingCodeHandler,
Handler<AsyncResult<T>> asyncResultHandler) {
Promise<T> res = Promise.promise();
Expand All @@ -70,7 +150,6 @@ private static <T> Future<T> syncExecuteBlocking(Handler<Promise<T>> blockingCod
return res.future();
}

res.complete();
return res.future();
}

Expand All @@ -80,8 +159,81 @@ public <T> Future<T> executeBlockingInternal(Handler<Promise<T>> action) {
}

@Override
public <T> Future<T> executeBlockingInternal(Callable<T> callable) {
return null;
}

@Override
public <T> Future<T> executeBlockingInternal(Handler<Promise<T>> handler, boolean b) {
return null;
}

@Override
public <T> Future<T> executeBlockingInternal(Callable<T> callable, boolean b) {
return null;
}

@Override
public Deployment getDeployment() {
return null;
}

@Override
public Executor executor() {
return executor;
}

@Override
public EventLoop nettyEventLoop() {
return null;
}

@Override
@Deprecated
public <T> Future<T> executeBlocking(Handler<Promise<T>> handler, TaskQueue taskQueue) {
return null;
}

@Override
public <T> Future<T> executeBlocking(Callable<T> callable, TaskQueue taskQueue) {
return null;
}

@Override
@Deprecated
public <T> void executeBlocking(Handler<Promise<T>> blockingCodeHandler, boolean ordered,
Handler<AsyncResult<T>> asyncResultHandler) {
syncExecuteBlocking(blockingCodeHandler, asyncResultHandler);
}

@Override
public <T> Future<@Nullable T> executeBlocking(Callable<T> callable, boolean b) {
return null;
}

@Override
@Deprecated
public <T> Future<@Nullable T> executeBlocking(Handler<Promise<T>> handler, boolean b) {
return null;
}

@Override
public @Nullable JsonObject config() {
return null;
}

@Override
public boolean isEventLoopContext() {
return false;
}

@Override
public boolean isWorkerContext() {
return false;
}

@Override
public ThreadingModel threadingModel() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,20 @@ private static TCPSSLOptions buildTCPSSLOptions(SSLOption sslOption, SSLCustom s
tcpClientOptions.setSsl(true);

if (sslOption.getEngine().equalsIgnoreCase("openssl")) {
tcpClientOptions.setOpenSslEngineOptions(new OpenSSLEngineOptions());
tcpClientOptions.setSslEngineOptions(new OpenSSLEngineOptions());
}
String fullKeyStore = sslCustom.getFullPath(sslOption.getKeyStore());
if (isFileExists(fullKeyStore)) {
if (STORE_PKCS12.equalsIgnoreCase(sslOption.getKeyStoreType())) {
PfxOptions keyPfxOptions = new PfxOptions();
keyPfxOptions.setPath(fullKeyStore);
keyPfxOptions.setPassword(new String(sslCustom.decode(sslOption.getKeyStoreValue().toCharArray())));
tcpClientOptions.setPfxKeyCertOptions(keyPfxOptions);
tcpClientOptions.setKeyCertOptions(keyPfxOptions);
} else if (STORE_JKS.equalsIgnoreCase(sslOption.getKeyStoreType())) {
JksOptions keyJksOptions = new JksOptions();
keyJksOptions.setPath(fullKeyStore);
keyJksOptions.setPassword(new String(sslCustom.decode(sslOption.getKeyStoreValue().toCharArray())));
tcpClientOptions.setKeyStoreOptions(keyJksOptions);
tcpClientOptions.setKeyCertOptions(keyJksOptions);
} else {
throw new IllegalArgumentException("invalid key store type.");
}
Expand All @@ -137,13 +137,13 @@ private static TCPSSLOptions buildTCPSSLOptions(SSLOption sslOption, SSLCustom s
trustPfxOptions.setPath(fullTrustStore);
trustPfxOptions
.setPassword(new String(sslCustom.decode(sslOption.getTrustStoreValue().toCharArray())));
tcpClientOptions.setPfxTrustOptions(trustPfxOptions);
tcpClientOptions.setTrustOptions(trustPfxOptions);
} else if (STORE_JKS.equalsIgnoreCase(sslOption.getTrustStoreType())) {
JksOptions trustJksOptions = new JksOptions();
trustJksOptions.setPath(fullTrustStore);
trustJksOptions
.setPassword(new String(sslCustom.decode(sslOption.getTrustStoreValue().toCharArray())));
tcpClientOptions.setTrustStoreOptions(trustJksOptions);
tcpClientOptions.setTrustOptions(trustJksOptions);
} else {
throw new IllegalArgumentException("invalid trust store type.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.net.InetSocketAddress;

import org.apache.servicecomb.foundation.common.net.URIEndpointObject;
import org.apache.servicecomb.foundation.common.utils.ExceptionUtils;
import org.apache.servicecomb.foundation.ssl.SSLCustom;
import org.apache.servicecomb.foundation.ssl.SSLOption;
import org.apache.servicecomb.foundation.ssl.SSLOptionFactory;
Expand Down Expand Up @@ -78,7 +77,7 @@ public void init(Vertx vertx, String sslKey, AsyncResultCallback<InetSocketAddre
TcpServerConnection connection = createTcpServerConnection();
connection.init(netSocket);
});
netServer.exceptionHandler(e -> LOGGER.error("Unexpected error in server.{}", ExceptionUtils.getExceptionMessageWithoutTrace(e)));
netServer.exceptionHandler(e -> LOGGER.error("Unexpected error in server.", e));
InetSocketAddress socketAddress = endpointObject.getSocketAddress();
netServer.listen(socketAddress.getPort(), socketAddress.getHostString(), ar -> {
if (ar.succeeded()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@

package io.vertx.ext.web.impl;

import io.vertx.ext.web.RequestBody;
import org.apache.servicecomb.foundation.vertx.http.VertxServerRequestToHttpServletRequest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import io.vertx.core.http.impl.HttpServerRequestInternal;
import io.vertx.core.net.HostAndPort;
import io.vertx.ext.web.AllowForwardHeaders;
import io.vertx.ext.web.RequestBody;
import io.vertx.ext.web.RoutingContext;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

// HttpServerRequestWrapper is a package visible class, so put this test in package io.vertx.ext.web.impl
public class TestHttpServerRequestUtils {
Expand All @@ -36,6 +37,7 @@ public void testVertxServerRequestToHttpServletRequest() {
HttpServerRequestWrapper wrapper = new HttpServerRequestWrapper(request, AllowForwardHeaders.NONE);
Mockito.when(request.scheme()).thenReturn("http");
Mockito.when(context.request()).thenReturn(wrapper);
Mockito.when(request.authority()).thenReturn(HostAndPort.create("localhost", 8080));
RequestBody requestBody = Mockito.mock(RequestBody.class);
Mockito.when(context.body()).thenReturn(requestBody);

Expand Down
Loading
Loading