Program: 83013
Project: 83013
Buggy source:
/** 
 * Returns an   {@link RPCRequest} that is built by decoding the contents of anencoded RPC request and optionally validating that type can handle the request. If the type parameter is not <code>null</code>, the implementation checks that the type is assignable to the {@link RemoteService} interface requested in the encoded request string.<p> If the serializationPolicyProvider parameter is not <code>null</code>, it is asked for a  {@link SerializationPolicy} to use to restrict the set oftypes that can be decoded from the request. If this parameter is <code>null</code>, then only subtypes of {@link com.google.gwt.user.client.rpc.IsSerializable IsSerializable} ortypes which have custom field serializers can be decoded. </p> <p> Invoking this method with <code>null</code> for the type parameter, <code>decodeRequest(encodedRequest, null)</code>, is equivalent to calling <code>decodeRequest(encodedRequest)</code>. </p>
 * @param encodedRequest a string that encodes the {@link RemoteService}interface, the service method, and the arguments to pass to the service method
 * @param type if not <code>null</code>, the implementation checks that thetype is assignable to the  {@link RemoteService} interface encodedin the encoded request string.
 * @param serializationPolicyProvider if not <code>null</code>, theimplementation asks this provider for a {@link SerializationPolicy} which will be used to restrict the setof types that can be decoded from this request
 * @return an {@link RPCRequest} instance
 * @throws NullPointerException if the encodedRequest is <code>null</code>
 * @throws IllegalArgumentException if the encodedRequest is an empty string
 * @throws IncompatibleRemoteServiceException if any of the followingconditions apply: <ul> <li>if the types in the encoded request cannot be deserialized</li> <li>if the  {@link ClassLoader} acquired from<code>Thread.currentThread().getContextClassLoader()</code> cannot load the service interface or any of the types specified in the encodedRequest</li> <li>the requested interface is not assignable to {@link RemoteService}</li> <li>the service method requested in the encodedRequest is not a member of the requested service interface</li> <li>the type parameter is not <code>null</code> and is not assignable to the requested   {@link RemoteService} interface</ul>
 */
public static RPCRequest decodeRequest(String encodedRequest,Class<? extends RemoteServiceServlet> type,SerializationPolicyProvider serializationPolicyProvider){
  if (encodedRequest == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (encodedRequest.length() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  ClassLoader classLoader=Thread.currentThread().getContextClassLoader();
  try {
    ServerSerializationStreamReader streamReader=new ServerSerializationStreamReader(classLoader,serializationPolicyProvider);
    streamReader.prepareToRead(encodedRequest);
    String serviceIntfName=streamReader.readString();
    if (type != null) {
      if (!implementsInterface(type,serviceIntfName)) {
        throw new IncompatibleRemoteServiceException("String_Node_Str" + serviceIntfName + "String_Node_Str"+ printTypeName(type)+ "String_Node_Str");
      }
    }
    SerializationPolicy serializationPolicy=streamReader.getSerializationPolicy();
    Class<?> serviceIntf;
    try {
      serviceIntf=getClassFromSerializedName(serviceIntfName,classLoader);
      if (!RemoteService.class.isAssignableFrom(serviceIntf)) {
        throw new IncompatibleRemoteServiceException("String_Node_Str" + printTypeName(serviceIntf) + "String_Node_Str");
      }
    }
 catch (    ClassNotFoundException e) {
      throw new IncompatibleRemoteServiceException("String_Node_Str" + serviceIntfName + "String_Node_Str",e);
    }
    String serviceMethodName=streamReader.readString();
    int paramCount=streamReader.readInt();
    Class<?>[] parameterTypes=new Class[paramCount];
    for (int i=0; i < parameterTypes.length; i++) {
      String paramClassName=streamReader.readString();
      try {
        parameterTypes[i]=getClassFromSerializedName(paramClassName,classLoader);
      }
 catch (      ClassNotFoundException e) {
        throw new IncompatibleRemoteServiceException("String_Node_Str" + i + "String_Node_Str"+ paramClassName+ "String_Node_Str",e);
      }
    }
    Method method=findInterfaceMethod(serviceIntf,serviceMethodName,parameterTypes,true);
    if (method == null) {
      throw new IncompatibleRemoteServiceException(formatMethodNotFoundErrorMessage(serviceIntf,serviceMethodName,parameterTypes));
    }
    Object[] parameterValues=new Object[parameterTypes.length];
    for (int i=0; i < parameterValues.length; i++) {
      parameterValues[i]=streamReader.deserializeValue(parameterTypes[i]);
    }
    return new RPCRequest(method,parameterValues,serializationPolicy);
  }
 catch (  SerializationException ex) {
    throw new IncompatibleRemoteServiceException(ex.getMessage(),ex);
  }
}

Fixed version (ground truth):
/** 
 * Returns an   {@link RPCRequest} that is built by decoding the contents of anencoded RPC request and optionally validating that type can handle the request. If the type parameter is not <code>null</code>, the implementation checks that the type is assignable to the {@link RemoteService} interface requested in the encoded request string.<p> If the serializationPolicyProvider parameter is not <code>null</code>, it is asked for a  {@link SerializationPolicy} to use to restrict the set oftypes that can be decoded from the request. If this parameter is <code>null</code>, then only subtypes of {@link com.google.gwt.user.client.rpc.IsSerializable IsSerializable} ortypes which have custom field serializers can be decoded. </p> <p> Invoking this method with <code>null</code> for the type parameter, <code>decodeRequest(encodedRequest, null)</code>, is equivalent to calling <code>decodeRequest(encodedRequest)</code>. </p>
 * @param encodedRequest a string that encodes the {@link RemoteService}interface, the service method, and the arguments to pass to the service method
 * @param type if not <code>null</code>, the implementation checks that thetype is assignable to the  {@link RemoteService} interface encodedin the encoded request string.
 * @param serializationPolicyProvider if not <code>null</code>, theimplementation asks this provider for a {@link SerializationPolicy} which will be used to restrict the setof types that can be decoded from this request
 * @return an {@link RPCRequest} instance
 * @throws NullPointerException if the encodedRequest is <code>null</code>
 * @throws IllegalArgumentException if the encodedRequest is an empty string
 * @throws IncompatibleRemoteServiceException if any of the followingconditions apply: <ul> <li>if the types in the encoded request cannot be deserialized</li> <li>if the  {@link ClassLoader} acquired from<code>Thread.currentThread().getContextClassLoader()</code> cannot load the service interface or any of the types specified in the encodedRequest</li> <li>the requested interface is not assignable to {@link RemoteService}</li> <li>the service method requested in the encodedRequest is not a member of the requested service interface</li> <li>the type parameter is not <code>null</code> and is not assignable to the requested   {@link RemoteService} interface</ul>
 */
public static RPCRequest decodeRequest(String encodedRequest,Class type,SerializationPolicyProvider serializationPolicyProvider){
  if (encodedRequest == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (encodedRequest.length() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  ClassLoader classLoader=Thread.currentThread().getContextClassLoader();
  try {
    ServerSerializationStreamReader streamReader=new ServerSerializationStreamReader(classLoader,serializationPolicyProvider);
    streamReader.prepareToRead(encodedRequest);
    String serviceIntfName=streamReader.readString();
    if (type != null) {
      if (!implementsInterface(type,serviceIntfName)) {
        throw new IncompatibleRemoteServiceException("String_Node_Str" + serviceIntfName + "String_Node_Str"+ printTypeName(type)+ "String_Node_Str");
      }
    }
    SerializationPolicy serializationPolicy=streamReader.getSerializationPolicy();
    Class<?> serviceIntf;
    try {
      serviceIntf=getClassFromSerializedName(serviceIntfName,classLoader);
      if (!RemoteService.class.isAssignableFrom(serviceIntf)) {
        throw new IncompatibleRemoteServiceException("String_Node_Str" + printTypeName(serviceIntf) + "String_Node_Str");
      }
    }
 catch (    ClassNotFoundException e) {
      throw new IncompatibleRemoteServiceException("String_Node_Str" + serviceIntfName + "String_Node_Str",e);
    }
    String serviceMethodName=streamReader.readString();
    int paramCount=streamReader.readInt();
    Class<?>[] parameterTypes=new Class[paramCount];
    for (int i=0; i < parameterTypes.length; i++) {
      String paramClassName=streamReader.readString();
      try {
        parameterTypes[i]=getClassFromSerializedName(paramClassName,classLoader);
      }
 catch (      ClassNotFoundException e) {
        throw new IncompatibleRemoteServiceException("String_Node_Str" + i + "String_Node_Str"+ paramClassName+ "String_Node_Str",e);
      }
    }
    Method method=findInterfaceMethod(serviceIntf,serviceMethodName,parameterTypes,true);
    if (method == null) {
      throw new IncompatibleRemoteServiceException(formatMethodNotFoundErrorMessage(serviceIntf,serviceMethodName,parameterTypes));
    }
    Object[] parameterValues=new Object[parameterTypes.length];
    for (int i=0; i < parameterValues.length; i++) {
      parameterValues[i]=streamReader.deserializeValue(parameterTypes[i]);
    }
    return new RPCRequest(method,parameterValues,serializationPolicy);
  }
 catch (  SerializationException ex) {
    throw new IncompatibleRemoteServiceException(ex.getMessage(),ex);
  }
}