Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some optimize on ExtensionLoader #3307

Merged
merged 5 commits into from
Jan 26, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix compile error
lixiaojiee committed Jan 24, 2019
commit 6d2204bacb65e0ecd88d152d03576635c648a454
Original file line number Diff line number Diff line change
@@ -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(";");
Original file line number Diff line number Diff line change
@@ -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());
}

}
}
Original file line number Diff line number Diff line change
@@ -147,17 +147,17 @@ 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 {
ExtensionLoader.getExtensionLoader(NoAdaptiveMethodExt.class).getAdaptiveExtension();
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());
}
}
}