Code Review Request JDK-8170329 New SSLSocket testing template
Artem Smotrakov
artem.smotrakov at oracle.com
Sat Dec 3 01:53:25 UTC 2016
Please see inline
On 12/02/2016 05:25 PM, Xue-Lei Fan wrote:
>>>
>>>> - Why did you remove Peer and Application interfaces? I think those
>>>> interfaces make SSLSocketTemplate more flexible since it allows
>>>> override
>>>> doServerSide/doClientSide logic if necessary - it doesn't seem to be
>>>> worse. If there is no strong reason to remove those interfaces, I
>>>> would
>>>> prefer to keep them with default static/stateless
>>>> doServerSide/doClientSide versions.
>>> I agree with you that The Peer and Application interfaces are more
>>> flexible. I have no strong reason to remove them. For this update, I
>>> focus more on simple and minimal sub-classes. The Peer and
>>> Application interfaces need some complicated coding (condition,
>>> threading, etc) in sub-classes, so the design does not fall into the
>>> scope. I may prefer to remove them at this update and see what
>>> happens if we moving forward with more test update. We can add them
>>> back or create a more flexible one if we need the flexibility in the
>>> future.
>> We have a lot of JSSE tests which may need to do something else in
>> doServerSide() and doClientSide() methods (that's what I learned from my
>> experience working with JSSE tests). Peer and Application interfaces
>> basically allow to override doServerSide() and doClientSide() methods.
>> Your changes make doServerSide() and doClientSide() methods private, so
>> that test can't add something inside it.
>>
>> If you think those interfaces are helpful, I think it's better to keep
>> Peer and Application interfaces instead of removing/adding them back and
>> forth.
>>
>> Another option may be providing methods which are called in
>> doServerSide() and doClientSide(). Those methods may be overridden by a
>> test if it needs to do extra stuff inside doServerSide() and
>> doClientSide().
>>
>> I am fine with both ways, so it's up to you. But I would like to make it
>> clear what way we want to follow.
>>
>> What do you think?
> You points above are good. When I made the update, I struggled a lot
> about the balance of flexible and simplicity. I was inclined to
> simplicity at last as we can update the template if any new feature is
> required in the future. I'm not sure how much this template can be used,
I suspect that all JSSE tests should be updated to use this template to
avoid intermittent failures which we have been seeing.
> exposing as less methods as possible will give us more flexible to
> make further update. So I made most of the methods private, and
> removed a lot of methods. Let's update the access scope if we really
> need them in the future. A small public footprint is easier to start.
We already started a while ago :) Those methods which you removed were
actually used by other tests which you updated. My point is that we'd
better understand how we want the tests to be organized to avoid
adding/removing stuff back and forth. Again, I believe that lots of
tests should be updated to use this template. I am not suggesting to
predict everything that the tests may need right away. If you think that
Peer and Application interfaces are not good enough, it's fine to me,
but we need to understand what would be a replacement for them
>>>> - Exceptions are printed out in startServer/startClient methods, it
>>>> doesn't look necessary to use suppressed exceptions and initCause()
>>>> method. What was wrong with the code in runTest() method? The code in
>>>> runTest() method looks shorter and cleaner to me.
>>>>
>>> The main issue of runTest() is that it does not throw the original
>>> exception. Exception tacks have more information for debugging. I
>>> want to keep the good side of Brad's previous hardness on this point.
>> It is not clear what's the original exception should be because you have
>> client and server. If you print all exceptions in
>> startServer/startClient (right after they occurred), then you don't hide
>> anything helpful for debugging.
>>
> The exception dump may have more information than the single exception
> track, for example the nested cause stacks.
Can't it be printed out in startServer/startClient accordingly?
> The original exception handling was very simple, and a lot
> improvements were made so that the log is easier for debugging.
>
>> IMO, suppressed exceptions may confuse here (that's just from my
>> experience looking at JSSE test logs). The logic in lines 739-763
>> doesn't make it cleaner what exception was thrown on what side. It does
>> "local.initCause(remote)", but actually "remote" is not a cause of
>> "local". Finally, it does "exception.addSuppressed(startException)"
>> where "startException" can be thrown either on server or client side
>> which actually depends on test logic (an engineer needs to keep it in
>> mind).
>>
>> Would it be better to have in logs something simple like the following?
>>
>> ....
>> This is an unexpected exception on client side:
>> <full stack trace>
>> This is an unexpected exception on server side:
>> <full stack trace>
>> Test failed.
>> ...
>>
>> Doesn't it look simpler?
> The purpose of suppressed exception is fully use of the exception for
> debugging. The above suggestion still lose some exception debugging
> information.
What kind of information is lost if you don't use suppressed exceptions?
"startException" can be printed out right away when it occurs which I
think would be cleaner.
> I dumped the exception message (line 808/818), hopefully it can help a
> little bit if confusing.
I believe this is right place to dump everything out. It just needs to
make sure that it exceptions traces from server/client sides don't mix
up, so may be it's better to add some synchronization on System.out like
it was done in print() method.
>
> It's good suggestion that we'd better to tell which side (the client
> or server side) throws the exception. I will think more about it in
> the next webrev update.
Sure, thank you.
Artem
More information about the security-dev
mailing list