Skip to content

Commit

Permalink
Merge branch '3.1' into 0118_skip_if_no_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ authored Feb 15, 2023
2 parents f6b9984 + 59a62a6 commit 42eea33
Show file tree
Hide file tree
Showing 76 changed files with 2,837 additions and 1,021 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build-and-test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,45 @@ jobs:
with:
name: "error-inspection-result"
path: ${{ github.workspace }}/dubbo-test-tools/dubbo-error-code-inspector/error-inspection-result.txt

native-image-inspecting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: "./dubbo"

- name: "Setup GraalVM environment"
uses: graalvm/setup-graalvm@v1
with:
version: '22.3.0'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'

- name: "Setup Zookeeper environment"
run: |
wget https://dlcdn.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz
tar -zxvf apache-zookeeper-3.7.1-bin.tar.gz
mv apache-zookeeper-3.7.1-bin/conf/zoo_sample.cfg apache-zookeeper-3.7.1-bin/conf/zoo.cfg
apache-zookeeper-3.7.1-bin/bin/zkServer.sh start
- name: "Check environment"
run: |
java --version
native-image --version
- name: "Compile Dubbo (Linux)"
run: |
cd ${{ github.workspace }}/dubbo
./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean install -DskipTests=true -DskipIntegrationTests=true -Dcheckstyle.skip=true -Dcheckstyle_unix.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true
- name: "Compile and run Dubbo demo for native (Linux)"
run: |
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider
${{ github.workspace }}/dubbo/mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean package -P native -Dmaven.test.skip=true
nohup ./target/demo-native-provider &
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer
${{ github.workspace }}/dubbo/mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean package -P native -Dmaven.test.skip=true
./target/demo-native-consumer
43 changes: 43 additions & 0 deletions .github/workflows/build-and-test-scheduled-3.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,46 @@ jobs:
with:
name: "error-inspection-result"
path: ${{ github.workspace }}/dubbo-test-tools/dubbo-error-code-inspector/error-inspection-result.txt

native-image-inspecting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: "3.1"
path: "./dubbo"

- name: "Setup GraalVM environment"
uses: graalvm/setup-graalvm@v1
with:
version: '22.3.0'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'

- name: "Setup Zookeeper environment"
run: |
wget https://dlcdn.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz
tar -zxvf apache-zookeeper-3.7.1-bin.tar.gz
mv apache-zookeeper-3.7.1-bin/conf/zoo_sample.cfg apache-zookeeper-3.7.1-bin/conf/zoo.cfg
apache-zookeeper-3.7.1-bin/bin/zkServer.sh start
- name: "Check environment"
run: |
java --version
native-image --version
- name: "Compile Dubbo (Linux)"
run: |
cd ${{ github.workspace }}/dubbo
./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean install -DskipTests=true -DskipIntegrationTests=true -Dcheckstyle.skip=true -Dcheckstyle_unix.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true
- name: "Compile and run Dubbo demo for native (Linux)"
run: |
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider
${{ github.workspace }}/dubbo/mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean package -P native -Dmaven.test.skip=true
nohup ./target/demo-native-provider &
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer
${{ github.workspace }}/dubbo/mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean package -P native -Dmaven.test.skip=true
./target/demo-native-consumer
43 changes: 43 additions & 0 deletions .github/workflows/build-and-test-scheduled-3.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,46 @@ jobs:
with:
name: "error-inspection-result"
path: ${{ github.workspace }}/dubbo-test-tools/dubbo-error-code-inspector/error-inspection-result.txt

native-image-inspecting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: "3.2"
path: "./dubbo"

- name: "Setup GraalVM environment"
uses: graalvm/setup-graalvm@v1
with:
version: '22.3.0'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'

- name: "Setup Zookeeper environment"
run: |
wget https://dlcdn.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz
tar -zxvf apache-zookeeper-3.7.1-bin.tar.gz
mv apache-zookeeper-3.7.1-bin/conf/zoo_sample.cfg apache-zookeeper-3.7.1-bin/conf/zoo.cfg
apache-zookeeper-3.7.1-bin/bin/zkServer.sh start
- name: "Check environment"
run: |
java --version
native-image --version
- name: "Compile Dubbo (Linux)"
run: |
cd ${{ github.workspace }}/dubbo
./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean install -DskipTests=true -DskipIntegrationTests=true -Dcheckstyle.skip=true -Dcheckstyle_unix.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true
- name: "Compile and run Dubbo demo for native (Linux)"
run: |
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider
${{ github.workspace }}/dubbo/mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean package -P native -Dmaven.test.skip=true
nohup ./target/demo-native-provider &
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer
${{ github.workspace }}/dubbo/mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean package -P native -Dmaven.test.skip=true
./target/demo-native-consumer
42 changes: 42 additions & 0 deletions .github/workflows/release-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,45 @@ jobs:
with:
name: "error-inspection-result"
path: ${{ github.workspace }}/dubbo-test-tools/dubbo-error-code-inspector/error-inspection-result.txt

native-image-inspecting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: "./dubbo"

- name: "Setup GraalVM environment"
uses: graalvm/setup-graalvm@v1
with:
version: '22.3.0'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'

- name: "Setup Zookeeper environment"
run: |
wget https://dlcdn.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz
tar -zxvf apache-zookeeper-3.7.1-bin.tar.gz
mv apache-zookeeper-3.7.1-bin/conf/zoo_sample.cfg apache-zookeeper-3.7.1-bin/conf/zoo.cfg
apache-zookeeper-3.7.1-bin/bin/zkServer.sh start
- name: "Check environment"
run: |
java --version
native-image --version
- name: "Compile Dubbo (Linux)"
run: |
cd ${{ github.workspace }}/dubbo
./mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean install -DskipTests=true -DskipIntegrationTests=true -Dcheckstyle.skip=true -Dcheckstyle_unix.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true
- name: "Compile and run Dubbo demo for native (Linux)"
run: |
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-provider
${{ github.workspace }}/dubbo/mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean package -P native -Dmaven.test.skip=true
nohup ./target/demo-native-provider &
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-consumer
${{ github.workspace }}/dubbo/mvnw --batch-mode --no-snapshot-updates -e --no-transfer-progress --fail-fast -T 2C clean package -P native -Dmaven.test.skip=true
./target/demo-native-consumer
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.apache.dubbo.common.lang.ShutdownHookCallbacks;
import org.apache.dubbo.common.status.reporter.FrameworkStatusReportService;
import org.apache.dubbo.common.threadpool.manager.FrameworkExecutorRepository;
import org.apache.dubbo.common.utils.DefaultSerializeClassChecker;
import org.apache.dubbo.common.utils.SerializeSecurityConfigurator;
import org.apache.dubbo.common.utils.SerializeSecurityManager;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.FrameworkModel;
Expand All @@ -35,6 +37,7 @@ public void initializeFrameworkModel(FrameworkModel frameworkModel) {
beanFactory.registerBean(FrameworkExecutorRepository.class);
beanFactory.registerBean(ConverterUtil.class);
beanFactory.registerBean(SerializeSecurityManager.class);
beanFactory.registerBean(DefaultSerializeClassChecker.class);
}

@Override
Expand All @@ -49,5 +52,6 @@ public void initializeApplicationModel(ApplicationModel applicationModel) {
public void initializeModuleModel(ModuleModel moduleModel) {
ScopeBeanFactory beanFactory = moduleModel.getBeanFactory();
beanFactory.registerBean(new ConfigurationCache());
beanFactory.registerBean(SerializeSecurityConfigurator.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
*/
package org.apache.dubbo.common.beanutil;

import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.LogHelper;
import org.apache.dubbo.common.utils.ReflectUtils;
import org.apache.dubbo.common.utils.SerializeClassChecker;

import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand All @@ -32,6 +26,12 @@
import java.util.IdentityHashMap;
import java.util.Map;

import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.DefaultSerializeClassChecker;
import org.apache.dubbo.common.utils.LogHelper;
import org.apache.dubbo.common.utils.ReflectUtils;

public final class JavaBeanSerializeUtil {

private static final Logger logger = LoggerFactory.getLogger(JavaBeanSerializeUtil.class);
Expand Down Expand Up @@ -465,8 +465,7 @@ public static Class<?> name2Class(ClassLoader loader, String name) throws ClassN
if (isReferenceType(name)) {
name = name.substring(1, name.length() - 1);
}
SerializeClassChecker.getInstance().validateClass(name);
return Class.forName(name, false, loader);
return DefaultSerializeClassChecker.getInstance().loadClass(loader, name);
}

private static boolean isArray(String type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,30 @@
*/
package org.apache.dubbo.common.json.impl;

import org.apache.dubbo.common.utils.ClassUtils;

import com.alibaba.fastjson.serializer.SerializerFeature;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.apache.dubbo.common.utils.CollectionUtils;

import com.alibaba.fastjson.serializer.SerializerFeature;

public class FastJsonImpl extends AbstractJSONImpl {

@Override
public boolean isSupport() {
try {
Class<?> aClass = ClassUtils.forName("com.alibaba.fastjson.JSON");
return aClass != null;
Map<String, String> map = new HashMap<>();
map.put("fastjson", "test");
if (!CollectionUtils.mapEquals(map, toJavaObject(toJson(map), Map.class))) {
return false;
}

List<String> list = new LinkedList<>();
list.add("fastjson");
return CollectionUtils.equals(list, toJavaList(toJson(list), String.class));
} catch (Throwable t) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,33 @@
*/
package org.apache.dubbo.common.json.impl;

import org.apache.dubbo.common.utils.ClassUtils;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.apache.dubbo.common.utils.CollectionUtils;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.List;

public class GsonImpl extends AbstractJSONImpl {
// weak reference of com.google.gson.Gson, prevent throw exception when init
private volatile Object gsonCache = null;

@Override
public boolean isSupport() {
try {
Class<?> aClass = ClassUtils.forName("com.google.gson.Gson");
return aClass != null;
Map<String, String> map = new HashMap<>();
map.put("gson", "test");
if (!CollectionUtils.mapEquals(map, toJavaObject(toJson(map), Map.class))) {
return false;
}

List<String> list = new LinkedList<>();
list.add("gson");
return CollectionUtils.equals(list, toJavaList(toJson(list), String.class));
} catch (Throwable t) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

package org.apache.dubbo.common.threadpool.serial;

import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.threadlocal.InternalThreadLocal;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.threadlocal.InternalThreadLocalMap;

import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_ERROR_RUN_THREAD_TASK;

/**
Expand Down Expand Up @@ -97,13 +97,13 @@ public void run() {
Runnable r;
try {
while ((r = runQueue.poll()) != null) {
InternalThreadLocalMap internalThreadLocalMap = InternalThreadLocalMap.getAndRemove();
try {
InternalThreadLocal.removeAll();
r.run();
} catch (RuntimeException e) {
LOGGER.error(COMMON_ERROR_RUN_THREAD_TASK, "", "", "Exception while executing runnable " + r, e);
} finally {
InternalThreadLocal.removeAll();
InternalThreadLocalMap.set(internalThreadLocalMap);
}
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ public interface AllowClassNotifyListener {

SerializeCheckStatus DEFAULT_STATUS = SerializeCheckStatus.WARN;

void notify(SerializeCheckStatus status, Set<String> prefixList);
void notifyPrefix(Set<String> allowedList, Set<String> disAllowedList);

void notifyCheckStatus(SerializeCheckStatus status);

void notifyCheckSerializable(boolean checkSerializable);
}
Loading

0 comments on commit 42eea33

Please sign in to comment.