@Override
    public void registerContextPath(final MetaDataRegisterDTO dto) {
        String name = PluginEnum.CONTEXT_PATH.getName();
        String contextPath = PathUtils.decoratorContextPath(dto.getContextPath());
        String key = LOCK_KEY_PREFIX + contextPath;
        Lock lock = registry.obtain(key);
        if (logger.isDebugEnabled()) {
            logger.debug("register context-path obtain lock for key:{}", key);
        }
        try {
            lock.lock();
            String contextPathSelectorId = getSelectorService().registerDefault(dto, name, "");
            // avoid repeated registration for many client threads
            // many client threads may register the same context path for contextPath plugin at the same time
            if (Objects.nonNull(getRuleService().findBySelectorIdAndName(contextPathSelectorId, dto.getContextPath()))) {
                return;
            }
            ContextMappingRuleHandle handle = new ContextMappingRuleHandle();
            handle.setContextPath(contextPath);
            handle.setAddPrefixed(dto.getAddPrefixed());
            getRuleService().registerDefault(buildContextPathDefaultRuleDTO(contextPathSelectorId, dto, handle.toJson()));
        } finally {
            lock.unlock();
        }
    }
@Test
    public void testRegisterContextPath() {
        MetaDataRegisterDTO dto = MetaDataRegisterDTO.builder().build();
        dto.setContextPath("Context_Path");
        dto.setAddPrefixed(true);
        when(selectorService.registerDefault(dto, PluginEnum.CONTEXT_PATH.getName(), "")).thenReturn("Context_Path_Selector_Id");
        // org.springframework.integration.jdbc.lock.JdbcLockRegistry.JdbcLock is private and cannot be mocked directly so we mock the LockRegistry and return a mock MockLock
        // here  mock ReentrantLock   cause cpu usage 100% in the jdk 19 20 21 environment
        when(registry.obtain(any())).thenReturn(mock(MockLock.class));
        when(ruleService.findBySelectorIdAndName("Context_Path_Selector_Id", "Context_Path")).thenReturn(null);
        when(ruleService.registerDefault(any())).thenReturn("Context_Path_Rule_Id");
        abstractContextPathRegisterService.registerContextPath(dto);
        verify(ruleService).registerDefault(any());
    }