JacORB 3 中对本地对象使用可移植拦截器的实现方式发生了变化,如发行说明中所述:“为本地对象正确实现了可移植拦截器。 ” 似乎这个新实现引起了一些问题;重现问题的最简单方法是从 sas-demo(jacorb 附带的那个)中修改 GssUpServer.java:
public class GssUpServer extends SASDemoPOA {
private ORB orb;
private boolean calledPrintSAS = false; // added
public GssUpServer(ORB orb) {
this.orb = orb;
}
public void printSAS() {
try {
org.omg.PortableInterceptor.Current current = (org.omg.PortableInterceptor.Current) orb
.resolve_initial_references("PICurrent");
org.omg.CORBA.Any anyName = current
.get_slot(org.jacorb.security.sas.SASInitializer.sasPrincipalNamePIC);
if (anyName.type().kind().value() == org.omg.CORBA.TCKind._tk_null) {
System.out.println("Null Name");
} else {
String name = anyName.extract_string();
System.out.println("printSAS for user " + name);
}
// /* added
if (!calledPrintSAS) {
calledPrintSAS = true;
// local call, (JacORB 3.x: throws NPE from SASClientInterceptor)
_this().printSAS();
}
// */
} catch (Exception e) {
e.printStackTrace();
}
}
...
}
GssUpClient.bat 之后的 Stacktrace:
2013-04-11 11:01:24.968 SEVERE unexpected exception during servant_preinvoke org.jacorb.security.sas.SASClientInterceptor.send_request(SASClientInterceptor.java:194)
org.jacorb.orb.portableInterceptor.ClientInterceptorIterator.invoke(ClientInterceptorIterator.java:129)
org.jacorb.orb.portableInterceptor.AbstractInterceptorIterator.iterate(AbstractInterceptorIterator.java:66)
org.jacorb.orb.portableInterceptor.ClientInterceptorIterator.iterate(ClientInterceptorIterator.java:87)
org.jacorb.orb.DefaultClientInterceptorHandler.invokeInterceptors(DefaultClientInterceptorHandler.java:328)
org.jacorb.orb.DefaultClientInterceptorHandler.handle_send_request(DefaultClientInterceptorHandler.java:132)
org.jacorb.orb.Delegate.servant_preinvoke(Delegate.java:2505)
org.omg.CORBA.portable.ObjectImpl._servant_preinvoke(ObjectImpl.java:135)
org.jacorb.demo.sas._SASDemoStub.printSAS(_SASDemoStub.java:73)
org.jacorb.demo.sas.GssUpServer.printSAS(GssUpServer.java:46)
org.jacorb.demo.sas.SASDemoPOA._invoke(SASDemoPOA.java:47)
org.jacorb.poa.RequestProcessor.invokeOperation(RequestProcessor.java:348)
org.jacorb.poa.RequestProcessor.process(RequestProcessor.java:670)
org.jacorb.poa.RequestProcessor.run(RequestProcessor.java:820)
java.lang.NullPointerException
at org.jacorb.security.sas.SASClientInterceptor.send_request(SASClientInterceptor.java:194)
at org.jacorb.orb.portableInterceptor.ClientInterceptorIterator.invoke(ClientInterceptorIterator.java:129)
at org.jacorb.orb.portableInterceptor.AbstractInterceptorIterator.iterate(AbstractInterceptorIterator.java:66)
at org.jacorb.orb.portableInterceptor.ClientInterceptorIterator.iterate(ClientInterceptorIterator.java:87)
at org.jacorb.orb.DefaultClientInterceptorHandler.invokeInterceptors(DefaultClientInterceptorHandler.java:328)
at org.jacorb.orb.DefaultClientInterceptorHandler.handle_send_request(DefaultClientInterceptorHandler.java:132)
at org.jacorb.orb.Delegate.servant_preinvoke(Delegate.java:2505)
at org.omg.CORBA.portable.ObjectImpl._servant_preinvoke(ObjectImpl.java:135)
at org.jacorb.demo.sas._SASDemoStub.printSAS(_SASDemoStub.java:73)
at org.jacorb.demo.sas.GssUpServer.printSAS(GssUpServer.java:46)
at org.jacorb.demo.sas.SASDemoPOA._invoke(SASDemoPOA.java:47)
at org.jacorb.poa.RequestProcessor.invokeOperation(RequestProcessor.java:348)
at org.jacorb.poa.RequestProcessor.process(RequestProcessor.java:670)
at org.jacorb.poa.RequestProcessor.run(RequestProcessor.java:820)
上面的代码在 JacORB 2.3.1 中运行良好。解决此问题的简单方法是将属性设置jacorb.isLocalHistoricalInterceptors
为 true;但是,某些“内置”方法(例如_is_a()
)不尊重此标志(因为这些方法直接使用 来检查对象位置is_really_local()
)。在本地进行调用时,这些“内置”方法调用似乎从未使用过拦截器。
所以我的观察是:
- JacORB 3.x 似乎破坏了一些本地调用的便携式拦截器(准确地说,需要连接对象的拦截器......)
- JacORB 3.x 似乎是第一个使用便携式拦截器进行本地调用的
_is_a()
JacORB_non_existent()
_interface()
_get_component()
第一个问题是可以解决的,因为有一个属性使 JacORB 3.x 可以像旧版本一样工作。第二个(结合第一个)似乎真的很麻烦。
有没有其他人注意到这种行为,并且可以验证我的怀疑这确实是 JacORB 3.x 中的缺陷,或者我错过了什么?