Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dubbo 2926] standardize semantics of all mergers,enhance mergeFactory and testcases #2936

Merged
merged 1 commit into from
Dec 12, 2018

Conversation

luchy0120
Copy link
Contributor

@luchy0120 luchy0120 commented Dec 11, 2018

What is the purpose of the change

This patch can standardize semantics of all mergers : merge arguments can be null , and all the others should have same type .

For ArrayMerger , as its argument type is Object[]... items , so we can avoid checking whether item[i] is
an Array . Also , in order to avoid problems like

        class Person{};
        class Teacher extends Person{};
        Person[] a= {new Person()};
        Teacher[] b= {new Teacher()};
        Object[] result = ArrayMerger.INSTANCE.merge(a,b);

we can require all elements to have the same type , al least the user should pass in the same type

For MergerFactory , if the required class is not in cache , we can throw an user friendly Exception

For test case , I add some exception case , and fix an ArrayMerger case , also add some null argument
test case .

Brief changelog

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/merger/*
dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/merger/ResultMergerTest

Verifying this change

mvn clean install -DskipTests

@luchy0120 luchy0120 changed the title standardize semantics of all mergers,enhance mergeFactory and testcases [Dubbo 2926] standardize semantics of all mergers,enhance mergeFactory and testcases Dec 11, 2018
@codecov-io
Copy link

codecov-io commented Dec 11, 2018

Codecov Report

Merging #2936 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2936      +/-   ##
==========================================
+ Coverage   63.92%   63.96%   +0.03%     
==========================================
  Files         584      584              
  Lines       26005    26051      +46     
  Branches     4543     4564      +21     
==========================================
+ Hits        16624    16663      +39     
- Misses       7195     7213      +18     
+ Partials     2186     2175      -11
Impacted Files Coverage Δ
...rg/apache/dubbo/rpc/cluster/merger/ListMerger.java 100% <100%> (+16.66%) ⬆️
...che/dubbo/rpc/cluster/merger/ShortArrayMerger.java 100% <100%> (ø) ⬆️
...g/apache/dubbo/rpc/cluster/merger/ArrayMerger.java 100% <100%> (+31.57%) ⬆️
...ache/dubbo/rpc/cluster/merger/LongArrayMerger.java 100% <100%> (ø) ⬆️
...ache/dubbo/rpc/cluster/merger/ByteArrayMerger.java 100% <100%> (ø) ⬆️
...org/apache/dubbo/rpc/cluster/merger/SetMerger.java 100% <100%> (+16.66%) ⬆️
...he/dubbo/rpc/cluster/merger/DoubleArrayMerger.java 100% <100%> (ø) ⬆️
...che/dubbo/rpc/cluster/merger/FloatArrayMerger.java 100% <100%> (ø) ⬆️
...pache/dubbo/rpc/cluster/merger/IntArrayMerger.java 100% <100%> (ø) ⬆️
...e/dubbo/rpc/cluster/merger/BooleanArrayMerger.java 100% <100%> (ø) ⬆️
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9d4b6cb...9761fbc. Read the comment docs.

@luchy0120
Copy link
Contributor Author

#2926

@beiwei30
Copy link
Member

nice suggestion, I will take a look.

Copy link
Member

@beiwei30 beiwei30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I leave comments for some trivial enhancement, pls. take a look.

@beiwei30
Copy link
Member

@luchy0120 could you pls. take a look?

for (Object[] array : items) {
if (array != null) {
for (int j = 0; j < array.length; j++) {
Array.set(result, index++, array[j]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array[index++] =result?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not wrong . It means "result[index++] = array[j]"

}

int i = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why check this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because if the user pass in ( null ,null , new String[]{"abs","edf"} , null ) , we need to find out the String.class , so we need to skip the null objects .

@luchy0120
Copy link
Contributor Author

@beiwei30, @kimmking, I've updated code accroding to your review . I add some comments for mergeFactory and remove the unnecessary check

@beiwei30
Copy link
Member

I think it's ready to go.

@beiwei30 beiwei30 merged commit 61eff59 into apache:master Dec 12, 2018
@luchy0120 luchy0120 deleted the patch branch December 13, 2018 07:46
khanimteyaz pushed a commit to khanimteyaz/incubator-dubbo that referenced this pull request Dec 17, 2018
beiwei30 pushed a commit that referenced this pull request Dec 17, 2018
* added dubbo-rpc-api filter documentation for issue no #2935

* wrong @see java.io.File was added, removed this version of checkins

* Close all ports after tests finish (#2906)

* fix testCustomExecutor (#2904)

* Graceful shutdown enhancement in Spring (#2901)

* Simplify the code logic of the method AbstractClusterInvoker#reselect. (#2826)

* Simplify the code logic of the method AbstractClusterInvoker#reselect.

* Minor modification for code style.

* create AbstractRouter (#2909)

* create AbstractRouter

* router default method

* router default method

* router default method

* mockinvoker

* Added javadoc for dubbo-filter module dubbo github issue 2884 (#2921)

* Enhance unit test (#2920)

* Change Readme dubbo-sample hyperlink (#2927)

* Simply TagRouter (#2924)

* make telnet config work again (#2925)

* Remove the log to putRandomPort when one protocol use random port (#2931)

* optimize findConfigedPorts method of ServiceConfig to log only one time when userandom port

* move the log to method putRandomPort

* Fix DubboShutdownHook Memory Leak (#2922)

* Improve UT grammar and remove unnecessary braces. (#2930)

* Improve UT grammer, fix compiler warnings.

* Remove unnecessary braces.

* re-enable testCustomExecutor  (#2917)

* fix testCustomExecutor

* fix ci

* Fixing test-order dependency for FstObjectInputTest (#2815)

* re-enable testCustomExecutor (#2913)

* Resetting ExtensionLoader to remove test order dependencies in StickyTest (#2807)

* optimize the RondRobinLoadBalance and MockClusterInvoker (#2932)

delete unused logic and take the logger out.

* [Dubbo-2864] Fix build failed with -Prelease (#2923)

fixes #2864

* Fix telnet can not find method with enum type (#2803)

* [dubbo-2766] fix the bug of isMatch method of InvokeTelnetHandler (#2787)

* enhance org.apache.dubbo.rpc.protocol.dubbo.telnet.InvokeTelnetHandler#isMatch (#2941)

* enhance isMatch

* remove useless imports

* [Dubbo-2766]Fix 2766 and enhance the invoke command (#2801)

* add getter and setter for ServiceConfig's interfaceName property#2353

* add interfaceName to ignoreAttributeNames and change the unit test

* delete the demo source code and update the unit test

* unchange ServiceConfig

* update unit test

* update unit test

* fix #2798 and enhance invoke command

* Delete useless assignments (#2939)

* Replace anonymous class with method reference (#2929)

* Replace anonymous class with method reference

* Revert changes as per @beiwei30 code review

* Optimize retry for FailbackRegistry. (#2763)

* Abstract retry task

* Task for retry.

* Fix sth.

* Finish Optimize. fix ci failed.

* Optimize retry for FailbackRegistry.
The retry operation splits into specific operations, such as subscriptions and registrations. This approach allows for very precise retry control.

* Optimize retry for FailbackRegistry.
The retry operation splits into specific operations, such as subscriptions and registrations. This approach allows for very precise retry control.

* Optimize logger warn's msg.

* Optimize FailedNotifiedTask's run method.
Optimize addXXXTask, directly return if we already have a retry task.

* Optimize notify logic, just notify when the urls is not empty.

* Optimize notify logic, just notify when the urls is not empty.

* Optimize timer that use daemon thread.

* standardize semantics of all mergers,enhance mergeFactory and testcase (#2936)

* Modified to lower camel case (#2945)

* Improve several map iteration (#2938)

* added dubbo-rpc-api filter documentation for issue no #2935

* wrong @see java.io.File was added, removed this version of checkins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants