Skip to content

Commit a4833bf

Browse files
committed
Merge remote-tracking branch 'origin/3.2' into version
* origin/3.2: (22 commits) Update codecov config (apache#11582) metric package structure optimization (apache#11576) Fix compile Provides the public part of metrics data collection and export (apache#11522) [Triple] Fix boxed type methods (apache#11577) Bump to 3.2.0-beta.6-SNAPSHOT Fix synchronized in ModelEnvironment (apache#11584) Fix conflict Fix concurrent issue in scope model (apache#11525) Update codecov config (apache#11580) Set timeout value to string (apache#11565) Skip mapping retry if metadata config is invalid (apache#11323) Fix stackoverflow in SerializeSecurityConfigurator (apache#11561) Revert clear response operation of timeoutfilter (apache#11562) Fix hessian2 serializable check (apache#11573) feat: fix oom (apache#11571) Enhance serializable check option (apache#11460) Fix config absent when refresh (apache#11505) Enhance json util check (apache#11501) classNotFound (apache#11552) ...
2 parents aa859a2 + 62509fb commit a4833bf

File tree

121 files changed

+1841
-860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+1841
-860
lines changed

.codecov.yml codecov.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,23 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
codecov:
17+
require_ci_to_pass: false
18+
notify:
19+
wait_for_ci: false
1620
coverage:
1721
status:
1822
# pull-requests only
1923
patch:
2024
default:
2125
threshold: 0.1%
2226
ignore:
23-
- "dubbo-demo/.*"
24-
- "dubbo-common/src/main/java/org/apache/dubbo/common/json/*.java" # internal JSON impl is deprecate, ignore test coverage for them
25-
- "dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/AnnotationBean.java" # Deprecated
26-
- "dubbo-rpc/dubbo-rpc-thrift/.*"
27+
- "**/dubbo-demo/**"
28+
- "**/dubbo-compiler/**"
29+
- "**/dubbo-test/**"
30+
- "**/dubbo-compatible/**"
31+
- "**/dubbo-native/**"
32+
- "**/dubbo-native-plugin/**"
33+
- "**/dubbo-common/src/main/java/org/apache/dubbo/common/json/*.java" # internal JSON impl is deprecate, ignore test coverage for them
34+
- "**/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/AnnotationBean.java" # Deprecated
35+
- "**/dubbo-rpc/dubbo-rpc-thrift/**"

dubbo-common/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<artifactId>commons-logging</artifactId>
4343
<scope>provided</scope>
4444
</dependency>
45+
4546
<dependency>
4647
<groupId>log4j</groupId>
4748
<artifactId>log4j</artifactId>

dubbo-common/src/main/java/org/apache/dubbo/common/beans/factory/ScopeBeanFactory.java

+9
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,15 @@ private int getNextId(Class<?> beanClass) {
186186
return ConcurrentHashMapUtils.computeIfAbsent(beanNameIdCounterMap, beanClass, key -> new AtomicInteger()).incrementAndGet();
187187
}
188188

189+
@SuppressWarnings("unchecked")
190+
public <T> List<T> getBeansOfType(Class<T> type) {
191+
List<T> currentBeans = (List<T>) registeredBeanInfos.stream().filter(beanInfo -> type.isInstance(beanInfo.instance)).map(beanInfo -> beanInfo.instance).collect(Collectors.toList());
192+
if (parent != null) {
193+
currentBeans.addAll(parent.getBeansOfType(type));
194+
}
195+
return currentBeans;
196+
}
197+
189198
public <T> T getBean(Class<T> type) {
190199
return this.getBean(null, type);
191200
}

dubbo-common/src/main/java/org/apache/dubbo/common/config/Environment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public String getLocalMigrationRule() {
315315
return localMigrationRule;
316316
}
317317

318-
public void refreshClassLoaders() {
318+
public synchronized void refreshClassLoaders() {
319319
propertiesConfiguration.refresh();
320320
loadMigrationRule();
321321
this.globalConfiguration = null;

dubbo-common/src/main/java/org/apache/dubbo/common/config/ModuleEnvironment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public String getLocalMigrationRule() {
220220
}
221221

222222
@Override
223-
public void refreshClassLoaders() {
223+
public synchronized void refreshClassLoaders() {
224224
orderedPropertiesConfiguration.refresh();
225225
applicationDelegate.refreshClassLoaders();
226226
}

dubbo-common/src/main/java/org/apache/dubbo/common/json/impl/AbstractJSONImpl.java

+19
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,30 @@
1717
package org.apache.dubbo.common.json.impl;
1818

1919
import org.apache.dubbo.common.json.JSON;
20+
import org.apache.dubbo.common.utils.CollectionUtils;
2021

22+
import java.util.HashMap;
23+
import java.util.LinkedList;
2124
import java.util.List;
2225
import java.util.Map;
2326

2427
public abstract class AbstractJSONImpl implements JSON {
28+
@Override
29+
public boolean isSupport() {
30+
try {
31+
Map<String, String> map = new HashMap<>();
32+
map.put("json", "test");
33+
if (!CollectionUtils.mapEquals(map, toJavaObject(toJson(map), Map.class))) {
34+
return false;
35+
}
36+
37+
List<String> list = new LinkedList<>();
38+
list.add("json");
39+
return CollectionUtils.equals(list, toJavaList(toJson(list), String.class));
40+
} catch (Throwable t) {
41+
return false;
42+
}
43+
}
2544

2645
@Override
2746
public List<?> getList(Map<String, ?> obj, String key) {

dubbo-common/src/main/java/org/apache/dubbo/common/json/impl/FastJson2Impl.java

-12
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,13 @@
1616
*/
1717
package org.apache.dubbo.common.json.impl;
1818

19-
import org.apache.dubbo.common.utils.ClassUtils;
20-
2119
import com.alibaba.fastjson2.JSONWriter;
2220

2321
import java.lang.reflect.Type;
2422
import java.util.List;
2523

2624
public class FastJson2Impl extends AbstractJSONImpl {
2725

28-
@Override
29-
public boolean isSupport() {
30-
try {
31-
Class<?> aClass = ClassUtils.forName("com.alibaba.fastjson2.JSON");
32-
return aClass != null;
33-
} catch (Exception t) {
34-
return false;
35-
}
36-
}
37-
3826
@Override
3927
public <T> T toJavaObject(String json, Type type) {
4028
return com.alibaba.fastjson2.JSON.parseObject(json, type);

dubbo-common/src/main/java/org/apache/dubbo/common/json/impl/FastJsonImpl.java

-12
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,13 @@
1616
*/
1717
package org.apache.dubbo.common.json.impl;
1818

19-
import org.apache.dubbo.common.utils.ClassUtils;
20-
2119
import com.alibaba.fastjson.serializer.SerializerFeature;
2220

2321
import java.lang.reflect.Type;
2422
import java.util.List;
2523

2624
public class FastJsonImpl extends AbstractJSONImpl {
2725

28-
@Override
29-
public boolean isSupport() {
30-
try {
31-
Class<?> aClass = ClassUtils.forName("com.alibaba.fastjson.JSON");
32-
return aClass != null;
33-
} catch (Throwable t) {
34-
return false;
35-
}
36-
}
37-
3826
@Override
3927
public <T> T toJavaObject(String json, Type type) {
4028
return com.alibaba.fastjson.JSON.parseObject(json, type);

dubbo-common/src/main/java/org/apache/dubbo/common/json/impl/GsonImpl.java

-12
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
*/
1717
package org.apache.dubbo.common.json.impl;
1818

19-
import org.apache.dubbo.common.utils.ClassUtils;
20-
2119
import com.google.gson.Gson;
2220
import com.google.gson.reflect.TypeToken;
2321

@@ -28,16 +26,6 @@ public class GsonImpl extends AbstractJSONImpl {
2826
// weak reference of com.google.gson.Gson, prevent throw exception when init
2927
private volatile Object gsonCache = null;
3028

31-
@Override
32-
public boolean isSupport() {
33-
try {
34-
Class<?> aClass = ClassUtils.forName("com.google.gson.Gson");
35-
return aClass != null;
36-
} catch (Throwable t) {
37-
return false;
38-
}
39-
}
40-
4129
@Override
4230
public <T> T toJavaObject(String json, Type type) {
4331
return getGson().fromJson(json, type);

dubbo-common/src/main/java/org/apache/dubbo/common/json/impl/JacksonImpl.java

+3-15
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,18 @@
1616
*/
1717
package org.apache.dubbo.common.json.impl;
1818

19-
import java.lang.reflect.Type;
20-
import java.util.List;
21-
22-
import org.apache.dubbo.common.utils.ClassUtils;
23-
2419
import com.fasterxml.jackson.annotation.JsonInclude.Include;
2520
import com.fasterxml.jackson.databind.MapperFeature;
2621
import com.fasterxml.jackson.databind.json.JsonMapper;
2722
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
2823

24+
import java.lang.reflect.Type;
25+
import java.util.List;
26+
2927
public class JacksonImpl extends AbstractJSONImpl {
3028

3129
private volatile Object jacksonCache = null;
3230

33-
@Override
34-
public boolean isSupport() {
35-
try {
36-
Class<?> aClass = ClassUtils.forName("com.fasterxml.jackson.databind.json.JsonMapper");
37-
return aClass != null;
38-
} catch (Throwable t) {
39-
return false;
40-
}
41-
}
42-
4331
@Override
4432
public <T> T toJavaObject(String json, Type type) {
4533
try {

dubbo-common/src/main/java/org/apache/dubbo/common/utils/DefaultSerializeClassChecker.java

+4
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,8 @@ private Class<?> loadClass0(ClassLoader classLoader, String className) throws Cl
201201
public static DefaultSerializeClassChecker getInstance() {
202202
return FrameworkModel.defaultModel().getBeanFactory().getBean(DefaultSerializeClassChecker.class);
203203
}
204+
205+
public boolean isCheckSerializable() {
206+
return checkSerializable;
207+
}
204208
}

dubbo-common/src/main/java/org/apache/dubbo/common/utils/SerializeSecurityConfigurator.java

+21-15
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
*/
1717
package org.apache.dubbo.common.utils;
1818

19+
import org.apache.dubbo.common.constants.CommonConstants;
20+
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
21+
import org.apache.dubbo.common.logger.LoggerFactory;
22+
import org.apache.dubbo.config.ApplicationConfig;
23+
import org.apache.dubbo.rpc.model.FrameworkModel;
24+
import org.apache.dubbo.rpc.model.ModuleModel;
25+
import org.apache.dubbo.rpc.model.ScopeClassLoaderListener;
26+
1927
import java.io.IOException;
2028
import java.lang.reflect.Field;
2129
import java.lang.reflect.GenericArrayType;
@@ -32,14 +40,6 @@
3240
import java.util.Set;
3341
import java.util.stream.Collectors;
3442

35-
import org.apache.dubbo.common.constants.CommonConstants;
36-
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
37-
import org.apache.dubbo.common.logger.LoggerFactory;
38-
import org.apache.dubbo.config.ApplicationConfig;
39-
import org.apache.dubbo.rpc.model.FrameworkModel;
40-
import org.apache.dubbo.rpc.model.ModuleModel;
41-
import org.apache.dubbo.rpc.model.ScopeClassLoaderListener;
42-
4343
import static org.apache.dubbo.common.constants.CommonConstants.CLASS_DESERIALIZE_ALLOWED_LIST;
4444
import static org.apache.dubbo.common.constants.CommonConstants.CLASS_DESERIALIZE_BLOCKED_LIST;
4545
import static org.apache.dubbo.common.constants.CommonConstants.CLASS_DESERIALIZE_BLOCK_ALL;
@@ -185,8 +185,9 @@ public synchronized void registerInterface(Class<?> clazz) {
185185
return;
186186
}
187187

188-
Set<Class<?>> markedClass = new HashSet<>();
188+
Set<Type> markedClass = new HashSet<>();
189189
markedClass.add(clazz);
190+
checkClass(markedClass, clazz);
190191

191192
addToAllow(clazz.getName());
192193

@@ -221,10 +222,17 @@ public synchronized void registerInterface(Class<?> clazz) {
221222
}
222223
}
223224

224-
private void checkType(Set<Class<?>> markedClass, Type type) {
225+
private void checkType(Set<Type> markedClass, Type type) {
225226
if (type instanceof Class) {
226227
checkClass(markedClass, (Class<?>) type);
227-
} else if (type instanceof ParameterizedType) {
228+
return;
229+
}
230+
231+
if (!markedClass.add(type)) {
232+
return;
233+
}
234+
235+
if (type instanceof ParameterizedType) {
228236
ParameterizedType parameterizedType = (ParameterizedType) type;
229237
checkClass(markedClass, (Class<?>) parameterizedType.getRawType());
230238
for (Type actualTypeArgument : parameterizedType.getActualTypeArguments()) {
@@ -249,13 +257,11 @@ private void checkType(Set<Class<?>> markedClass, Type type) {
249257
}
250258
}
251259

252-
private void checkClass(Set<Class<?>> markedClass, Class<?> clazz) {
253-
if (markedClass.contains(clazz)) {
260+
private void checkClass(Set<Type> markedClass, Class<?> clazz) {
261+
if (!markedClass.add(clazz)) {
254262
return;
255263
}
256264

257-
markedClass.add(clazz);
258-
259265
addToAllow(clazz.getName());
260266

261267
Class<?>[] interfaces = clazz.getInterfaces();

0 commit comments

Comments
 (0)