From e79449a9f4004a6a71c30d2e35421a928c3ae554 Mon Sep 17 00:00:00 2001 From: "liujianjun.ljj" Date: Thu, 29 Feb 2024 17:49:57 +0800 Subject: [PATCH 1/2] add queueRemainingSize at the beginning --- .../com/alipay/sofa/rpc/boot/common/RpcThreadPoolMonitor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/main/java/com/alipay/sofa/rpc/boot/common/RpcThreadPoolMonitor.java b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/main/java/com/alipay/sofa/rpc/boot/common/RpcThreadPoolMonitor.java index 8d654f2db..dd10af9f7 100644 --- a/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/main/java/com/alipay/sofa/rpc/boot/common/RpcThreadPoolMonitor.java +++ b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/main/java/com/alipay/sofa/rpc/boot/common/RpcThreadPoolMonitor.java @@ -82,6 +82,7 @@ public void start() { StringBuilder sb = new StringBuilder(); sb.append("coreSize:" + threadPoolExecutor.getCorePoolSize() + ","); sb.append("maxPoolSize:" + threadPoolExecutor.getMaximumPoolSize() + ","); + sb.append("queueRemainingSize:" + threadPoolExecutor.getQueue().remainingCapacity() + ","); sb.append("keepAliveTime:" + threadPoolExecutor.getKeepAliveTime(TimeUnit.MILLISECONDS) + "\n"); From 56bb340a449095ddc8b1a12010ab849e9afa1d9a Mon Sep 17 00:00:00 2001 From: "liujianjun.ljj" Date: Mon, 26 May 2025 20:56:13 +0800 Subject: [PATCH 2/2] fix unRef problem --- .../runtime/adapter/RpcBindingAdapter.java | 3 +- .../ConsumerConfigContainerTest.java | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/java/com/alipay/sofa/rpc/boot/test/container/ConsumerConfigContainerTest.java diff --git a/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/main/java/com/alipay/sofa/rpc/boot/runtime/adapter/RpcBindingAdapter.java b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/main/java/com/alipay/sofa/rpc/boot/runtime/adapter/RpcBindingAdapter.java index 6481ea1d4..117f71176 100644 --- a/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/main/java/com/alipay/sofa/rpc/boot/runtime/adapter/RpcBindingAdapter.java +++ b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/main/java/com/alipay/sofa/rpc/boot/runtime/adapter/RpcBindingAdapter.java @@ -201,12 +201,11 @@ public Object inBinding(Object contract, RpcBinding binding, if (MockMode.LOCAL.equalsIgnoreCase(binding.getRpcBindingParam().getMockMode())) { consumerConfig.setMockRef(consumerConfigHelper.getMockRef(binding, applicationContext)); } - + binding.setConsumerConfig(consumerConfig); consumerConfigContainer.addConsumerConfig(binding, consumerConfig); try { Object result = consumerConfig.refer(); - binding.setConsumerConfig(consumerConfig); return result; } catch (Exception e) { throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_CONSUME_FAIL), e); diff --git a/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/java/com/alipay/sofa/rpc/boot/test/container/ConsumerConfigContainerTest.java b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/java/com/alipay/sofa/rpc/boot/test/container/ConsumerConfigContainerTest.java new file mode 100644 index 000000000..99ae8ca42 --- /dev/null +++ b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/test/java/com/alipay/sofa/rpc/boot/test/container/ConsumerConfigContainerTest.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alipay.sofa.rpc.boot.test.container; + +import com.alipay.sofa.rpc.boot.container.ConsumerConfigContainer; +import com.alipay.sofa.rpc.boot.runtime.binding.BoltBinding; +import com.alipay.sofa.rpc.boot.runtime.param.BoltBindingParam; +import com.alipay.sofa.rpc.config.ConsumerConfig; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Even + * @date 2025/5/26 20:33 + */ +public class ConsumerConfigContainerTest { + + @Test + public void test() { + ConsumerConfigContainer consumerConfigContainer = new ConsumerConfigContainer(); + ConsumerConfig consumerConfig = new ConsumerConfig<>(); + BoltBinding binding = new BoltBinding(new BoltBindingParam(), null, true); + consumerConfigContainer.addConsumerConfig(binding, consumerConfig); + binding.setConsumerConfig(consumerConfig); + Assert.assertNull(null, consumerConfigContainer.getConsumerConfigMap().remove(binding)); + } + +} \ No newline at end of file