diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java index 784195877be..0706053b52f 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveLoadBalance.java @@ -71,7 +71,7 @@ protected Invoker doSelect(List> invokers, URL url, Invocation leastActive = active; // Reset the number of least active invokers leastCount = 1; - // Put the first least active invoker first in leastIndexs + // Put the first least active invoker first in leastIndexes leastIndexes[0] = i; // Reset totalWeight totalWeight = afterWarmup; @@ -81,7 +81,7 @@ protected Invoker doSelect(List> invokers, URL url, Invocation sameWeight = true; // If current invoker's active value equals with leaseActive, then accumulating. } else if (active == leastActive) { - // Record the index of the least active invoker in leastIndexs order + // Record the index of the least active invoker in leastIndexes order leastIndexes[leastCount++] = i; // Accumulate the total weight of the least active invoker totalWeight += afterWarmup; diff --git a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveBalanceTest.java b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveBalanceTest.java index 00b5c14db1b..89dc66be01c 100644 --- a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveBalanceTest.java +++ b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/loadbalance/LeastActiveBalanceTest.java @@ -35,7 +35,7 @@ public void testLeastActiveLoadBalance_select() { Long count = entry.getValue().get(); // System.out.println(count); Assertions.assertTrue( - Math.abs(count - runs / (0f + invokers.size())) < runs / (0f + invokers.size()), "abs diff shoud < avg"); + Math.abs(count - runs / (0f + invokers.size())) < runs / (0f + invokers.size()), "abs diff should < avg"); } } diff --git a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailfastClusterInvokerTest.java b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailfastClusterInvokerTest.java index d8dd653f34e..9b6d2e88b73 100644 --- a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailfastClusterInvokerTest.java +++ b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/FailfastClusterInvokerTest.java @@ -80,7 +80,7 @@ private void resetInvoker1ToNoException() { } @Test - public void testInvokeExceptoin() { + public void testInvokeException() { Assertions.assertThrows(RpcException.class, () -> { resetInvoker1ToException(); FailfastClusterInvoker invoker = new FailfastClusterInvoker(dic); @@ -90,7 +90,7 @@ public void testInvokeExceptoin() { } @Test() - public void testInvokeNoExceptoin() { + public void testInvokeNoException() { resetInvoker1ToNoException(); diff --git a/dubbo-common/pom.xml b/dubbo-common/pom.xml index 29b22b7eada..98ecc9b87b2 100644 --- a/dubbo-common/pom.xml +++ b/dubbo-common/pom.xml @@ -77,9 +77,5 @@ de.ruedigermoeller fst - - com.google.protobuf - protobuf-java-util - \ No newline at end of file diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java index fcce47feaf1..50bf9508359 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/AdaptiveClassCodeGenerator.java @@ -224,7 +224,7 @@ private String generateMethodContent(Method method) { code.append(generateExtensionAssignment()); // return statement - code.append(generateReturnAndInovation(method)); + code.append(generateReturnAndInvocation(method)); } return code.toString(); @@ -292,7 +292,7 @@ private String generateExtensionAssignment() { /** * generate method invocation statement and return it if necessary */ - private String generateReturnAndInovation(Method method) { + private String generateReturnAndInvocation(Method method) { String returnStatement = method.getReturnType().equals(void.class) ? "" : "return "; String args = Arrays.stream(method.getParameters()).map(Parameter::getName).collect(Collectors.joining(", ")); diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ProtobufUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ProtobufUtils.java deleted file mode 100644 index 532cfdeef02..00000000000 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ProtobufUtils.java +++ /dev/null @@ -1,76 +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 org.apache.dubbo.common.utils; - -import java.lang.reflect.Method; - -import com.google.protobuf.GeneratedMessageV3; -import com.google.protobuf.GeneratedMessageV3.Builder; -import com.google.protobuf.MessageOrBuilder; -import com.google.protobuf.util.JsonFormat; -import com.google.protobuf.util.JsonFormat.Parser; -import com.google.protobuf.util.JsonFormat.Printer; - -/** - * 2019/4/4 - */ -public class ProtobufUtils { - - public static boolean isSupported(Class clazz) { - if (clazz == null) { - return false; - } - - if (GeneratedMessageV3.class.isAssignableFrom(clazz)) { - return true; - } - return false; - } - - public static T deserialize(String json, Class requestClass) { - if (!isSupported(requestClass)) { - throw new UnsupportedOperationException(requestClass.getName() + "can not be deserialize"); - } - Builder builder; - try{ - builder = getMessageBuilder(requestClass); - Parser parser = JsonFormat.parser(); - parser.merge(json, builder); - }catch (Exception e){ - throw new RuntimeException("Failed to deserialize "+requestClass,e ); - } - - return (T) builder.build(); - } - - public static String serialize(Object value) { - String result; - try { - Printer printer = JsonFormat.printer(); - result = printer.print((MessageOrBuilder) value); - } catch (Exception e) { - result = e.getMessage(); - } - return result; - } - - private static Builder getMessageBuilder(Class requestType) throws Exception { - Method method = requestType.getMethod("newBuilder"); - - return (Builder) method.invoke(null, null); - } -} diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtilTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtilTest.java index 5c72a14d3d0..4b3654a73d5 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtilTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtilTest.java @@ -441,20 +441,20 @@ static void assertEqualsBigPerson(BigPerson person, Object obj) { assertEqualsPrimitive(person.getInfoProfile().isMale(), infoProfile.getProperty("male")); } - static void assertEqualsPhone(Phone excpected, Object obj) { + static void assertEqualsPhone(Phone expected, Object obj) { JavaBeanDescriptor descriptor = (JavaBeanDescriptor) obj; Assertions.assertTrue(descriptor.isBeanType()); - if (excpected.getArea() != null) { - assertEqualsPrimitive(excpected.getArea(), descriptor.getProperty("area")); + if (expected.getArea() != null) { + assertEqualsPrimitive(expected.getArea(), descriptor.getProperty("area")); } - if (excpected.getCountry() != null) { - assertEqualsPrimitive(excpected.getCountry(), descriptor.getProperty("country")); + if (expected.getCountry() != null) { + assertEqualsPrimitive(expected.getCountry(), descriptor.getProperty("country")); } - if (excpected.getExtensionNumber() != null) { - assertEqualsPrimitive(excpected.getExtensionNumber(), descriptor.getProperty("extensionNumber")); + if (expected.getExtensionNumber() != null) { + assertEqualsPrimitive(expected.getExtensionNumber(), descriptor.getProperty("extensionNumber")); } - if (excpected.getNumber() != null) { - assertEqualsPrimitive(excpected.getNumber(), descriptor.getProperty("number")); + if (expected.getNumber() != null) { + assertEqualsPrimitive(expected.getNumber(), descriptor.getProperty("number")); } } diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractConfigTest.java index 2d40cc369fd..10cac653e99 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractConfigTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractConfigTest.java @@ -306,7 +306,7 @@ public void testRefreshAll() { System.setProperty("dubbo.override.address", "system://127.0.0.1:2181"); System.setProperty("dubbo.override.protocol", "system"); - // this will not override, use 'key' instread, @Parameter(key="key1", useKeyAsProperty=false) + // this will not override, use 'key' instead, @Parameter(key="key1", useKeyAsProperty=false) System.setProperty("dubbo.override.key1", "system"); System.setProperty("dubbo.override.key2", "system"); diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-api/pom.xml b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-api/pom.xml deleted file mode 100644 index df752e33cc6..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-api/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - dubbo-demo-protobuf - org.apache.dubbo - 2.7.2-SNAPSHOT - - 4.0.0 - - dubbo-demo-protobuf-api - \ No newline at end of file diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-api/src/main/java/org/apache/dubbo/demo/protobuf/api/GooglePb.java b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-api/src/main/java/org/apache/dubbo/demo/protobuf/api/GooglePb.java deleted file mode 100644 index 6f475d515b1..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-api/src/main/java/org/apache/dubbo/demo/protobuf/api/GooglePb.java +++ /dev/null @@ -1,1132 +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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: GooglePb.proto - -package org.apache.dubbo.demo.protobuf.api; - -public final class GooglePb { - private GooglePb() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - public interface GooglePBRequestTypeOrBuilder extends - // @@protoc_insertion_point(interface_extends:org.apache.dubbo.demo.protobuf.api.GooglePBRequestType) - com.google.protobuf.MessageOrBuilder { - - /** - * string req = 1; - */ - String getReq(); - /** - * string req = 1; - */ - com.google.protobuf.ByteString - getReqBytes(); - } - /** - * Protobuf type {@code org.apache.dubbo.demo.protobuf.api.GooglePBRequestType} - */ - public static final class GooglePBRequestType extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:org.apache.dubbo.demo.protobuf.api.GooglePBRequestType) - GooglePBRequestTypeOrBuilder { - private static final long serialVersionUID = 0L; - // Use GooglePBRequestType.newBuilder() to construct. - private GooglePBRequestType(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private GooglePBRequestType() { - req_ = ""; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private GooglePBRequestType( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - req_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBRequestType_descriptor; - } - - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBRequestType_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType.class, org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType.Builder.class); - } - - public static final int REQ_FIELD_NUMBER = 1; - private volatile Object req_; - /** - * string req = 1; - */ - public String getReq() { - Object ref = req_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - req_ = s; - return s; - } - } - /** - * string req = 1; - */ - public com.google.protobuf.ByteString - getReqBytes() { - Object ref = req_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - req_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getReqBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, req_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getReqBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, req_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType)) { - return super.equals(obj); - } - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType other = (org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType) obj; - - boolean result = true; - result = result && getReq() - .equals(other.getReq()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + REQ_FIELD_NUMBER; - hash = (53 * hash) + getReq().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code org.apache.dubbo.demo.protobuf.api.GooglePBRequestType} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:org.apache.dubbo.demo.protobuf.api.GooglePBRequestType) - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestTypeOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBRequestType_descriptor; - } - - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBRequestType_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType.class, org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType.Builder.class); - } - - // Construct using org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - req_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBRequestType_descriptor; - } - - public org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType getDefaultInstanceForType() { - return getDefaultInstance(); - } - - public org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType build() { - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType buildPartial() { - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType result = new org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType(this); - result.req_ = req_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType) { - return mergeFrom((org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType other) { - if (other == getDefaultInstance()) return this; - if (!other.getReq().isEmpty()) { - req_ = other.req_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private Object req_ = ""; - /** - * string req = 1; - */ - public String getReq() { - Object ref = req_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - req_ = s; - return s; - } else { - return (String) ref; - } - } - /** - * string req = 1; - */ - public com.google.protobuf.ByteString - getReqBytes() { - Object ref = req_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - req_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string req = 1; - */ - public Builder setReq( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - req_ = value; - onChanged(); - return this; - } - /** - * string req = 1; - */ - public Builder clearReq() { - - req_ = getDefaultInstance().getReq(); - onChanged(); - return this; - } - /** - * string req = 1; - */ - public Builder setReqBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - req_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:org.apache.dubbo.demo.protobuf.api.GooglePBRequestType) - } - - // @@protoc_insertion_point(class_scope:org.apache.dubbo.demo.protobuf.api.GooglePBRequestType) - private static final org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType(); - } - - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public GooglePBRequestType parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new GooglePBRequestType(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface GooglePBResponseTypeOrBuilder extends - // @@protoc_insertion_point(interface_extends:org.apache.dubbo.demo.protobuf.api.GooglePBResponseType) - com.google.protobuf.MessageOrBuilder { - - /** - * string response = 1; - */ - String getResponse(); - /** - * string response = 1; - */ - com.google.protobuf.ByteString - getResponseBytes(); - } - /** - * Protobuf type {@code org.apache.dubbo.demo.protobuf.api.GooglePBResponseType} - */ - public static final class GooglePBResponseType extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:org.apache.dubbo.demo.protobuf.api.GooglePBResponseType) - GooglePBResponseTypeOrBuilder { - private static final long serialVersionUID = 0L; - // Use GooglePBResponseType.newBuilder() to construct. - private GooglePBResponseType(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private GooglePBResponseType() { - response_ = ""; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private GooglePBResponseType( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - response_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBResponseType_descriptor; - } - - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBResponseType_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType.class, org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType.Builder.class); - } - - public static final int RESPONSE_FIELD_NUMBER = 1; - private volatile Object response_; - /** - * string response = 1; - */ - public String getResponse() { - Object ref = response_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - response_ = s; - return s; - } - } - /** - * string response = 1; - */ - public com.google.protobuf.ByteString - getResponseBytes() { - Object ref = response_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - response_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getResponseBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, response_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getResponseBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, response_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType)) { - return super.equals(obj); - } - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType other = (org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType) obj; - - boolean result = true; - result = result && getResponse() - .equals(other.getResponse()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + RESPONSE_FIELD_NUMBER; - hash = (53 * hash) + getResponse().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType( - BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code org.apache.dubbo.demo.protobuf.api.GooglePBResponseType} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:org.apache.dubbo.demo.protobuf.api.GooglePBResponseType) - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseTypeOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBResponseType_descriptor; - } - - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBResponseType_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType.class, org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType.Builder.class); - } - - // Construct using org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - response_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBResponseType_descriptor; - } - - public org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType getDefaultInstanceForType() { - return getDefaultInstance(); - } - - public org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType build() { - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType buildPartial() { - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType result = new org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType(this); - result.response_ = response_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType) { - return mergeFrom((org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType other) { - if (other == getDefaultInstance()) return this; - if (!other.getResponse().isEmpty()) { - response_ = other.response_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private Object response_ = ""; - /** - * string response = 1; - */ - public String getResponse() { - Object ref = response_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - response_ = s; - return s; - } else { - return (String) ref; - } - } - /** - * string response = 1; - */ - public com.google.protobuf.ByteString - getResponseBytes() { - Object ref = response_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - response_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string response = 1; - */ - public Builder setResponse( - String value) { - if (value == null) { - throw new NullPointerException(); - } - - response_ = value; - onChanged(); - return this; - } - /** - * string response = 1; - */ - public Builder clearResponse() { - - response_ = getDefaultInstance().getResponse(); - onChanged(); - return this; - } - /** - * string response = 1; - */ - public Builder setResponseBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - response_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:org.apache.dubbo.demo.protobuf.api.GooglePBResponseType) - } - - // @@protoc_insertion_point(class_scope:org.apache.dubbo.demo.protobuf.api.GooglePBResponseType) - private static final org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType(); - } - - public static org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public GooglePBResponseType parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new GooglePBResponseType(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBRequestType_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBRequestType_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBResponseType_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBResponseType_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - String[] descriptorData = { - "\n\016GooglePb.proto\022\"org.apache.dubbo.demo." + - "protobuf.api\"\"\n\023GooglePBRequestType\022\013\n\003r" + - "eq\030\001 \001(\t\"(\n\024GooglePBResponseType\022\020\n\010resp" + - "onse\030\001 \001(\t2\226\001\n\025CDubboGooglePBService\022}\n\010" + - "sayHello\0227.org.apache.dubbo.demo.protobu" + - "f.api.GooglePBRequestType\0328.org.apache.d" + - "ubbo.demo.protobuf.api.GooglePBResponseT" + - "ypeb\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBRequestType_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBRequestType_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBRequestType_descriptor, - new String[] { "Req", }); - internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBResponseType_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBResponseType_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_org_apache_dubbo_demo_protobuf_api_GooglePBResponseType_descriptor, - new String[] { "Response", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-api/src/main/java/org/apache/dubbo/demo/protobuf/api/ProtobufDemoService.java b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-api/src/main/java/org/apache/dubbo/demo/protobuf/api/ProtobufDemoService.java deleted file mode 100644 index 65786356ae7..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-api/src/main/java/org/apache/dubbo/demo/protobuf/api/ProtobufDemoService.java +++ /dev/null @@ -1,26 +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 org.apache.dubbo.demo.protobuf.api; - -import org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType; -import org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType; - -public interface ProtobufDemoService { - - GooglePBResponseType sayHello(GooglePBRequestType request); - -} \ No newline at end of file diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-api/src/main/resources/protobuf/GooglePb.proto b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-api/src/main/resources/protobuf/GooglePb.proto deleted file mode 100644 index a899f950b5b..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-api/src/main/resources/protobuf/GooglePb.proto +++ /dev/null @@ -1,31 +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. - */ -syntax = "proto3"; -package org.apache.dubbo.demo.protobuf.api; - -message GooglePBRequestType { - string req = 1; -} - - -message GooglePBResponseType { - string response =1; -} - -service CDubboGooglePBService { - rpc sayHello (GooglePBRequestType) returns (GooglePBResponseType); -} diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/pom.xml b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/pom.xml deleted file mode 100644 index d6cce10cc63..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - dubbo-demo-protobuf - org.apache.dubbo - 2.7.2-SNAPSHOT - - 4.0.0 - - dubbo-demo-protobuf-consumer - - - - org.apache.dubbo - dubbo-demo-protobuf-api - ${project.version} - - - org.apache.dubbo - dubbo-demo-interface - ${project.parent.version} - - - org.apache.dubbo - dubbo-config-spring - - - org.apache.dubbo - dubbo-registry-zookeeper - - - org.apache.dubbo - dubbo-registry-multicast - - - org.apache.dubbo - dubbo-rpc-dubbo - - - org.apache.dubbo - dubbo-remoting-netty4 - - - org.apache.dubbo - dubbo-serialization-hessian2 - - - org.apache.dubbo - dubbo-configcenter-zookeeper - - - org.apache.dubbo - dubbo-metadata-report-redis - - - org.apache.dubbo - dubbo-metadata-report-zookeeper - - - - \ No newline at end of file diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/src/main/java/org/apache/dubbo/demo/protobuf/consumer/Application.java b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/src/main/java/org/apache/dubbo/demo/protobuf/consumer/Application.java deleted file mode 100644 index a1d5a8a83b9..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/src/main/java/org/apache/dubbo/demo/protobuf/consumer/Application.java +++ /dev/null @@ -1,42 +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 org.apache.dubbo.demo.protobuf.consumer; - - -import org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType; -import org.apache.dubbo.rpc.service.GenericService; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class Application { - /** - * In order to make sure multicast registry works, need to specify '-Djava.net.preferIPv4Stack=true' before - * launch the application - */ - public static void main(String[] args) { - ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml"); - context.start(); - GenericService genericService = context.getBean("demoService", GenericService.class); - String methodName = "sayHello"; - String[] requestType = new String[]{GooglePBRequestType.class.getName()}; - - // TODO this requestStr could generate from serviceMetaData. a new TypeDefinition is create will push next - String requestStr = "{ \"req\": \"some Message\" }"; - Object[] request = new Object[]{requestStr}; - String hello = (String) genericService.$invoke(methodName,requestType,request); - System.out.println("result: " + hello); - } -} diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/src/main/resources/dubbo.properties b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/src/main/resources/dubbo.properties deleted file mode 100644 index 8c3cb2559c7..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/src/main/resources/dubbo.properties +++ /dev/null @@ -1 +0,0 @@ -dubbo.application.qos.port=33333 diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/src/main/resources/log4j.properties b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/src/main/resources/log4j.properties deleted file mode 100644 index 24243814906..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/src/main/resources/log4j.properties +++ /dev/null @@ -1,7 +0,0 @@ -###set log levels### -log4j.rootLogger=info, stdout -###output to console### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n \ No newline at end of file diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/src/main/resources/spring/dubbo-consumer.xml b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/src/main/resources/spring/dubbo-consumer.xml deleted file mode 100644 index 4f07a39f13e..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-consumer/src/main/resources/spring/dubbo-consumer.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/pom.xml b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/pom.xml deleted file mode 100644 index 8cc856f8b87..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - dubbo-demo-protobuf - org.apache.dubbo - 2.7.2-SNAPSHOT - - 4.0.0 - - dubbo-demo-protobuf-provider - - - - org.apache.dubbo - dubbo-demo-protobuf-api - ${project.version} - - - org.apache.dubbo - dubbo-demo-interface - ${project.parent.version} - - - org.apache.dubbo - dubbo-config-spring - - - org.apache.dubbo - dubbo-registry-zookeeper - - - org.apache.dubbo - dubbo-registry-multicast - - - org.apache.dubbo - dubbo-rpc-dubbo - - - org.apache.dubbo - dubbo-remoting-netty4 - - - org.apache.dubbo - dubbo-serialization-hessian2 - - - org.apache.dubbo - dubbo-configcenter-zookeeper - - - org.apache.dubbo - dubbo-metadata-report-zookeeper - - - org.apache.dubbo - dubbo-metadata-report-redis - - - org.apache.dubbo - dubbo-qos - - - - \ No newline at end of file diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/java/org/apache/dubbo/demo/protobuf/provider/Application.java b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/java/org/apache/dubbo/demo/protobuf/provider/Application.java deleted file mode 100644 index b6b10d2dd97..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/java/org/apache/dubbo/demo/protobuf/provider/Application.java +++ /dev/null @@ -1,31 +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 org.apache.dubbo.demo.protobuf.provider; - -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class Application { - /** - * In order to make sure multicast registry works, need to specify '-Djava.net.preferIPv4Stack=true' before - * launch the application - */ - public static void main(String[] args) throws Exception { - ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-provider.xml"); - context.start(); - System.in.read(); - } -} \ No newline at end of file diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/java/org/apache/dubbo/demo/protobuf/provider/ProtobufDemoServiceImpl.java b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/java/org/apache/dubbo/demo/protobuf/provider/ProtobufDemoServiceImpl.java deleted file mode 100644 index eff8db1f3b6..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/java/org/apache/dubbo/demo/protobuf/provider/ProtobufDemoServiceImpl.java +++ /dev/null @@ -1,32 +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 org.apache.dubbo.demo.protobuf.provider; - -import org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBRequestType; -import org.apache.dubbo.demo.protobuf.api.GooglePb.GooglePBResponseType; -import org.apache.dubbo.demo.protobuf.api.ProtobufDemoService; - -/** - * 2019/4/8 - */ -public class ProtobufDemoServiceImpl implements ProtobufDemoService { - @Override - public GooglePBResponseType sayHello(GooglePBRequestType request) { - GooglePBResponseType response = GooglePBResponseType.newBuilder().setResponse("message from server :"+request.getReq()).build(); - return response; - } -} diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/resources/dubbo.properties b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/resources/dubbo.properties deleted file mode 100644 index ad602baa943..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/resources/dubbo.properties +++ /dev/null @@ -1 +0,0 @@ -dubbo.application.qos.port=22222 diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/resources/log4j.properties b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/resources/log4j.properties deleted file mode 100644 index 15a0900f0d2..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/resources/log4j.properties +++ /dev/null @@ -1,7 +0,0 @@ -###set log levels### -log4j.rootLogger=info, stdout -###output to the console### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n \ No newline at end of file diff --git a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/resources/spring/dubbo-provider.xml b/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/resources/spring/dubbo-provider.xml deleted file mode 100644 index c0c20a7ef1a..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/dubbo-demo-protobuf-provider/src/main/resources/spring/dubbo-provider.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/dubbo-demo/dubbo-demo-protobuf/pom.xml b/dubbo-demo/dubbo-demo-protobuf/pom.xml deleted file mode 100644 index 651c651fea1..00000000000 --- a/dubbo-demo/dubbo-demo-protobuf/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - dubbo-demo - org.apache.dubbo - 2.7.2-SNAPSHOT - - 4.0.0 - - dubbo-demo-protobuf - pom - - dubbo-demo-protobuf-api - dubbo-demo-protobuf-consumer - dubbo-demo-protobuf-provider - - - - com.google.protobuf - protobuf-java - - - - \ No newline at end of file diff --git a/dubbo-demo/pom.xml b/dubbo-demo/pom.xml index ffb1f26ad6c..d46e2d99df9 100644 --- a/dubbo-demo/pom.xml +++ b/dubbo-demo/pom.xml @@ -34,7 +34,6 @@ dubbo-demo-xml dubbo-demo-annotation dubbo-demo-api - dubbo-demo-protobuf diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java index 23364d06e4f..8c959ebe8a0 100644 --- a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java +++ b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java @@ -312,20 +312,20 @@ public void testRecover2() throws Exception { @Test public void testNotify() throws Exception { final AtomicReference notified = new AtomicReference(false); - NotifyListener listner1 = urls -> notified.set(Boolean.TRUE); + NotifyListener listener1 = urls -> notified.set(Boolean.TRUE); URL url1 = new URL("dubbo", "192.168.0.1", 2200, parametersConsumer); - abstractRegistry.subscribe(url1, listner1); - NotifyListener listner2 = urls -> notified.set(Boolean.TRUE); + abstractRegistry.subscribe(url1, listener1); + NotifyListener listener2 = urls -> notified.set(Boolean.TRUE); URL url2 = new URL("dubbo", "192.168.0.2", 2201, parametersConsumer); - abstractRegistry.subscribe(url2, listner2); - NotifyListener listner3 = urls -> notified.set(Boolean.TRUE); + abstractRegistry.subscribe(url2, listener2); + NotifyListener listener3 = urls -> notified.set(Boolean.TRUE); URL url3 = new URL("dubbo", "192.168.0.3", 2202, parametersConsumer); - abstractRegistry.subscribe(url3, listner3); + abstractRegistry.subscribe(url3, listener3); List urls = new ArrayList<>(); urls.add(url1); urls.add(url2); urls.add(url3); - abstractRegistry.notify(url1, listner1, urls); + abstractRegistry.notify(url1, listener1, urls); Map>> map = abstractRegistry.getNotified(); MatcherAssert.assertThat(true, Matchers.equalTo(map.containsKey(url1))); MatcherAssert.assertThat(false, Matchers.equalTo(map.containsKey(url2))); @@ -338,15 +338,15 @@ public void testNotify() throws Exception { @Test public void testNotifyList() throws Exception { final AtomicReference notified = new AtomicReference(false); - NotifyListener listner1 = urls -> notified.set(Boolean.TRUE); + NotifyListener listener1 = urls -> notified.set(Boolean.TRUE); URL url1 = new URL("dubbo", "192.168.0.1", 2200, parametersConsumer); - abstractRegistry.subscribe(url1, listner1); - NotifyListener listner2 = urls -> notified.set(Boolean.TRUE); + abstractRegistry.subscribe(url1, listener1); + NotifyListener listener2 = urls -> notified.set(Boolean.TRUE); URL url2 = new URL("dubbo", "192.168.0.2", 2201, parametersConsumer); - abstractRegistry.subscribe(url2, listner2); - NotifyListener listner3 = urls -> notified.set(Boolean.TRUE); + abstractRegistry.subscribe(url2, listener2); + NotifyListener listener3 = urls -> notified.set(Boolean.TRUE); URL url3 = new URL("dubbo", "192.168.0.3", 2202, parametersConsumer); - abstractRegistry.subscribe(url3, listner3); + abstractRegistry.subscribe(url3, listener3); List urls = new ArrayList<>(); urls.add(url1); urls.add(url2); @@ -362,20 +362,20 @@ public void testNotifyList() throws Exception { public void testNotifyIfURLNull() throws Exception { Assertions.assertThrows(IllegalArgumentException.class, () -> { final AtomicReference notified = new AtomicReference(false); - NotifyListener listner1 = urls -> notified.set(Boolean.TRUE); + NotifyListener listener1 = urls -> notified.set(Boolean.TRUE); URL url1 = new URL("dubbo", "192.168.0.1", 2200, parametersConsumer); - abstractRegistry.subscribe(url1, listner1); - NotifyListener listner2 = urls -> notified.set(Boolean.TRUE); + abstractRegistry.subscribe(url1, listener1); + NotifyListener listener2 = urls -> notified.set(Boolean.TRUE); URL url2 = new URL("dubbo", "192.168.0.2", 2201, parametersConsumer); - abstractRegistry.subscribe(url2, listner2); - NotifyListener listner3 = urls -> notified.set(Boolean.TRUE); + abstractRegistry.subscribe(url2, listener2); + NotifyListener listener3 = urls -> notified.set(Boolean.TRUE); URL url3 = new URL("dubbo", "192.168.0.3", 2202, parametersConsumer); - abstractRegistry.subscribe(url3, listner3); + abstractRegistry.subscribe(url3, listener3); List urls = new ArrayList<>(); urls.add(url1); urls.add(url2); urls.add(url3); - abstractRegistry.notify(null, listner1, urls); + abstractRegistry.notify(null, listener1, urls); Assertions.fail("notify url == null"); }); } @@ -384,15 +384,15 @@ public void testNotifyIfURLNull() throws Exception { public void testNotifyIfNotifyNull() { Assertions.assertThrows(IllegalArgumentException.class, () -> { final AtomicReference notified = new AtomicReference(false); - NotifyListener listner1 = urls -> notified.set(Boolean.TRUE); + NotifyListener listener1 = urls -> notified.set(Boolean.TRUE); URL url1 = new URL("dubbo", "192.168.0.1", 2200, parametersConsumer); - abstractRegistry.subscribe(url1, listner1); - NotifyListener listner2 = urls -> notified.set(Boolean.TRUE); + abstractRegistry.subscribe(url1, listener1); + NotifyListener listener2 = urls -> notified.set(Boolean.TRUE); URL url2 = new URL("dubbo", "192.168.0.2", 2201, parametersConsumer); - abstractRegistry.subscribe(url2, listner2); - NotifyListener listner3 = urls -> notified.set(Boolean.TRUE); + abstractRegistry.subscribe(url2, listener2); + NotifyListener listener3 = urls -> notified.set(Boolean.TRUE); URL url3 = new URL("dubbo", "192.168.0.3", 2202, parametersConsumer); - abstractRegistry.subscribe(url3, listner3); + abstractRegistry.subscribe(url3, listener3); List urls = new ArrayList<>(); urls.add(url1); urls.add(url2); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractClient.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractClient.java index 2afdc4d0f02..dd02651e018 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractClient.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractClient.java @@ -192,7 +192,7 @@ protected void connect() throws RemotingException { } else { if (logger.isInfoEnabled()) { - logger.info("Successed connect to server " + getRemoteAddress() + " from " + getClass().getSimpleName() + " " + logger.info("Succeed connect to server " + getRemoteAddress() + " from " + getClass().getSimpleName() + " " + NetUtils.getLocalHost() + " using dubbo version " + Version.getVersion() + ", channel is " + this.getChannel()); } diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/support/AbstractEtcdClient.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/support/AbstractEtcdClient.java index bf639ab3c93..0a6d26f90e9 100644 --- a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/support/AbstractEtcdClient.java +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/support/AbstractEtcdClient.java @@ -58,7 +58,7 @@ public abstract class AbstractEtcdClient implements EtcdClient private final Set stateListeners = new ConcurrentHashSet<>(); private final ConcurrentMap> childListeners = new ConcurrentHashMap<>(); - private final List categroies = Arrays.asList(Constants.PROVIDERS_CATEGORY + private final List categories = Arrays.asList(Constants.PROVIDERS_CATEGORY , Constants.CONSUMERS_CATEGORY , Constants.ROUTERS_CATEGORY , Constants.CONFIGURATORS_CATEGORY); @@ -158,11 +158,11 @@ protected void createParentIfAbsent(String fixedPath) { int i = fixedPath.lastIndexOf('/'); if (i > 0) { String parentPath = fixedPath.substring(0, i); - if (categroies.stream().anyMatch(c -> fixedPath.endsWith(c))) { + if (categories.stream().anyMatch(c -> fixedPath.endsWith(c))) { if (!checkExists(parentPath)) { this.doCreatePersistent(parentPath); } - } else if (categroies.stream().anyMatch(c -> parentPath.endsWith(c))) { + } else if (categories.stream().anyMatch(c -> parentPath.endsWith(c))) { String grandfather = parentPath.substring(0, parentPath.lastIndexOf('/')); if (!checkExists(grandfather)) { this.doCreatePersistent(grandfather); diff --git a/dubbo-rpc/dubbo-rpc-api/pom.xml b/dubbo-rpc/dubbo-rpc-api/pom.xml index aae1c05b6ed..b47a4ae9324 100644 --- a/dubbo-rpc/dubbo-rpc-api/pom.xml +++ b/dubbo-rpc/dubbo-rpc-api/pom.xml @@ -44,5 +44,13 @@ dubbo-remoting-api ${project.parent.version} + + com.google.protobuf + protobuf-java + + + com.google.protobuf + protobuf-java-util + \ No newline at end of file diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java index 69b9c97fd53..6a6ac822ed2 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java @@ -26,7 +26,6 @@ import org.apache.dubbo.common.io.UnsafeByteArrayOutputStream; import org.apache.dubbo.common.serialize.Serialization; import org.apache.dubbo.common.utils.PojoUtils; -import org.apache.dubbo.common.utils.ProtobufUtils; import org.apache.dubbo.common.utils.ReflectUtils; import org.apache.dubbo.common.utils.StringUtils; import org.apache.dubbo.rpc.Filter; @@ -39,6 +38,7 @@ import org.apache.dubbo.rpc.RpcResult; import org.apache.dubbo.rpc.service.GenericException; import org.apache.dubbo.rpc.service.GenericService; +import org.apache.dubbo.rpc.support.ProtobufUtils; import org.apache.dubbo.rpc.support.ProtocolUtils; import java.io.IOException; @@ -77,7 +77,7 @@ public Result invoke(Invoker invoker, Invocation inv) throws RpcException { } else if (ProtocolUtils.isJavaGenericSerialization(generic)) { for (int i = 0; i < args.length; i++) { if (byte[].class == args[i].getClass()) { - try(UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream((byte[]) args[i])) { + try (UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream((byte[]) args[i])) { args[i] = ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA) .deserialize(null, is).readObject(); @@ -108,7 +108,7 @@ public Result invoke(Invoker invoker, Invocation inv) throws RpcException { args[i].getClass().getName()); } } - }else if (ProtocolUtils.isProtobufGenericSerialization(generic)) { + } else if (ProtocolUtils.isProtobufGenericSerialization(generic)) { //as proto3 only accept one parameter if (args.length == 1 && args[0] instanceof String) { args[0] = ProtobufUtils.deserialize((String) args[0], method.getParameterTypes()[0]); @@ -136,9 +136,9 @@ public Result invoke(Invoker invoker, Invocation inv) throws RpcException { } } else if (ProtocolUtils.isBeanGenericSerialization(generic)) { return new RpcResult(JavaBeanSerializeUtil.serialize(result.getValue(), JavaBeanAccessor.METHOD)); - } else if(ProtocolUtils.isProtobufGenericSerialization(generic)) { + } else if (ProtocolUtils.isProtobufGenericSerialization(generic)) { return new RpcResult(ProtobufUtils.serialize(result.getValue())); - }else { + } else { return new RpcResult(PojoUtils.generalize(result.getValue())); } } catch (NoSuchMethodException e) { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProtocol.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProtocol.java index 86ef44ca54a..814e9182280 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProtocol.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProtocol.java @@ -40,7 +40,7 @@ public abstract class AbstractProtocol implements Protocol { protected final Map> exporterMap = new ConcurrentHashMap>(); - //TODO SOFEREFENCE + //TODO SoftReference protected final Set> invokers = new ConcurrentHashSet>(); protected static String serviceKey(URL url) { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/ProtobufUtils.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/ProtobufUtils.java new file mode 100644 index 00000000000..7e90bf671c6 --- /dev/null +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/ProtobufUtils.java @@ -0,0 +1,73 @@ +/* + * 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.dubbo.rpc.support; + +import java.lang.reflect.Method; + +import com.google.protobuf.GeneratedMessageV3; +import com.google.protobuf.GeneratedMessageV3.Builder; +import com.google.protobuf.MessageOrBuilder; +import com.google.protobuf.util.JsonFormat; +import com.google.protobuf.util.JsonFormat.Parser; +import com.google.protobuf.util.JsonFormat.Printer; + +public class ProtobufUtils { + + public static boolean isSupported(Class clazz) { + if (clazz == null) { + return false; + } + + if (GeneratedMessageV3.class.isAssignableFrom(clazz)) { + return true; + } + return false; + } + + public static T deserialize(String json, Class requestClass) { + if (!isSupported(requestClass)) { + throw new UnsupportedOperationException(requestClass.getName() + "can not be deserialize"); + } + Builder builder; + try{ + builder = getMessageBuilder(requestClass); + Parser parser = JsonFormat.parser(); + parser.merge(json, builder); + }catch (Exception e){ + throw new RuntimeException("Failed to deserialize "+requestClass,e ); + } + + return (T) builder.build(); + } + + public static String serialize(Object value) { + String result; + try { + Printer printer = JsonFormat.printer(); + result = printer.print((MessageOrBuilder) value); + } catch (Exception e) { + result = e.getMessage(); + } + return result; + } + + private static Builder getMessageBuilder(Class requestType) throws Exception { + Method method = requestType.getMethod("newBuilder"); + + return (Builder) method.invoke(null, null); + } +} \ No newline at end of file