Program: 83115
Project: 83115
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 IncompatibleRemoteServiceException if any of the followingconditions apply: <ul> <li>if the types in the encoded request cannot be deserialized</li> <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){
  if (encodedRequest == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (encodedRequest.length() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  try {
    ServerSerializationStreamReader streamReader=new ServerSerializationStreamReader(serializableTypeOracle);
    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");
      }
    }
    Class serviceIntf;
    try {
      serviceIntf=getClassFromSerializedName(serviceIntfName);
      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);
      }
 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);
  }
 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> 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 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){
  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(serializableTypeOracle,classLoader);
    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");
      }
    }
    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);
  }
 catch (  SerializationException ex) {
    throw new IncompatibleRemoteServiceException(ex.getMessage(),ex);
  }
}