[ https://issues.apache.org/jira/browse/SCB-477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16436622#comment-16436622 ]
ASF GitHub Bot commented on SCB-477: ------------------------------------ liubao68 closed pull request #645: [SCB-477] sdk guava's version need to update to 19.0 URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/645 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/foundations/foundation-common/src/main/java/com/google/common/eventbus/SimpleEventBus.java b/foundations/foundation-common/src/main/java/com/google/common/eventbus/SimpleEventBus.java deleted file mode 100644 index 55c370801..000000000 --- a/foundations/foundation-common/src/main/java/com/google/common/eventbus/SimpleEventBus.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.common.eventbus; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx; - -import com.google.common.collect.Multimap; - -/** - * <p>EventBus has performance problem, we create a new simpler eventBus - * - * <p>extend from EventBus is not necessary<br> - * but EventManager has a public EventBus field, we need to make compatible - * - * <p>different between this class and EventBus:<br> - * 1. not support cycle trigger:<br> - * subscribe a, when handle a, trigger event b<br> - * subscribe b, when handle b, trigger event a - */ -public class SimpleEventBus extends com.google.common.eventbus.EventBus { - private AnnotatedSubscriberFinder finder = new AnnotatedSubscriberFinder(); - - // key is event type - // value is CopyOnWriteArrayList - private Map<Class<?>, List<EventSubscriber>> subscribersByType = new ConcurrentHashMapEx<>(); - - @Override - public void register(Object listener) { - Multimap<Class<?>, EventSubscriber> methodsInListener = finder.findAllSubscribers(listener); - - for (Entry<Class<?>, Collection<EventSubscriber>> entry : methodsInListener.asMap().entrySet()) { - List<EventSubscriber> exists = subscribersByType.computeIfAbsent(entry.getKey(), cls -> { - return new CopyOnWriteArrayList<>(); - }); - exists.addAll(entry.getValue()); - } - } - - @Override - public void unregister(Object listener) { - Multimap<Class<?>, EventSubscriber> methodsInListener = finder.findAllSubscribers(listener); - - for (Entry<Class<?>, Collection<EventSubscriber>> entry : methodsInListener.asMap().entrySet()) { - List<EventSubscriber> exists = subscribersByType.get(entry.getKey()); - if (exists == null) { - continue; - } - - exists.removeAll(entry.getValue()); - } - } - - @Override - public void post(Object event) { - Set<Class<?>> dispatchTypes = flattenHierarchy(event.getClass()); - for (Class<?> dispatchType : dispatchTypes) { - List<EventSubscriber> subscribers = subscribersByType.getOrDefault(dispatchType, Collections.emptyList()); - - for (EventSubscriber subscriber : subscribers) { - dispatch(event, subscriber); - } - } - } -} diff --git a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/event/EventManager.java b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/event/EventManager.java index 9672a92dc..cb72a21a4 100644 --- a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/event/EventManager.java +++ b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/event/EventManager.java @@ -18,14 +18,13 @@ package org.apache.servicecomb.foundation.common.event; import com.google.common.eventbus.EventBus; -import com.google.common.eventbus.SimpleEventBus; /** * EventManager for chassis events * */ public class EventManager { - public static EventBus eventBus = new SimpleEventBus(); + public static EventBus eventBus = new EventBus(); public static EventBus getEventBus() { return eventBus; diff --git a/foundations/foundation-common/src/test/java/com/google/common/eventbus/TestSimpleEventBus.java b/foundations/foundation-common/src/test/java/com/google/common/eventbus/TestEventBus.java similarity index 90% rename from foundations/foundation-common/src/test/java/com/google/common/eventbus/TestSimpleEventBus.java rename to foundations/foundation-common/src/test/java/com/google/common/eventbus/TestEventBus.java index 8aef0cb45..8e2231ada 100644 --- a/foundations/foundation-common/src/test/java/com/google/common/eventbus/TestSimpleEventBus.java +++ b/foundations/foundation-common/src/test/java/com/google/common/eventbus/TestEventBus.java @@ -23,8 +23,8 @@ import org.junit.Assert; import org.junit.Test; -public class TestSimpleEventBus { - private SimpleEventBus eventBus = new SimpleEventBus(); +public class TestEventBus { + private EventBus eventBus = new EventBus(); private List<Object> events = new ArrayList<>(); @@ -45,14 +45,8 @@ public void s2(String event) { public void unregister() { Object obj = new SubscriberForTest(); - // unregister not exist obj, should no problem - eventBus.unregister(obj); - eventBus.register(obj); eventBus.unregister(obj); - - // unregister again, should no problem - eventBus.unregister(obj); } @Test diff --git a/java-chassis-dependencies/pom.xml b/java-chassis-dependencies/pom.xml index 95bb502e2..ba53189c5 100644 --- a/java-chassis-dependencies/pom.xml +++ b/java-chassis-dependencies/pom.xml @@ -179,7 +179,7 @@ <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> - <version>16.0.1</version> + <version>19.0</version> </dependency> <dependency> diff --git a/java-chassis-distribution/src/release/LICENSE b/java-chassis-distribution/src/release/LICENSE index 20a18c575..4b11ea9de 100644 --- a/java-chassis-distribution/src/release/LICENSE +++ b/java-chassis-distribution/src/release/LICENSE @@ -345,7 +345,7 @@ ClassMate (http://github.com/cowtowncoder/java-classmate) com.fasterxml:classmat Commons IO (http://commons.apache.org/io/) commons-io:commons-io:jar:2.4 Commons Lang (http://commons.apache.org/lang/) commons-lang:commons-lang:jar:2.6 FindBugs-jsr305 (http://findbugs.sourceforge.net/) com.google.code.findbugs:jsr305:jar:3.0.1 -Guava: Google Core Libraries for Java (http://code.google.com/p/guava-libraries/guava) com.google.guava:guava:bundle:16.0.1 +Guava: Google Core Libraries for Java (http://code.google.com/p/guava-libraries/guava) com.google.guava:guava:bundle:19.0 Hibernate Validator Engine (http://hibernate.org/validator/hibernate-validator) org.hibernate:hibernate-validator:jar:5.2.4.Final JBoss Logging 3 (http://www.jboss.org) org.jboss.logging:jboss-logging:jar:3.3.0.Final Jackson dataformat: CBOR (http://github.com/FasterXML/jackson-dataformats-binary) com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:bundle:2.8.7 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > sdk guava‘s version need to update from 16.0.1 to 19.0 > ------------------------------------------------------ > > Key: SCB-477 > URL: https://issues.apache.org/jira/browse/SCB-477 > Project: Apache ServiceComb > Issue Type: Improvement > Components: Java-Chassis > Reporter: WeiChao > Assignee: WeiChao > Priority: Major > > sdk guava‘s version need to update from 16.0.1 to 19.0 -- This message was sent by Atlassian JIRA (v7.6.3#76005)