Program: 83243
Project: 83243
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> 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.
 * @return an {@link RPCRequest} instance
 * @throws NullPointerException if the encodedRequest is <code>null</code>
 * @throws IllegalArgumentException if the encodedRequest is an empty string
 * @throws SerializationException if the types in the encoded request cannotbe deserialized
 * @throws SecurityException if any of the following conditions apply:<ul> <li><code>RPC.class.getClassLoader()</code> cannot load the service interface requested 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) throws SerializationException {
  if (encodedRequest == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (encodedRequest.length() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  ServerSerializationStreamReader streamReader=new ServerSerializationStreamReader(serializableTypeOracle);
  streamReader.prepareToRead(encodedRequest);
  String serviceIntfName=streamReader.readString();
  if (type != null) {
    if (!implementsInterface(type,serviceIntfName)) {
      throw new SecurityException("String_Node_Str" + serviceIntfName + "String_Node_Str"+ TypeInfo.getSourceRepresentation(type,"String_Node_Str")+ "String_Node_Str");
    }
  }
  Class serviceIntf;
  try {
    serviceIntf=getClassFromSerializedName(serviceIntfName);
    if (!RemoteService.class.isAssignableFrom(serviceIntf)) {
      throw new SecurityException("String_Node_Str" + TypeInfo.getSourceRepresentation(serviceIntf,"String_Node_Str") + "String_Node_Str");
    }
  }
 catch (  ClassNotFoundException e) {
    SecurityException securityException=new SecurityException("String_Node_Str" + serviceIntfName + "String_Node_Str");
    securityException.initCause(e);
    throw securityException;
  }
  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);
    }
 catch (    ClassNotFoundException e) {
      throw new SerializationException("String_Node_Str" + i + "String_Node_Str"+ paramClassName+ "String_Node_Str",e);
    }
  }
  Method method=findInterfaceMethod(serviceIntf,serviceMethodName,parameterTypes,true);
  if (method == null) {
    throw new SecurityException(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);
}

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> 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.
 * @return an {@link RPCRequest} instance
 * @throws NullPointerException if the encodedRequest is <code>null</code>
 * @throws IllegalArgumentException if the encodedRequest is an empty string
 * @throws SerializationException if the types in the encoded request cannotbe deserialized
 * @throws SecurityException if any of the following conditions apply:<ul> <li><code>RPC.class.getClassLoader()</code> cannot load the service interface requested 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) throws SerializationException {
  if (encodedRequest == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (encodedRequest.length() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  ServerSerializationStreamReader streamReader=new ServerSerializationStreamReader(serializableTypeOracle);
  streamReader.prepareToRead(encodedRequest);
  String serviceIntfName=streamReader.readString();
  if (type != null) {
    if (!implementsInterface(type,serviceIntfName)) {
      throw new SecurityException("String_Node_Str" + serviceIntfName + "String_Node_Str"+ printTypeName(type)+ "String_Node_Str");
    }
  }
  Class serviceIntf;
  try {
    serviceIntf=getClassFromSerializedName(serviceIntfName);
    if (!RemoteService.class.isAssignableFrom(serviceIntf)) {
      throw new SecurityException("String_Node_Str" + printTypeName(serviceIntf) + "String_Node_Str");
    }
  }
 catch (  ClassNotFoundException e) {
    SecurityException securityException=new SecurityException("String_Node_Str" + serviceIntfName + "String_Node_Str");
    securityException.initCause(e);
    throw securityException;
  }
  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);
    }
 catch (    ClassNotFoundException e) {
      throw new SerializationException("String_Node_Str" + i + "String_Node_Str"+ paramClassName+ "String_Node_Str",e);
    }
  }
  Method method=findInterfaceMethod(serviceIntf,serviceMethodName,parameterTypes,true);
  if (method == null) {
    throw new SecurityException(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);
}