From f94450be27043500a32dadef0b1ba4d6745c88bf Mon Sep 17 00:00:00 2001 From: lixiaojiee Date: Tue, 22 Jan 2019 17:09:19 +0800 Subject: [PATCH 1/4] some optimize on ExtensionLoader --- .../common/extension/ExtensionLoader.java | 75 +++++++++---------- 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java index 42fa01bb25f..01eb00933e5 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java @@ -110,18 +110,16 @@ public static ExtensionLoader getExtensionLoader(Class type) { throw new IllegalArgumentException("Extension type == null"); } if (!type.isInterface()) { - throw new IllegalArgumentException("Extension type(" + type + ") is not interface!"); + throw new IllegalArgumentException("Extension type (" + type + ") is not interface!"); } if (!withExtensionAnnotation(type)) { - throw new IllegalArgumentException("Extension type(" + type + + throw new IllegalArgumentException("Extension type (" + type + ") is not extension, because WITHOUT @" + SPI.class.getSimpleName() + " Annotation!"); } - ExtensionLoader loader = (ExtensionLoader) EXTENSION_LOADERS.get(type); - if (loader == null) { - EXTENSION_LOADERS.putIfAbsent(type, new ExtensionLoader(type)); - loader = (ExtensionLoader) EXTENSION_LOADERS.get(type); - } + ExtensionLoader loader = (ExtensionLoader) EXTENSION_LOADERS.computeIfAbsent(type, k -> { + return new ExtensionLoader<>(type); + }); return loader; } @@ -296,11 +294,9 @@ public T getLoadedExtension(String name) { if (StringUtils.isEmpty(name)) { throw new IllegalArgumentException("Extension name == null"); } - Holder holder = cachedInstances.get(name); - if (holder == null) { - cachedInstances.putIfAbsent(name, new Holder()); - holder = cachedInstances.get(name); - } + Holder holder = cachedInstances.computeIfAbsent(name, k -> { + return new Holder<>(); + }); return (T) holder.get(); } @@ -331,11 +327,9 @@ public T getExtension(String name) { if ("true".equals(name)) { return getDefaultExtension(); } - Holder holder = cachedInstances.get(name); - if (holder == null) { - cachedInstances.putIfAbsent(name, new Holder()); - holder = cachedInstances.get(name); - } + Holder holder = cachedInstances.computeIfAbsent(name, k -> { + return new Holder<>(); + }); Object instance = holder.get(); if (instance == null) { synchronized (holder) { @@ -354,8 +348,7 @@ public T getExtension(String name) { */ public T getDefaultExtension() { getExtensionClasses(); - if (null == cachedDefaultName || cachedDefaultName.length() == 0 - || "true".equals(cachedDefaultName)) { + if (StringUtils.isBlank(cachedDefaultName) || "true".equals(cachedDefaultName)) { return null; } return getExtension(cachedDefaultName); @@ -394,11 +387,11 @@ public void addExtension(String name, Class clazz) { if (!type.isAssignableFrom(clazz)) { throw new IllegalStateException("Input type " + - clazz + "not implement Extension " + type); + clazz + " doesn't implement the Extension " + type); } if (clazz.isInterface()) { throw new IllegalStateException("Input type " + - clazz + "can not be interface!"); + clazz + " can't be interface!"); } if (!clazz.isAnnotationPresent(Adaptive.class)) { @@ -407,14 +400,14 @@ public void addExtension(String name, Class clazz) { } if (cachedClasses.get().containsKey(name)) { throw new IllegalStateException("Extension name " + - name + " already existed(Extension " + type + ")!"); + name + " already exists (Extension " + type + ")!"); } cachedNames.put(clazz, name); cachedClasses.get().put(name, clazz); } else { if (cachedAdaptiveClass != null) { - throw new IllegalStateException("Adaptive Extension already existed(Extension " + type + ")!"); + throw new IllegalStateException("Adaptive Extension already exists (Extension " + type + ")!"); } cachedAdaptiveClass = clazz; @@ -435,11 +428,11 @@ public void replaceExtension(String name, Class clazz) { if (!type.isAssignableFrom(clazz)) { throw new IllegalStateException("Input type " + - clazz + "not implement Extension " + type); + clazz + " doesn't implement Extension " + type); } if (clazz.isInterface()) { throw new IllegalStateException("Input type " + - clazz + "can not be interface!"); + clazz + " can't be interface!"); } if (!clazz.isAnnotationPresent(Adaptive.class)) { @@ -448,7 +441,7 @@ public void replaceExtension(String name, Class clazz) { } if (!cachedClasses.get().containsKey(name)) { throw new IllegalStateException("Extension name " + - name + " not existed(Extension " + type + ")!"); + name + " doesn't exist (Extension " + type + ")!"); } cachedNames.put(clazz, name); @@ -456,7 +449,7 @@ public void replaceExtension(String name, Class clazz) { cachedInstances.remove(name); } else { if (cachedAdaptiveClass == null) { - throw new IllegalStateException("Adaptive Extension not existed(Extension " + type + ")!"); + throw new IllegalStateException("Adaptive Extension doesn't exist (Extension " + type + ")!"); } cachedAdaptiveClass = clazz; @@ -477,12 +470,12 @@ public T getAdaptiveExtension() { cachedAdaptiveInstance.set(instance); } catch (Throwable t) { createAdaptiveInstanceError = t; - throw new IllegalStateException("fail to create adaptive instance: " + t.toString(), t); + throw new IllegalStateException("Failed to create adaptive instance: " + t.toString(), t); } } } } else { - throw new IllegalStateException("fail to create adaptive instance: " + createAdaptiveInstanceError.toString(), createAdaptiveInstanceError); + throw new IllegalStateException("Failed to create adaptive instance: " + createAdaptiveInstanceError.toString(), createAdaptiveInstanceError); } } @@ -535,8 +528,8 @@ private T createExtension(String name) { } return instance; } catch (Throwable t) { - throw new IllegalStateException("Extension instance(name: " + name + ", class: " + - type + ") could not be instantiated: " + t.getMessage(), t); + throw new IllegalStateException("Extension instance (name: " + name + ", class: " + + type + ") couldn't be instantiated: " + t.getMessage(), t); } } @@ -564,7 +557,7 @@ private T injectExtension(T instance) { method.invoke(instance, object); } } catch (Exception e) { - logger.error("fail to inject via method " + method.getName() + logger.error("Failed to inject via method " + method.getName() + " of interface " + type.getName() + ": " + e.getMessage(), e); } } @@ -672,7 +665,7 @@ private void loadResource(Map> extensionClasses, ClassLoader cl loadClass(extensionClasses, resourceURL, Class.forName(line, true, classLoader), name); } } catch (Throwable t) { - IllegalStateException e = new IllegalStateException("Failed to load extension class(interface: " + type + ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t); + IllegalStateException e = new IllegalStateException("Failed to load extension class (interface: " + type + ", class line: " + line + ") in " + resourceURL + ", cause: " + t.getMessage(), t); exceptions.put(line, e); } } @@ -681,16 +674,16 @@ private void loadResource(Map> extensionClasses, ClassLoader cl reader.close(); } } catch (Throwable t) { - logger.error("Exception when load extension class(interface: " + + logger.error("Exception occured when loading extension class (interface: " + type + ", class file: " + resourceURL + ") in " + resourceURL, t); } } private void loadClass(Map> extensionClasses, java.net.URL resourceURL, Class clazz, String name) throws NoSuchMethodException { if (!type.isAssignableFrom(clazz)) { - throw new IllegalStateException("Error when load extension class(interface: " + + throw new IllegalStateException("Error occured when loading extension class (interface: " + type + ", class line: " + clazz.getName() + "), class " - + clazz.getName() + "is not subtype of interface."); + + clazz.getName() + " is not subtype of interface."); } if (clazz.isAnnotationPresent(Adaptive.class)) { if (cachedAdaptiveClass == null) { @@ -703,7 +696,7 @@ private void loadClass(Map> extensionClasses, java.net.URL reso } else if (isWrapperClass(clazz)) { Set> wrappers = cachedWrapperClasses; if (wrappers == null) { - cachedWrapperClasses = new ConcurrentHashSet>(); + cachedWrapperClasses = new ConcurrentHashSet<>(); wrappers = cachedWrapperClasses; } wrappers.add(clazz); @@ -800,7 +793,7 @@ private String createAdaptiveExtensionClassCode() { } // no need to generate adaptive class since there's no adaptive method found. if (!hasAdaptiveAnnotation) { - throw new IllegalStateException("No adaptive method on extension " + type.getName() + ", refuse to create the adaptive class!"); + throw new IllegalStateException("No adaptive method exists on extension " + type.getName() + ", refuse to create the adaptive class!"); } codeBuilder.append("package ").append(type.getPackage().getName()).append(";"); @@ -815,7 +808,7 @@ private String createAdaptiveExtensionClassCode() { Adaptive adaptiveAnnotation = method.getAnnotation(Adaptive.class); StringBuilder code = new StringBuilder(512); if (adaptiveAnnotation == null) { - code.append("throw new UnsupportedOperationException(\"method ") + code.append("throw new UnsupportedOperationException(\"The method ") .append(method.toString()).append(" of interface ") .append(type.getName()).append(" is not adaptive method!\");"); } else { @@ -858,7 +851,7 @@ private String createAdaptiveExtensionClassCode() { } } if (attribMethod == null) { - throw new IllegalStateException("fail to create adaptive class for interface " + type.getName() + throw new IllegalStateException("Failed to create adaptive class for interface " + type.getName() + ": not found url parameter or url attribute in parameters of method " + method.getName()); } @@ -934,7 +927,7 @@ private String createAdaptiveExtensionClassCode() { code.append("\nString extName = ").append(getNameCode).append(";"); // check extName == null? String s = String.format("\nif(extName == null) " + - "throw new IllegalStateException(\"Fail to get extension(%s) name from url(\" + url.toString() + \") use keys(%s)\");", + "throw new IllegalStateException(\"Failed to get extension (%s) name from url (\" + url.toString() + \") use keys(%s)\");", type.getName(), Arrays.toString(value)); code.append(s); From a5028b9fd020686e75a5dbd58a6ca02aac4c8579 Mon Sep 17 00:00:00 2001 From: lixiaojiee Date: Thu, 24 Jan 2019 15:22:06 +0800 Subject: [PATCH 2/4] make ci rerun --- .../org/apache/dubbo/common/extension/ExtensionLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java index 01eb00933e5..09ae756cb3a 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java @@ -601,7 +601,7 @@ private Map> loadExtensionClasses() { if ((value = value.trim()).length() > 0) { String[] names = NAME_SEPARATOR.split(value); if (names.length > 1) { - throw new IllegalStateException("more than 1 default extension name on extension " + type.getName() + throw new IllegalStateException("More than 1 default extension name on extension " + type.getName() + ": " + Arrays.toString(names)); } if (names.length == 1) { @@ -637,7 +637,7 @@ private void loadDirectory(Map> extensionClasses, String dir, S } } } catch (Throwable t) { - logger.error("Exception when load extension class(interface: " + + logger.error("Exception occured when loading extension class (interface: " + type + ", description file: " + fileName + ").", t); } } From 6d2204bacb65e0ecd88d152d03576635c648a454 Mon Sep 17 00:00:00 2001 From: lixiaojiee Date: Thu, 24 Jan 2019 17:42:35 +0800 Subject: [PATCH 3/4] fix compile error --- .../common/extension/ExtensionLoader.java | 4 ++-- .../common/extension/ExtensionLoaderTest.java | 14 +++++++------- .../ExtensionLoader_Adaptive_Test.java | 18 +++++++++--------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java index 09ae756cb3a..dd6124eb512 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java @@ -762,7 +762,7 @@ private T createAdaptiveExtension() { try { return injectExtension((T) getAdaptiveExtensionClass().newInstance()); } catch (Exception e) { - throw new IllegalStateException("Can not create adaptive extension " + type + ", cause: " + e.getMessage(), e); + throw new IllegalStateException("Can't create adaptive extension " + type + ", cause: " + e.getMessage(), e); } } @@ -793,7 +793,7 @@ private String createAdaptiveExtensionClassCode() { } // no need to generate adaptive class since there's no adaptive method found. if (!hasAdaptiveAnnotation) { - throw new IllegalStateException("No adaptive method exists on extension " + type.getName() + ", refuse to create the adaptive class!"); + throw new IllegalStateException("No adaptive method exist on extension " + type.getName() + ", refuse to create the adaptive class!"); } codeBuilder.append("package ").append(type.getPackage().getName()).append(";"); diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java index 3f767e802b0..b0e878ce60e 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoaderTest.java @@ -87,7 +87,7 @@ public void test_getExtensionLoader_NotInterface() throws Exception { fail(); } catch (IllegalArgumentException expected) { assertThat(expected.getMessage(), - containsString("Extension type(class org.apache.dubbo.common.extension.ExtensionLoaderTest) is not interface")); + containsString("Extension type (class org.apache.dubbo.common.extension.ExtensionLoaderTest) is not interface")); } } @@ -263,7 +263,7 @@ public void test_AddExtension_ExceptionWhenExistedExtension() throws Exception { ExtensionLoader.getExtensionLoader(AddExt1.class).addExtension("impl1", AddExt1_ManualAdd1.class); fail(); } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Extension name impl1 already existed(Extension interface org.apache.dubbo.common.extension.ext8_add.AddExt1)!")); + assertThat(expected.getMessage(), containsString("Extension name impl1 already exists (Extension interface org.apache.dubbo.common.extension.ext8_add.AddExt1)!")); } } @@ -286,7 +286,7 @@ public void test_AddExtension_Adaptive_ExceptionWhenExistedAdaptive() throws Exc loader.addExtension(null, AddExt1_ManualAdaptive.class); fail(); } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Adaptive Extension already existed(Extension interface org.apache.dubbo.common.extension.ext8_add.AddExt1)!")); + assertThat(expected.getMessage(), containsString("Adaptive Extension already exists (Extension interface org.apache.dubbo.common.extension.ext8_add.AddExt1)!")); } } @@ -335,7 +335,7 @@ public void test_replaceExtension_ExceptionWhenNotExistedExtension() throws Exce ExtensionLoader.getExtensionLoader(AddExt1.class).replaceExtension("NotExistedExtension", AddExt1_ManualAdd1.class); fail(); } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Extension name NotExistedExtension not existed(Extension interface org.apache.dubbo.common.extension.ext8_add.AddExt1)")); + assertThat(expected.getMessage(), containsString("Extension name NotExistedExtension doesn't exist (Extension interface org.apache.dubbo.common.extension.ext8_add.AddExt1)")); } } @@ -347,7 +347,7 @@ public void test_replaceExtension_Adaptive_ExceptionWhenNotExistedExtension() th loader.replaceExtension(null, AddExt4_ManualAdaptive.class); fail(); } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Adaptive Extension not existed(Extension interface org.apache.dubbo.common.extension.ext8_add.AddExt4)")); + assertThat(expected.getMessage(), containsString("Adaptive Extension doesn't exist (Extension interface org.apache.dubbo.common.extension.ext8_add.AddExt4)")); } } @@ -361,7 +361,7 @@ public void test_InitError() throws Exception { loader.getExtension("error"); fail(); } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Failed to load extension class(interface: interface org.apache.dubbo.common.extension.ext7.InitErrorExt")); + assertThat(expected.getMessage(), containsString("Failed to load extension class (interface: interface org.apache.dubbo.common.extension.ext7.InitErrorExt")); assertThat(expected.getCause(), instanceOf(ExceptionInInitializerError.class)); } } @@ -437,4 +437,4 @@ public void testInjectExtension() { Assertions.assertNull(injectExtImpl.getGenericType()); } -} \ No newline at end of file +} diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Adaptive_Test.java b/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Adaptive_Test.java index b4db6d49d23..fe64a63b6ed 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Adaptive_Test.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/extension/ExtensionLoader_Adaptive_Test.java @@ -147,8 +147,8 @@ public void test_getAdaptiveExtension_ExceptionWhenNoAdaptiveMethodOnInterface() fail(); } catch (IllegalStateException expected) { assertThat(expected.getMessage(), - allOf(containsString("Can not create adaptive extension interface org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt"), - containsString("No adaptive method on extension org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt, refuse to create the adaptive class"))); + allOf(containsString("Can't create adaptive extension interface org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt"), + containsString("No adaptive method exist on extension org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt, refuse to create the adaptive class"))); } // report same error when get is invoked for multiple times try { @@ -156,8 +156,8 @@ public void test_getAdaptiveExtension_ExceptionWhenNoAdaptiveMethodOnInterface() fail(); } catch (IllegalStateException expected) { assertThat(expected.getMessage(), - allOf(containsString("Can not create adaptive extension interface org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt"), - containsString("No adaptive method on extension org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt, refuse to create the adaptive class"))); + allOf(containsString("Can't create adaptive extension interface org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt"), + containsString("No adaptive method exist on extension org.apache.dubbo.common.extension.ext5.NoAdaptiveMethodExt, refuse to create the adaptive class"))); } } @@ -185,7 +185,7 @@ public void test_getAdaptiveExtension_ExceptionWhenNoUrlAttribute() throws Excep ExtensionLoader.getExtensionLoader(NoUrlParamExt.class).getAdaptiveExtension(); fail(); } catch (Exception expected) { - assertThat(expected.getMessage(), containsString("fail to create adaptive class for interface ")); + assertThat(expected.getMessage(), containsString("Failed to create adaptive class for interface ")); assertThat(expected.getMessage(), containsString(": not found url parameter or url attribute in parameters of method ")); } } @@ -218,7 +218,7 @@ public void test_urlHolder_getAdaptiveExtension_noExtension() throws Exception { ext.echo(holder, "haha"); fail(); } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Fail to get extension(")); + assertThat(expected.getMessage(), containsString("Failed to get extension")); } url = url.addParameter("ext2", "XXX"); @@ -281,7 +281,7 @@ public void test_urlHolder_getAdaptiveExtension_ExceptionWhenNameNotProvided() t ext.echo(holder, "impl1"); fail(); } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Fail to get extension(")); + assertThat(expected.getMessage(), containsString("Failed to get extension")); } url = url.addParameter("key1", "impl1"); @@ -290,7 +290,7 @@ public void test_urlHolder_getAdaptiveExtension_ExceptionWhenNameNotProvided() t ext.echo(holder, "haha"); fail(); } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Fail to get extension(org.apache.dubbo.common.extension.ext2.Ext2) name from url")); + assertThat(expected.getMessage(), containsString("Failed to get extension (org.apache.dubbo.common.extension.ext2.Ext2) name from url")); } } @@ -319,4 +319,4 @@ public void test_getAdaptiveExtension_InjectNotExtFail() throws Exception { Ext6Impl2 impl = (Ext6Impl2) ext; assertNull(impl.getList()); } -} \ No newline at end of file +} From 3e0a57a9c854f58b47d7a69ba5f40c7e32c597e1 Mon Sep 17 00:00:00 2001 From: lixiaojiee Date: Fri, 25 Jan 2019 01:39:17 +0800 Subject: [PATCH 4/4] fix ci failure --- .../common/extension/ExtensionLoader.java | 24 ++++++++++------- .../dubbo/monitor/dubbo/DubboMonitorTest.java | 26 +++++++++---------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java index dd6124eb512..380dbbf1905 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java @@ -117,9 +117,11 @@ public static ExtensionLoader getExtensionLoader(Class type) { ") is not extension, because WITHOUT @" + SPI.class.getSimpleName() + " Annotation!"); } - ExtensionLoader loader = (ExtensionLoader) EXTENSION_LOADERS.computeIfAbsent(type, k -> { - return new ExtensionLoader<>(type); - }); + ExtensionLoader loader = (ExtensionLoader) EXTENSION_LOADERS.get(type); + if (loader == null) { + EXTENSION_LOADERS.putIfAbsent(type, new ExtensionLoader(type)); + loader = (ExtensionLoader) EXTENSION_LOADERS.get(type); + } return loader; } @@ -294,9 +296,11 @@ public T getLoadedExtension(String name) { if (StringUtils.isEmpty(name)) { throw new IllegalArgumentException("Extension name == null"); } - Holder holder = cachedInstances.computeIfAbsent(name, k -> { - return new Holder<>(); - }); + Holder holder = cachedInstances.get(name); + if (holder == null) { + cachedInstances.putIfAbsent(name, new Holder()); + holder = cachedInstances.get(name); + } return (T) holder.get(); } @@ -327,9 +331,11 @@ public T getExtension(String name) { if ("true".equals(name)) { return getDefaultExtension(); } - Holder holder = cachedInstances.computeIfAbsent(name, k -> { - return new Holder<>(); - }); + Holder holder = cachedInstances.get(name); + if (holder == null) { + cachedInstances.putIfAbsent(name, new Holder()); + holder = cachedInstances.get(name); + } Object instance = holder.get(); if (instance == null) { synchronized (holder) { diff --git a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/DubboMonitorTest.java b/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/DubboMonitorTest.java index 38213f17021..1a944710505 100644 --- a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/DubboMonitorTest.java +++ b/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/DubboMonitorTest.java @@ -106,19 +106,19 @@ public void testCount() throws Exception { while (lastStatistics == null) { Thread.sleep(10); } - Assertions.assertEquals(lastStatistics.getParameter(MonitorService.APPLICATION), "morgan"); - Assertions.assertEquals(lastStatistics.getProtocol(), "dubbo"); - Assertions.assertEquals(lastStatistics.getHost(), "10.20.153.10"); - Assertions.assertEquals(lastStatistics.getParameter(MonitorService.APPLICATION), "morgan"); - Assertions.assertEquals(lastStatistics.getParameter(MonitorService.INTERFACE), "MemberService"); - Assertions.assertEquals(lastStatistics.getParameter(MonitorService.METHOD), "findPerson"); - Assertions.assertEquals(lastStatistics.getParameter(MonitorService.CONSUMER), "10.20.153.11"); - Assertions.assertEquals(lastStatistics.getParameter(MonitorService.SUCCESS), "1"); - Assertions.assertEquals(lastStatistics.getParameter(MonitorService.FAILURE), "0"); - Assertions.assertEquals(lastStatistics.getParameter(MonitorService.ELAPSED), "3"); - Assertions.assertEquals(lastStatistics.getParameter(MonitorService.MAX_ELAPSED), "3"); - Assertions.assertEquals(lastStatistics.getParameter(MonitorService.CONCURRENT), "1"); - Assertions.assertEquals(lastStatistics.getParameter(MonitorService.MAX_CONCURRENT), "1"); + Assertions.assertEquals("morgan", lastStatistics.getParameter(MonitorService.APPLICATION)); + Assertions.assertEquals("dubbo", lastStatistics.getProtocol()); + Assertions.assertEquals("10.20.153.10", lastStatistics.getHost()); + Assertions.assertEquals("morgan", lastStatistics.getParameter(MonitorService.APPLICATION)); + Assertions.assertEquals("MemberService", lastStatistics.getParameter(MonitorService.INTERFACE)); + Assertions.assertEquals("findPerson", lastStatistics.getParameter(MonitorService.METHOD)); + Assertions.assertEquals("10.20.153.11", lastStatistics.getParameter(MonitorService.CONSUMER)); + Assertions.assertEquals("1", lastStatistics.getParameter(MonitorService.SUCCESS)); + Assertions.assertEquals("0", lastStatistics.getParameter(MonitorService.FAILURE)); + Assertions.assertEquals("3", lastStatistics.getParameter(MonitorService.ELAPSED)); + Assertions.assertEquals("3", lastStatistics.getParameter(MonitorService.MAX_ELAPSED)); + Assertions.assertEquals("1", lastStatistics.getParameter(MonitorService.CONCURRENT)); + Assertions.assertEquals("1", lastStatistics.getParameter(MonitorService.MAX_CONCURRENT)); monitor.destroy(); }