[
https://issues.apache.org/jira/browse/WODEN-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13001570#comment-13001570
]
Ping Liu commented on WODEN-186:
--------------------------------
I did an initial try with the throw-catch-exception I mentioned above but
quickly found several issues:
1. have to modify WSDLComponent interface to add "throws XXXException" for
getFragmentIdentifier(). This is to allow all implementation classes to throw
the exception. This might be okay as I saw getFragmentIdentifier() is only
used by WSDLCompentImpl. But it is not a good practice at the risk of possibly
breaking existing implementation classes.
2. for the complicated case like BindingFaultReferenceImpl, it is not easy to
provide a friendly "meaningful" error description. The error not only can
occur on the spot in BindingFaultReferenceImpl directly but also can go deep to
several parent layers. In the example test case I have, the error goes all the
way to BindingFaultReference's great parent Binding's getInterfaceOperation()
like this
org.apache.woden.internal.wsdl20.BindingImpl.getInterface(BindingImpl.java:93)
org.apache.woden.internal.wsdl20.BindingOperationImpl.getInterfaceOperation(BindingOperationImpl.java:65)
org.apache.woden.internal.wsdl20.BindingFaultReferenceImpl.getFragmentIdentifier(BindingFaultReferenceImpl.java:201)
org.apache.woden.internal.wsdl20.WSDLComponentImpl.toString(WSDLComponentImpl.java:183)
If still go this way with the throw-catch-exception, I guess we should only
check the very basic info (i.e. is null, has no QName) inside
getFragmentIdentifier() for the current implementation class and its parent.
If the current instance or its parent is null or has no QName, then we provide
warning message to indicate the instance or the parent instance is null or has
no QName. And then throw this warning message for the caller
(WSDLComponentImpl). In other word, this is the same steps as what I said in
my previous comment above.
However, beyond the basic info check, we leave whatever exception alone but
throw out the exception stack. In this case, there will be no "meaningful"
error description other than the exception stack itself. The idea is the error
check is hard to and also should not try to check possible exceptions beyond
what are available within current implementation class. As a result, the
warning message will be largely the exception stack instead of what error it is
exactly.
Going beyond, is there any better way for the fix?
> Various problems calling toString() on uninitialized *Impl classes
> ------------------------------------------------------------------
>
> Key: WODEN-186
> URL: https://issues.apache.org/jira/browse/WODEN-186
> Project: Woden
> Issue Type: Bug
> Components: Parser
> Affects Versions: M8
> Reporter: Jeremy Hughes
> Fix For: 1.0
>
> Attachments: TestToStringForComponentAndElement.txt
>
>
> I'm using the Element API to construct a Description from the ground up, with
> some problems in calling toString() on uninitialized *Impl objects.
> WSDLFactory factory = WSDLFactory.newInstance();
> DescriptionElement descElem1 = factory.newDescription();
> ServiceElement svcElem1 = descElem1.addServiceElement();
> assertNotNull(svcElem1.toString());
> gives:
> java.lang.IllegalArgumentException
> at
> org.apache.woden.wsdl20.fragids.ServicePart.<init>(ServicePart.java:40)
> at
> org.apache.woden.internal.wsdl20.ServiceImpl.getFragmentIdentifier(ServiceImpl.java:227)
> at
> org.apache.woden.internal.wsdl20.WSDLComponentImpl.toString(WSDLComponentImpl.java:108)
> ServicePart ctor actually throws a new IllegalArgumentException if passed a
> null so that's WAD. However, ServiceImpl.toString() should be friendlier.
> Then there is a problem with ElementImpl.toString():
> WSDLFactory factory = WSDLFactory.newInstance();
> DescriptionElement descElem1 = factory.newDescription();
> ServiceElement svcElem1 = descElem1.addServiceElement();
> EndpointElement endPtElem1 = svcElem1.addEndpointElement();
> assertNotNull(endPtElem1.toString());
> gives:
> java.lang.NullPointerException
> at
> org.apache.woden.internal.wsdl20.EndpointImpl.getFragmentIdentifier(EndpointImpl.java:140)
> at
> org.apache.woden.internal.wsdl20.WSDLComponentImpl.toString(WSDLComponentImpl.java:108)
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]