diff --git a/sofa-ark-parent/core-impl/container/src/main/java/com/alipay/sofa/ark/container/ArkContainer.java b/sofa-ark-parent/core-impl/container/src/main/java/com/alipay/sofa/ark/container/ArkContainer.java index 878b435ef..0eab82a41 100644 --- a/sofa-ark-parent/core-impl/container/src/main/java/com/alipay/sofa/ark/container/ArkContainer.java +++ b/sofa-ark-parent/core-impl/container/src/main/java/com/alipay/sofa/ark/container/ArkContainer.java @@ -250,8 +250,8 @@ public List getProfileConfFiles(String... profiles) { * @throws ArkRuntimeException */ public void reInitializeArkLogger() throws ArkRuntimeException { - for (Map.Entry entry : MultiAppLoggerSpaceManager.getSpacesMap() - .entrySet()) { + for (Map.Entry entry : ((Map) MultiAppLoggerSpaceManager + .getSpacesMap()).entrySet()) { SpaceId spaceId = entry.getKey(); SpaceInfo spaceInfo = entry.getValue(); if (!ArkLoggerFactory.SOFA_ARK_LOGGER_SPACE.equals(spaceId.getSpaceName())) { diff --git a/sofa-ark-parent/core-impl/container/src/test/java/com/alipay/sofa/ark/container/service/classloader/BizClassLoaderTest.java b/sofa-ark-parent/core-impl/container/src/test/java/com/alipay/sofa/ark/container/service/classloader/BizClassLoaderTest.java index 77bec3679..f496f1a36 100644 --- a/sofa-ark-parent/core-impl/container/src/test/java/com/alipay/sofa/ark/container/service/classloader/BizClassLoaderTest.java +++ b/sofa-ark-parent/core-impl/container/src/test/java/com/alipay/sofa/ark/container/service/classloader/BizClassLoaderTest.java @@ -144,7 +144,7 @@ public void testLoadClassFromPluginClassLoader() throws Exception { .setExportClasses("") .setExportPackages(ClassUtils.getPackageName(ITest.class.getName())) .setImportResources(StringUtils.EMPTY_STRING) - .setExportResources("META-INF/services/sofa-ark/com.alipay.sofa.ark.container.service.extension.spi.ServiceB") + .setExportResources("META-INF/services/sofa-ark/com.alipay.sofa.ark.container.service.extension.spi.ServiceB, Sample_Resource_Exported_A") .setPluginClassLoader( new PluginClassLoader(pluginA.getPluginName(), pluginA.getClassPath())); @@ -157,7 +157,7 @@ public void testLoadClassFromPluginClassLoader() throws Exception { .setExportClasses("com.alipay.sofa.ark.sample.common.SampleClassExported,org.aopalliance.aop.Advice") .setExportPackages("") .setImportResources(StringUtils.EMPTY_STRING) - .setExportResources("Sample_Resource_Exported, META-INF/spring/service.xml") + .setExportResources("Sample_Resource_Exported, META-INF/spring/service.xml, Sample_Resource_Exported_A") .setPluginClassLoader( new PluginClassLoader(pluginB.getPluginName(), pluginB.getClassPath())); diff --git a/sofa-ark-parent/support/ark-support-starter/src/main/java/com/alipay/sofa/ark/support/common/DelegateToMasterBizClassLoaderHook.java b/sofa-ark-parent/support/ark-support-starter/src/main/java/com/alipay/sofa/ark/support/common/DelegateToMasterBizClassLoaderHook.java index bc47acd32..258aeb30e 100644 --- a/sofa-ark-parent/support/ark-support-starter/src/main/java/com/alipay/sofa/ark/support/common/DelegateToMasterBizClassLoaderHook.java +++ b/sofa-ark-parent/support/ark-support-starter/src/main/java/com/alipay/sofa/ark/support/common/DelegateToMasterBizClassLoaderHook.java @@ -106,10 +106,17 @@ public URL postFindResource(String name, ClassLoaderService classLoaderService, if (resourceUrl != null && biz.isDeclared(resourceUrl, name)) { return resourceUrl; } - return null; + + Enumeration matchResourceUrls = postFindResources(name, classLoaderService, biz); + + // get the first resource url when match multiple resources + if (matchResourceUrls != null && matchResourceUrls.hasMoreElements()) { + return matchResourceUrls.nextElement(); + } } catch (Exception e) { return null; } + return null; } @Override diff --git a/sofa-ark-parent/support/ark-support-starter/src/test/java/com/alipay/sofa/ark/support/DefaultClassLoaderHookTest.java b/sofa-ark-parent/support/ark-support-starter/src/test/java/com/alipay/sofa/ark/support/DefaultClassLoaderHookTest.java index 50e2a8efe..563747f9d 100644 --- a/sofa-ark-parent/support/ark-support-starter/src/test/java/com/alipay/sofa/ark/support/DefaultClassLoaderHookTest.java +++ b/sofa-ark-parent/support/ark-support-starter/src/test/java/com/alipay/sofa/ark/support/DefaultClassLoaderHookTest.java @@ -140,8 +140,8 @@ public void testLoadClassFromClassLoaderHook() throws Exception { Assert.assertNotNull(bizModel.getBizClassLoader().getResource( "sample-ark-1.0.0-ark-biz.jar")); - // case 7: find resource from master in jar - Assert.assertNotNull(bizModel.getBizClassLoader().getResource("Sample_Resource_Exported")); + // case 7: find resource from master in multiple jar + Assert.assertNull(bizModel.getBizClassLoader().getResource("Sample_Resource_Exported_A")); // case 8: find resources from master but not set provided in biz model Assert.assertFalse(bizModel.getBizClassLoader().getResources("org/slf4j/ILoggerFactory.class")