[ 
https://issues.apache.org/jira/browse/GEODE-86?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14625609#comment-14625609
 ] 

Darrel Schneider commented on GEODE-86:
---------------------------------------

I think it is best to leave getValue as it is. The javadocs will be beefed up 
to clarify that it may returned a serialized blob:
  /**
   * Get the value for this operation.
   * Note that if the value is serialized then a byte array
   * will be returned that contains the serialized bytes.
   * To figure out if the returned byte array contains serialized bytes
   * or is the deserialized value call {@link #isObject()}.
   * If you need to deserialize the serialized bytes use 
   * {@link DataSerializer#readObject(java.io.DataInput)}
   * or you can just call {@link #getDeserializedValue()}.
   * 
   * @return the value for this operation
   * @since 6.5
   */
  public Object getValue();

To fix this issue a new method will be added that allows you to explicitly 
request the deserialized value:
  /**
   * Get the deserialized value for this operation.
   * Note that if the value is serialized this method will attempt to 
deserialize it.
   * If PDX read-serialized is set to true and the value was serialized with PDX
   * then this method will return a PdxInstance.
   * 
   * @return the deserialized value for this operation
   * @throws SerializationException if deserialization of the value fails
   * @since Geode 1.0
   */
  public Object getDeserializedValue() throws SerializationException;


> KeyValueOperationContext getValue returns a byte array when the value was not 
> a byte array
> ------------------------------------------------------------------------------------------
>
>                 Key: GEODE-86
>                 URL: https://issues.apache.org/jira/browse/GEODE-86
>             Project: Geode
>          Issue Type: Bug
>            Reporter: Darrel Schneider
>            Assignee: Darrel Schneider
>            Priority: Minor
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> I am using a plain-old Java object and Geode PDX to PUT and GET values from a 
> client app to a Geode region. Thanks to PDX, I don't have to install the 
> class on the Geode cluster.
> In my implementation of the AccessControl interface, I receive the 
> OperationContext object as part of the pre- and post-authorization callbacks. 
> I was expecting to receive a PdxInstance object but instead I am receiving a 
> byte[] object.
> In the future, It would be nice to receive a PdxInstance to make the process 
> much cleaner. For now I have to do this something like this to get my 
> PdxInstance object:
> PdxInputStream pdxIs = new PdxInputStream((byte[]) 
> ((KeyValueOperationContext) context).getValue());
>  userData = (PdxInstance) DataSerializer.readObject(pdxIs);    
> This looks like a bug in 
> com.gemstone.gemfire.cache.operations.KeyValueOperationContext.getValue().
> This method should return to deserialized value for the operation. The 
> javadocs don't actually say this but I think that was the idea. If you wanted 
> to serialized value you could call getSerializedValue().
> The problem with the current getValue implementation is that if the context 
> has a serialized value it just returns it. But the serialized value will 
> always be a byte[] that contains the serialized bytes.
> getValue should only return a byte array if the actual value passed to the 
> operation was a byte array.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to