ruanwenjun commented on code in PR #835: URL: https://github.com/apache/incubator-eventmesh/pull/835#discussion_r851971579
########## eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/ConfigurationContextUtil.java: ########## @@ -0,0 +1,74 @@ +/* + * 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 org.apache.eventmesh.common.utils; + +import org.apache.eventmesh.common.config.CommonConfiguration; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +/** + * ConfigurationContextUtil. + */ +public class ConfigurationContextUtil { + + private static final ConcurrentHashMap<String, CommonConfiguration> CONFIGURATION_MAP = new ConcurrentHashMap<>(); + + public static final String HTTP = "http"; + + public static final String TCP = "tcp"; + public static final String GRPC = "grpc"; + + public static final List<String> KEYS = new ArrayList<String>() { + { + add(HTTP); + add(TCP); + add(GRPC); + } + }; + + + /** + * Save http, tcp, grpc configuration at startup for global use. Review Comment: Since you use `putIfAbsent` here, you need to add comment to announce that this method will not overwrite the value, or you can change the `add` to `putIfAbsent`. ########## eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/ConfigurationContextUtil.java: ########## @@ -0,0 +1,74 @@ +/* + * 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 org.apache.eventmesh.common.utils; + +import org.apache.eventmesh.common.config.CommonConfiguration; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +/** + * ConfigurationContextUtil. + */ +public class ConfigurationContextUtil { + + private static final ConcurrentHashMap<String, CommonConfiguration> CONFIGURATION_MAP = new ConcurrentHashMap<>(); + + public static final String HTTP = "http"; + + public static final String TCP = "tcp"; + public static final String GRPC = "grpc"; + + public static final List<String> KEYS = new ArrayList<String>() { + { + add(HTTP); + add(TCP); + add(GRPC); + } + }; Review Comment: Use this way will generate an extra child class of ArrayList, this is not a good practice. ```suggestion public static final List<String> KEYS = Lists.newArrayList(HTTP, TCP, GRPC); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
