result = result && getValueCase().equals( other.getValueCase()); if (!result) return false; switch (valueCase_) { case 1: result = result && (getIntResult() == other.getIntResult()); break; case 2: result = result && (getLongResult() == other.getLongResult()); break; case 3: result = result && (getShortResult() == other.getShortResult()); break; case 4: result = result && (getByteResult() == other.getByteResult()); break; case 5: result = result && (getBooleanResult() == other.getBooleanResult()); break; case 6: result = result && ( java.lang.Double.doubleToLongBits(getDoubleResult()) == java.lang.Double.doubleToLongBits( other.getDoubleResult()));
BasicTypes.EncodedValue.Builder builder = BasicTypes.EncodedValue.newBuilder(); try { if (serializer.supportsPrimitives()) {
hash = (19 * hash) + getDescriptor().hashCode(); switch (valueCase_) { case 1: hash = (37 * hash) + INTRESULT_FIELD_NUMBER; hash = (53 * hash) + getIntResult(); break; case 2: hash = (37 * hash) + LONGRESULT_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong( getLongResult()); break; case 3: hash = (37 * hash) + SHORTRESULT_FIELD_NUMBER; hash = (53 * hash) + getShortResult(); break; case 4: hash = (37 * hash) + BYTERESULT_FIELD_NUMBER; hash = (53 * hash) + getByteResult(); break; case 5: hash = (37 * hash) + BOOLEANRESULT_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( getBooleanResult()); break; case 6: hash = (37 * hash) + DOUBLERESULT_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong( java.lang.Double.doubleToLongBits(getDoubleResult())); break;
public Builder mergeFrom(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue other) { if (other == org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue.getDefaultInstance()) return this; switch (other.getValueCase()) { case INTRESULT: { setIntResult(other.getIntResult()); break; setLongResult(other.getLongResult()); break; setShortResult(other.getShortResult()); break; setByteResult(other.getByteResult()); break; setBooleanResult(other.getBooleanResult()); break; setDoubleResult(other.getDoubleResult()); break; setFloatResult(other.getFloatResult()); break; setBinaryResult(other.getBinaryResult()); break; setNullResultValue(other.getNullResultValue()); break;
BasicTypes.EncodedValue.Builder builder = BasicTypes.EncodedValue.newBuilder();
switch (encodedValue.getValueCase()) { case BINARYRESULT: return encodedValue.getBinaryResult().toByteArray(); case BOOLEANRESULT: return encodedValue.getBooleanResult(); case BYTERESULT: return (byte) encodedValue.getByteResult(); case DOUBLERESULT: return encodedValue.getDoubleResult(); case FLOATRESULT: return encodedValue.getFloatResult(); case INTRESULT: return encodedValue.getIntResult(); case LONGRESULT: return encodedValue.getLongResult(); case SHORTRESULT: return (short) encodedValue.getShortResult(); case STRINGRESULT: return encodedValue.getStringResult(); case JSONOBJECTRESULT: return jsonPdxConverter.decode(encodedValue.getJsonObjectResult()); case NULLRESULT: return null; case CUSTOMOBJECTRESULT: return serializer.deserialize(encodedValue.getCustomObjectResult()); default: throw new DecodingException( "Unknown Protobuf encoding type: " + encodedValue.getValueCase());
switch (encodedValue.getValueCase()) { case BINARYRESULT: return encodedValue.getBinaryResult().toByteArray(); case BOOLEANRESULT: return encodedValue.getBooleanResult(); case BYTERESULT: return (byte) encodedValue.getByteResult(); case DOUBLERESULT: return encodedValue.getDoubleResult(); case FLOATRESULT: return encodedValue.getFloatResult(); case INTRESULT: return encodedValue.getIntResult(); case LONGRESULT: return encodedValue.getLongResult(); case SHORTRESULT: return (short) encodedValue.getShortResult(); case STRINGRESULT: return encodedValue.getStringResult(); case JSONOBJECTRESULT: return JSONWrapper.wrapJSON(encodedValue.getJsonObjectResult()); case NULLRESULT: return null; case CUSTOMOBJECTRESULT: try { return valueSerializer.deserialize(encodedValue.getCustomObjectResult()); } catch (IOException | ClassNotFoundException e) { throw new IllegalStateException(e);
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.EncodedValue singleResult = 1;</code> */ public Builder mergeSingleResult(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue value) { if (singleResultBuilder_ == null) { if (resultCase_ == 1 && result_ != org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue.getDefaultInstance()) { result_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue.newBuilder((org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue) result_) .mergeFrom(value).buildPartial(); } else { result_ = value; } onChanged(); } else { if (resultCase_ == 1) { singleResultBuilder_.mergeFrom(value); } singleResultBuilder_.setMessage(value); } resultCase_ = 1; return this; } /**
@Test public void processReturnsErrorUnableToDecodeRequest() throws Exception { Exception exception = new DecodingException("error finding codec for type"); ProtobufSerializationService serializationServiceStub = mock(ProtobufSerializationService.class); when(serializationServiceStub.decode(any())).thenReturn(TEST_KEY1, TEST_VALUE1) .thenThrow(exception); when(serializationServiceStub.encode(any())) .thenReturn(BasicTypes.EncodedValue.newBuilder().setStringResult("some string").build()); BasicTypes.EncodedValue encodedObject1 = BasicTypes.EncodedValue.newBuilder().setStringResult(TEST_KEY1).build(); BasicTypes.EncodedValue encodedObject2 = BasicTypes.EncodedValue.newBuilder().setStringResult(TEST_KEY2).build(); Set<BasicTypes.Entry> entries = new HashSet<>(); entries.add(ProtobufUtilities.createEntry(encodedObject1, encodedObject1)); entries.add(ProtobufUtilities.createEntry(encodedObject2, encodedObject2)); RegionAPI.PutAllRequest putAllRequest = ProtobufRequestUtilities.createPutAllRequest(TEST_REGION, entries).getPutAllRequest(); expectedException.expect(DecodingException.class); Result response = operationHandler.process(serializationServiceStub, putAllRequest, TestExecutionContext.getNoAuthCacheExecutionContext(cacheStub)); }
@Test public void processReturnsErrorUnableToDecodeRequest() throws Exception { Exception exception = new DecodingException("error finding codec for type"); ProtobufSerializationService serializationServiceStub = mock(ProtobufSerializationService.class); when(serializationServiceStub.decodeList(any())).thenThrow(exception); BasicTypes.EncodedValue encodedKey1 = BasicTypes.EncodedValue.newBuilder().setStringResult(TEST_KEY1).build(); BasicTypes.EncodedValue encodedKey2 = BasicTypes.EncodedValue.newBuilder().setStringResult(TEST_KEY2).build(); Set<BasicTypes.EncodedValue> keys = new HashSet<>(); keys.add(encodedKey1); keys.add(encodedKey2); RegionAPI.GetAllRequest getRequest = ProtobufRequestUtilities.createGetAllRequest(TEST_REGION, keys); expectedException.expect(DecodingException.class); operationHandler.process(serializationServiceStub, getRequest, TestExecutionContext.getNoAuthCacheExecutionContext(cacheStub)); }
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.EncodedValue key = 2;</code> */ public Builder mergeKey(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue value) { if (keyBuilder_ == null) { if (key_ != null) { key_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue.newBuilder(key_).mergeFrom(value).buildPartial(); } else { key_ = value; } onChanged(); } else { keyBuilder_.mergeFrom(value); } return this; } /**
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.EncodedValue callbackArg = 3;</code> */ public Builder mergeCallbackArg(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue value) { if (callbackArgBuilder_ == null) { if (callbackArg_ != null) { callbackArg_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue.newBuilder(callbackArg_).mergeFrom(value).buildPartial(); } else { callbackArg_ = value; } onChanged(); } else { callbackArgBuilder_.mergeFrom(value); } return this; } /**
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.EncodedValue arguments = 3;</code> */ public Builder mergeArguments(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue value) { if (argumentsBuilder_ == null) { if (arguments_ != null) { arguments_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue.newBuilder(arguments_).mergeFrom(value).buildPartial(); } else { arguments_ = value; } onChanged(); } else { argumentsBuilder_.mergeFrom(value); } return this; } /**
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.EncodedValue key = 1;</code> */ public Builder mergeKey(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue value) { if (keyBuilder_ == null) { if (key_ != null) { key_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue.newBuilder(key_).mergeFrom(value).buildPartial(); } else { key_ = value; } onChanged(); } else { keyBuilder_.mergeFrom(value); } return this; } /**
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.EncodedValue key = 1;</code> */ public Builder mergeKey(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue value) { if (keyBuilder_ == null) { if (key_ != null) { key_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue.newBuilder(key_).mergeFrom(value).buildPartial(); } else { key_ = value; } onChanged(); } else { keyBuilder_.mergeFrom(value); } return this; } /**
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.EncodedValue result = 1;</code> */ public Builder mergeResult(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue value) { if (resultBuilder_ == null) { if (result_ != null) { result_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue.newBuilder(result_).mergeFrom(value).buildPartial(); } else { result_ = value; } onChanged(); } else { resultBuilder_.mergeFrom(value); } return this; } /**
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.EncodedValue key = 2;</code> */ public Builder mergeKey(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue value) { if (keyBuilder_ == null) { if (key_ != null) { key_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue.newBuilder(key_).mergeFrom(value).buildPartial(); } else { key_ = value; } onChanged(); } else { keyBuilder_.mergeFrom(value); } return this; } /**
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.EncodedValue value = 2;</code> */ public Builder mergeValue(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue value) { if (valueBuilder_ == null) { if (value_ != null) { value_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue.newBuilder(value_).mergeFrom(value).buildPartial(); } else { value_ = value; } onChanged(); } else { valueBuilder_.mergeFrom(value); } return this; } /**
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.EncodedValue oldValue = 1;</code> */ public Builder mergeOldValue(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue value) { if (oldValueBuilder_ == null) { if (oldValue_ != null) { oldValue_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue.newBuilder(oldValue_).mergeFrom(value).buildPartial(); } else { oldValue_ = value; } onChanged(); } else { oldValueBuilder_.mergeFrom(value); } return this; } /**
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.EncodedValue arguments = 3;</code> */ public Builder mergeArguments(org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue value) { if (argumentsBuilder_ == null) { if (arguments_ != null) { arguments_ = org.apache.geode.internal.protocol.protobuf.v1.BasicTypes.EncodedValue.newBuilder(arguments_).mergeFrom(value).buildPartial(); } else { arguments_ = value; } onChanged(); } else { argumentsBuilder_.mergeFrom(value); } return this; } /**