Skip to content
This repository has been archived by the owner on Feb 3, 2019. It is now read-only.

Commit

Permalink
Code sync from master. (sofastack#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjboy authored and leizhiyuan committed Jun 29, 2018
1 parent 67a9650 commit 95f752b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ private static <T> T[] array2Array(Object[] src, Class<T> componentType) {
*/
public static <T> T deserializeByType(Object src, Class<T> clazz) {
if (src == null) {
return null;
return (T) ClassUtils.getDefaultPrimitiveValue(clazz);
} else if (src instanceof Boolean) {
return (T) CompatibleTypeUtils.convert(src, clazz);
} else if (src instanceof Number) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,5 @@ public BoltResponseFuture addListener(SofaResponseCallback sofaResponseCallback)

@Override
public void notifyListeners() {
throw new UnsupportedOperationException("Not supported, Please use callback function");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,43 +52,52 @@ public void testAll() {
.setRegister(false);
providerConfig.export();

ConsumerConfig<TestExceptionService> consumerConfig = new ConsumerConfig<TestExceptionService>()
.setInterfaceId(TestExceptionService.class.getName())
.setDirectUrl("bolt://127.0.0.1:22222")
.setTimeout(1000)
.setRegister(false);
final TestExceptionService service = consumerConfig.refer();
for (String proxy : new String[] { "jdk", "javassist" }) {
ConsumerConfig<TestExceptionService> consumerConfig = new ConsumerConfig<TestExceptionService>()
.setInterfaceId(TestExceptionService.class.getName())
.setDirectUrl("bolt://127.0.0.1:22222")
.setTimeout(1000)
.setProxy(proxy)
.setRepeatedReferLimit(-1)
.setRegister(false);
final TestExceptionService service = consumerConfig.refer();

try {
service.throwRuntimeException();
} catch (Throwable e) {
Assert.assertTrue(e instanceof RuntimeException);
Assert.assertEquals(e.getMessage(), "RuntimeException");
}
try {
service.throwException();
} catch (Throwable e) {
Assert.assertTrue(e instanceof Exception);
Assert.assertEquals(e.getMessage(), "Exception");
}
try {
service.throwSofaException();
} catch (Throwable e) {
Assert.assertTrue(e instanceof SofaRpcException);
Assert.assertEquals(e.getMessage(), "SofaRpcException");
}
try {
service.throwDeclaredException();
} catch (Throwable e) {
Assert.assertTrue(e instanceof TestException);
Assert.assertEquals(e.getMessage(), "TestException");
}
try {
service.throwRuntimeException();
Assert.fail();
} catch (Throwable e) {
Assert.assertTrue(e instanceof RuntimeException);
Assert.assertEquals(e.getMessage(), "RuntimeException");
}
try {
service.throwException();
Assert.fail();
} catch (Throwable e) {
Assert.assertTrue(e instanceof Exception);
Assert.assertEquals(e.getMessage(), "Exception");
}
try {
service.throwSofaException();
Assert.fail();
} catch (Throwable e) {
Assert.assertTrue(e instanceof SofaRpcException);
Assert.assertEquals(e.getMessage(), "SofaRpcException");
}
try {
service.throwDeclaredException();
Assert.fail();
} catch (Throwable e) {
Assert.assertTrue(e instanceof TestException);
Assert.assertEquals(e.getMessage(), "TestException");
}

try {
service.throwDeclaredExceptionWithoutReturn();
} catch (Throwable e) {
Assert.assertTrue(e instanceof TestException);
Assert.assertEquals(e.getMessage(), "DeclaredExceptionWithoutReturn");
try {
service.throwDeclaredExceptionWithoutReturn();
Assert.fail();
} catch (Throwable e) {
Assert.assertTrue(e instanceof TestException);
Assert.assertEquals(e.getMessage(), "DeclaredExceptionWithoutReturn");
}
}
}
}

0 comments on commit 95f752b

Please sign in to comment.