[
https://issues.apache.org/jira/browse/VALIDATOR-341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14581542#comment-14581542
]
Ayoma Wijethunga commented on VALIDATOR-341:
--------------------------------------------
Thank you for your comments and suggestions.
My initial idea was that custom TLD list should be somewhat dynamic (supporting
both addition and removal of entries). With that in mind it was simpler to use
a List instead of array.
However, I understand your point regarding memory consumption and I see that
users will not frequently add/remove entries from this list. As you suggested
user could reset the array by passing an empty array and also we could provide
another method just to clear the entire array. I will change the implementation
to use arrays and upload a new patch for review.
Secondly, why I added null check in the binarySearch for list was to minimize
the overhead for users who do not add additional entries to the List.
Therefore, binarySearch on the customer TLD lists will be performed only and
only if user has added custom TLDs. However, the first line of
Arrays.binarySearch(...) is as follows :
int low = fromIndex;
int high = toIndex - 1;
while (low <= high) {...}
Therefore, even if we initialize the array first and pass an empty array into
the binarySearch(...) method, method will return after above three operations.
However, my thought is that it is better to keep null check (or introduce a
length check) before calling the binarySearch(...) to reduce any additional
overhead. Please further comment on this if possible.
Finally, while revising the patch, I notice that due to synchronization
enforced on methods, only one thread could perform binarySearch(...) on custom
TLD List at a time. Hence, in order to maintain thread-safety and performance,
I will add the "clone the array locally, sort it, then update the static
pointer" approach you suggested earlier with the next patch.
> Make TLD list configurable
> --------------------------
>
> Key: VALIDATOR-341
> URL: https://issues.apache.org/jira/browse/VALIDATOR-341
> Project: Commons Validator
> Issue Type: New Feature
> Components: Framework
> Reporter: Benedikt Ritter
> Labels: TLD, domains, email
> Attachments: RequestForComments.patch
>
>
> Since the list of valid TLDs changes from time to time, it makes sense to let
> users configure the list of valid TLDs.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)