nus-yam/ex-repair huggingface dataset:
Program: 90682
Project: 90682
Buggy source:
/** 
 * Returns all preferences of this portlet The return value cannot be NULL.
 * @return the preference set
 */
public PortletPreference[] getDefaultPreferences(){
  if (defaultPreferences == null) {
    PortletDD portletDD=getPortletDefinition();
    PortletPreferencesDD prefsDD=portletDD.getPortletPreferences();
    if (prefsDD != null) {
      List prefs=new ArrayList();
      for (Iterator it=prefsDD.getPortletPreferences().iterator(); it.hasNext(); ) {
        PortletPreferenceDD prefDD=(PortletPreferenceDD)it.next();
        String[] values=(String[])prefDD.getValues().toArray(new String[prefDD.getValues().size()]);
        PortletPreferenceImpl pref=new PortletPreferenceImpl(prefDD.getName(),values,prefDD.isReadOnly());
        prefs.add(pref);
      }
      defaultPreferences=(PortletPreference[])prefs.toArray(new PortletPreference[prefs.size()]);
    }
  }
  return defaultPreferences;
}

Fixed version (ground truth):
/** 
 * Returns an array of default preferences of this portlet. The default preferences are retrieved from the portlet application descriptor. <p> Data retrieved from <code>portlet.xml</code> are injected into the domain object <code>PortletPreferenceDD</code>. This method converts the domain objects into <code>PortletPreference</code> objects. </p> <p> Note that if no value is bound to a given preference key, <code>PortletPreferenceDD.getValues()</code> will return an empty string list, but the value array of <code>PortletPreference</code> should be set to null (instead of an empty array). </p> <p> This method never returns null. </p>
 * @return the preference set
 * @see org.apache.pluto.descriptors.portlet.PortletPreferenceDD
 */
public PortletPreference[] getDefaultPreferences(){
  if (defaultPreferences == null) {
    PortletDD portletDD=getPortletDefinition();
    PortletPreferencesDD prefsDD=portletDD.getPortletPreferences();
    if (prefsDD != null) {
      List prefs=new ArrayList();
      for (Iterator it=prefsDD.getPortletPreferences().iterator(); it.hasNext(); ) {
        PortletPreferenceDD prefDD=(PortletPreferenceDD)it.next();
        String[] values=null;
        if (prefDD.getValues().size() > 0) {
          values=(String[])prefDD.getValues().toArray(new String[prefDD.getValues().size()]);
        }
        PortletPreferenceImpl pref=new PortletPreferenceImpl(prefDD.getName(),values,prefDD.isReadOnly());
        prefs.add(pref);
      }
      defaultPreferences=(PortletPreference[])prefs.toArray(new PortletPreference[prefs.size()]);
    }
  }
  return defaultPreferences;
}
Program: 90683
Project: 90683
Buggy source:
public String getValue(String key,String defaultValue){
  String[] values=getValues(key,new String[]{defaultValue});
  return (values != null && values.length > 0) ? values[0] : null;
}

Fixed version (ground truth):
public String getValue(String key,String defaultValue){
  String[] values=getValues(key,new String[]{defaultValue});
  String value=null;
  if (values != null && values.length > 0) {
    value=values[0];
  }
  if (value == null) {
    value=defaultValue;
  }
  return value;
}
Program: 90684
Project: 90684
Buggy source:
public String[] getValues(String key,String[] defaultValues){
  if (key == null) {
    throw new IllegalArgumentException(EXCEPTIONS.getString("String_Node_Str","String_Node_Str"));
  }
  String[] values=null;
  PortletPreference pref=(PortletPreference)preferences.get(key);
  if (pref != null) {
    values=pref.getValues();
  }
 else {
    values=defaultValues;
  }
  return values;
}

Fixed version (ground truth):
public String[] getValues(String key,String[] defaultValues){
  if (key == null) {
    throw new IllegalArgumentException(EXCEPTIONS.getString("String_Node_Str","String_Node_Str"));
  }
  String[] values=null;
  PortletPreference pref=(PortletPreference)preferences.get(key);
  if (pref != null) {
    values=pref.getValues();
  }
  if (values == null) {
    values=defaultValues;
  }
  return values;
}
Program: 90685
Project: 90685
Buggy source:
public PortletRequestDispatcher getRequestDispatcher(String path){
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + path);
  }
  if (path == null || !path.startsWith("String_Node_Str")) {
    if (LOG.isInfoEnabled()) {
      LOG.info("String_Node_Str" + "String_Node_Str");
    }
    return null;
  }
  String dispatchingPath=null;
  Map params=null;
  int index=path.indexOf("String_Node_Str");
  if (index > 0) {
    dispatchingPath=path.substring(0,index);
    if (index < path.length() - 1) {
      params=parseQueryParams(path.substring(index + 1));
    }
  }
 else {
    dispatchingPath=path;
  }
  PortletRequestDispatcher portletRequestDispatcher=null;
  try {
    RequestDispatcher servletRequestDispatcher=servletContext.getRequestDispatcher(dispatchingPath);
    if (servletRequestDispatcher != null) {
      portletRequestDispatcher=new PortletRequestDispatcherImpl(servletRequestDispatcher,params);
    }
 else {
      if (LOG.isInfoEnabled()) {
        LOG.info("String_Node_Str" + dispatchingPath);
      }
    }
  }
 catch (  Exception ex) {
    if (LOG.isInfoEnabled()) {
      LOG.info("String_Node_Str" + ex.getMessage());
    }
    portletRequestDispatcher=null;
  }
  return portletRequestDispatcher;
}

Fixed version (ground truth):
public PortletRequestDispatcher getRequestDispatcher(String path){
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + path);
  }
  if (path == null || !path.startsWith("String_Node_Str")) {
    if (LOG.isInfoEnabled()) {
      LOG.info("String_Node_Str" + "String_Node_Str");
    }
    return null;
  }
  Map appendedParameters=null;
  int index=path.indexOf("String_Node_Str");
  if (index > 0 && index < path.length() - 1) {
    appendedParameters=parseQueryString(path.substring(index + 1));
  }
  PortletRequestDispatcher portletRequestDispatcher=null;
  try {
    RequestDispatcher servletRequestDispatcher=servletContext.getRequestDispatcher(path);
    if (servletRequestDispatcher != null) {
      portletRequestDispatcher=new PortletRequestDispatcherImpl(servletRequestDispatcher,appendedParameters);
    }
 else {
      if (LOG.isInfoEnabled()) {
        LOG.info("String_Node_Str" + path);
      }
    }
  }
 catch (  Exception ex) {
    if (LOG.isInfoEnabled()) {
      LOG.info("String_Node_Str" + ex.getMessage());
    }
    portletRequestDispatcher=null;
  }
  return portletRequestDispatcher;
}
Program: 90686
Project: 90686
Buggy source:
public PortletRequestDispatcherImpl(RequestDispatcher requestDispatcher,Map queryParams){
  this(requestDispatcher);
  this.queryParams=queryParams;
}

Fixed version (ground truth):
/** 
 * Creates an instance. This constructor should be called to construct a portlet request dispatcher.
 * @param requestDispatcher  the servlet request dispatcher.
 * @param queryParams  the appended query parameters.
 * @see javax.portlet.PortletContext#getRequestDispatcher(String)
 */
public PortletRequestDispatcherImpl(RequestDispatcher requestDispatcher,Map queryParams){
  this(requestDispatcher);
  this.queryParams=queryParams;
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str");
  }
}
Program: 90687
Project: 90687
Buggy source:
public void include(RenderRequest request,RenderResponse response) throws PortletException, IOException {
  InternalRenderRequest internalRequest=(InternalRenderRequest)InternalImplConverter.getInternalRequest(request);
  InternalRenderResponse internalResponse=(InternalRenderResponse)InternalImplConverter.getInternalResponse(response);
  if (queryParams != null) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str");
    }
    internalRequest=new IncludedRenderRequestImpl(internalRequest,queryParams);
  }
  boolean isIncluded=(internalRequest.isIncluded() || internalResponse.isIncluded());
  try {
    internalRequest.setIncluded(true);
    internalResponse.setIncluded(true);
    requestDispatcher.include((HttpServletRequest)internalRequest,(HttpServletResponse)internalResponse);
  }
 catch (  IOException ex) {
    throw ex;
  }
catch (  ServletException ex) {
    if (ex.getRootCause() != null) {
      throw new PortletException(ex.getRootCause());
    }
 else {
      throw new PortletException(ex);
    }
  }
 finally {
    internalRequest.setIncluded(isIncluded);
    internalResponse.setIncluded(isIncluded);
  }
}

Fixed version (ground truth):
public void include(RenderRequest request,RenderResponse response) throws PortletException, IOException {
  InternalRenderRequest internalRequest=(InternalRenderRequest)InternalImplConverter.getInternalRequest(request);
  InternalRenderResponse internalResponse=(InternalRenderResponse)InternalImplConverter.getInternalResponse(response);
  boolean isIncluded=(internalRequest.isIncluded() || internalResponse.isIncluded());
  try {
    internalRequest.setIncluded(true);
    internalRequest.setAppendedParameters(queryParams);
    internalResponse.setIncluded(true);
    requestDispatcher.include((HttpServletRequest)internalRequest,(HttpServletResponse)internalResponse);
  }
 catch (  IOException ex) {
    throw ex;
  }
catch (  ServletException ex) {
    if (ex.getRootCause() != null) {
      throw new PortletException(ex.getRootCause());
    }
 else {
      throw new PortletException(ex);
    }
  }
 finally {
    internalRequest.setIncluded(isIncluded);
    internalResponse.setIncluded(isIncluded);
  }
}
Program: 90688
Project: 90688
Buggy source:
public String getParameter(String name){
  ArgumentUtility.validateNotNull("String_Node_Str",name);
  bodyAccessed=true;
  Map parameters=this.getHttpServletRequest().getParameterMap();
  String[] values=(String[])parameters.get(name);
  if (values != null) {
    return values[0];
  }
  return null;
}

Fixed version (ground truth):
public String getParameter(String name){
  ArgumentUtility.validateNotNull("String_Node_Str",name);
  bodyAccessed=true;
  Map parameters=this.getHttpServletRequest().getParameterMap();
  String[] values=(String[])parameters.get(name);
  if (values != null) {
    return values[0];
  }
 else {
    return null;
  }
}
Program: 90689
Project: 90689
Buggy source:
/** 
 * FIXME: portlet preference method ID!
 */
public PortletPreferences getPreferences(){
  if (portletPreferences == null) {
    portletPreferences=new PortletPreferencesImpl(getPortletContainer(),getInternalPortletWindow(),this,Constants.METHOD_RENDER);
  }
  return portletPreferences;
}

Fixed version (ground truth):
public PortletPreferences getPreferences(){
  if (portletPreferences == null) {
    portletPreferences=new PortletPreferencesImpl(getPortletContainer(),getInternalPortletWindow(),this,Constants.METHOD_RENDER);
  }
  return portletPreferences;
}
Program: 90690
Project: 90690
Buggy source:
public void setIncluded(boolean included){
  this.included=included;
}

Fixed version (ground truth):
public void setIncluded(boolean included){
  this.included=included;
  if (!included) {
    this.parameters=null;
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + included);
  }
}
Program: 90691
Project: 90691
Buggy source:
public PortletPreference[] getStoredPreferences(PortletWindow portletWindow,PortletRequest request) throws PortletContainerException {
  String key=getFormattedKey(portletWindow,request.getRemoteUser());
  PortletPreference[] prefs=(PortletPreference[])storage.get(key);
  if (prefs == null) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + key);
    }
    return new PortletPreference[0];
  }
 else {
    return prefs;
  }
}

Fixed version (ground truth):
/** 
 * Returns the stored portlet preferences array. The preferences managed by this service should be protected from being directly accessed, so this method returns a cloned copy of the stored preferences.
 * @see org.apache.pluto.core.PortletPreference#clone()
 * @param portletWindow  the portlet window.
 * @param request  the portlet request from which the remote user is retrieved.
 * @return a copy of the stored portlet preferences array.
 * @throws PortletContainerException
 */
public PortletPreference[] getStoredPreferences(PortletWindow portletWindow,PortletRequest request) throws PortletContainerException {
  String key=getFormattedKey(portletWindow,request);
  PortletPreference[] preferences=(PortletPreference[])storage.get(key);
  if (preferences == null) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + key);
    }
    return new PortletPreference[0];
  }
 else {
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + preferences.length + "String_Node_Str");
    }
    return clonePreferences(preferences);
  }
}
Program: 90692
Project: 90692
Buggy source:
/** 
 * Formats the preference key for the portlet preference using specified portlet window and remote user. TODO: this method depends on the impl of PortletWindow.toString()!
 * @param portletWindow  the portlet window.
 * @param user  the remote user.
 */
private String getFormattedKey(PortletWindow portletWindow,String user){
  StringBuffer buffer=new StringBuffer();
  buffer.append("String_Node_Str").append(user).append("String_Node_Str");
  buffer.append("String_Node_Str").append(portletWindow.getPortletName());
  return buffer.toString();
}

Fixed version (ground truth):
/** 
 * Formats the preference key for the portlet preference using specified portlet window and remote user.
 * @param portletWindow  the portlet window.
 * @param user  the remote user.
 */
private String getFormattedKey(PortletWindow portletWindow,PortletRequest request){
  StringBuffer buffer=new StringBuffer();
  buffer.append("String_Node_Str").append(request.getRemoteUser()).append("String_Node_Str");
  buffer.append("String_Node_Str").append(portletWindow.getPortletName());
  return buffer.toString();
}
Program: 90693
Project: 90693
Buggy source:
/** 
 * Stores the portlet preferences to the in-memory storage. This method should be invoked after the portlet preferences are validated by the preference validator (if defined).
 * @see javax.portlet.PortletPreferences#store()
 */
public void store(PortletWindow portletWindow,PortletRequest request,PortletPreference[] preferences) throws PortletContainerException {
  String key=getFormattedKey(portletWindow,request.getRemoteUser());
  storage.put(key,preferences);
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + key);
  }
}

Fixed version (ground truth):
/** 
 * Stores the portlet preferences to the in-memory storage. This method should be invoked after the portlet preferences are validated by the preference validator (if defined). <p> The preferences managed by this service should be protected from being directly accessed, so this method clones the passed-in preferences array and saves it. </p>
 * @see javax.portlet.PortletPreferences#store()
 * @see org.apache.pluto.core.PortletPreference#clone()
 * @param portletWindow  the portlet window
 * @param request  the portlet request from which the remote user is retrieved.
 * @param preferences  the portlet preferences to store.
 * @throws PortletContainerException
 */
public void store(PortletWindow portletWindow,PortletRequest request,PortletPreference[] preferences) throws PortletContainerException {
  String key=getFormattedKey(portletWindow,request);
  storage.put(key,clonePreferences(preferences));
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + key);
  }
}
Program: 90694
Project: 90694
Buggy source:
/** 
 * Stores the portlet preferences to a persistent storage.
 * @throws ValidatorException  if the portlet preferences are not valid.
 * @throws IOException  if an error occurs with the persistence mechanism.
 */
public void store() throws IOException, ValidatorException {
  if (!Constants.METHOD_ACTION.equals(methodId)) {
    throw new IllegalStateException("String_Node_Str");
  }
  PreferencesValidator validator=window.getPortletEntity().getPreferencesValidator();
  if (validator != null) {
    validator.validate(this);
  }
  PortletPreference[] prefs=(PortletPreference[])new ArrayList(preferences.values()).toArray(new PortletPreference[preferences.size()]);
  try {
    preferencesService.store(window,request,prefs);
  }
 catch (  PortletContainerException ex) {
    LOG.error("String_Node_Str",ex);
    throw new IOException("String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Stores the portlet preferences to a persistent storage. If a preferences validator is defined for this portlet, this method firstly validates the portlet preferences.
 * @throws ValidatorException  if the portlet preferences are not valid.
 * @throws IOException  if an error occurs with the persistence mechanism.
 */
public void store() throws IOException, ValidatorException {
  if (!Constants.METHOD_ACTION.equals(methodId)) {
    throw new IllegalStateException("String_Node_Str");
  }
  PreferencesValidator validator=window.getPortletEntity().getPreferencesValidator();
  if (validator != null) {
    validator.validate(this);
  }
  PortletPreference[] prefs=(PortletPreference[])(new ArrayList(preferences.values())).toArray(new PortletPreference[preferences.size()]);
  try {
    preferencesService.store(window,request,prefs);
  }
 catch (  PortletContainerException ex) {
    LOG.error("String_Node_Str",ex);
    throw new IOException("String_Node_Str" + ex.getMessage());
  }
}
Program: 90696
Project: 90696
Buggy source:
/** 
 * Invoke test methods using java reflection. All 'check*' methods are invoked and test results are saved into <code>TestResults</code> object.
 * @param config  the portlet config.
 * @param context  the portlet context.
 * @param request  the portlet request.
 * @param response  the portlet response.
 * @return the test results including several TestResult instances. 
 */
public TestResults doTest(PortletConfig config,PortletContext context,PortletRequest request,PortletResponse response){
  TestResults results=new TestResults(getTestSuiteName());
  Method[] methods=getClass().getDeclaredMethods();
  for (int i=0; i < methods.length; i++) {
    if (methods[i].getName().startsWith("String_Node_Str")) {
      debugWithName("String_Node_Str" + methods[i].getName());
      try {
        TestResult result=invoke(methods[i],config,context,request,response);
        if (result.getName() == null) {
          result.setName(methods[i].getName());
        }
        results.add(result);
        debugWithName("String_Node_Str" + result);
      }
 catch (      Throwable th) {
        String message="String_Node_Str" + methods[i].getName() + "String_Node_Str"+ th.getClass().getName()+ "String_Node_Str"+ th.getMessage();
        errorWithName(message,th);
        TestResult result=new TestResult();
        result.setName(methods[i].getName());
        result.setReturnCode(TestResult.FAILED);
        result.setResultMessage(message);
        results.add(result);
      }
    }
  }
  return results;
}

Fixed version (ground truth):
/** 
 * Invoke test methods using java reflection. All 'check*' methods are invoked and test results are saved into <code>TestResults</code> object.
 * @param config  the portlet config.
 * @param context  the portlet context.
 * @param request  the portlet request.
 * @param response  the portlet response.
 * @return the test results including several TestResult instances. 
 */
public TestResults doTest(PortletConfig config,PortletContext context,PortletRequest request,PortletResponse response){
  TestResults results=new TestResults(getTestSuiteName());
  for (Iterator it=getCheckMethods().iterator(); it.hasNext(); ) {
    Method method=(Method)it.next();
    debugWithName("String_Node_Str" + method.getName());
    try {
      TestResult result=invoke(method,config,context,request,response);
      if (result.getName() == null) {
        result.setName(method.getName());
      }
      results.add(result);
      debugWithName("String_Node_Str" + result);
    }
 catch (    Throwable th) {
      String message="String_Node_Str" + method.getName() + "String_Node_Str"+ th.getClass().getName()+ "String_Node_Str"+ th.getMessage();
      errorWithName(message,th);
      TestResult result=new TestResult();
      result.setName(method.getName());
      result.setReturnCode(TestResult.FAILED);
      result.setResultMessage(message);
      results.add(result);
    }
  }
  return results;
}
Program: 90697
Project: 90697
Buggy source:
/** 
 * @param context  the servlet context from which this window isbeing invoked.
 * @param portletWindow  the underlying portlet window instance.
 */
public InternalPortletWindow(ServletContext context,PortletWindow portletWindow){
  this.servletContext=context.getContext(portletWindow.getContextPath());
  if (servletContext == null) {
    throw new PortletContainerRuntimeException(EXCEPTIONS.getString("String_Node_Str",portletWindow.getPortletName(),portletWindow.getContextPath()));
  }
  this.portletWindow=portletWindow;
}

Fixed version (ground truth):
/** 
 * Constructs an internal portlet window that wraps a portlet window. An internal portlet window instance is created everytime when the portlet container's <code>doRender()</code> or <code>doAction()</code> method is invoked.
 * @param context  the servlet context from which this window isbeing invoked.
 * @param portletWindow  the underlying portlet window instance.
 */
public InternalPortletWindow(ServletContext context,PortletWindow portletWindow){
  this.servletContext=context.getContext(portletWindow.getContextPath());
  if (servletContext == null) {
    throw new PortletContainerRuntimeException(EXCEPTIONS.getString("String_Node_Str",portletWindow.getPortletName(),portletWindow.getContextPath()));
  }
  this.portletWindow=portletWindow;
}
Program: 90698
Project: 90698
Buggy source:
public static PortletDescriptorRegistry getRegistry(){
  if (instance == null) {
    instance=new PortletDescriptorRegistry();
  }
  return instance;
}

Fixed version (ground truth):
/** 
 * Returns the singleton registry instance.
 * @return the singleton registry instance.
 */
public static PortletDescriptorRegistry getRegistry(){
  return REGISTRY;
}
Program: 90699
Project: 90699
Buggy source:
/** 
 * We must modify the context class loader in order for the Configuration utility to find the properties file.
 */
private PortletDescriptorRegistry(){
  String className=Configuration.getPortletAppDescriptorServiceImpl();
  try {
    Class cl=Class.forName(className);
    Object instance=cl.newInstance();
    portletDDService=(PortletAppDescriptorService)instance;
  }
 catch (  ClassNotFoundException e) {
    throw new PlutoConfigurationException("String_Node_Str" + className,e);
  }
catch (  InstantiationException e) {
    throw new PlutoConfigurationException("String_Node_Str" + className,e);
  }
catch (  IllegalAccessException e) {
    throw new PlutoConfigurationException("String_Node_Str" + className,e);
  }
}

Fixed version (ground truth):
/** 
 * Private constructor that prevents external instantiation. We must modify the context class loader in order for the Configuration utility to find the properties file.
 * @throws PlutoConfigurationException  if fail to instantiate portletapplication descriptor service.
 */
private PortletDescriptorRegistry() throws PlutoConfigurationException {
  String className=Configuration.getPortletAppDescriptorServiceImpl();
  try {
    Class clazz=Class.forName(className);
    portletDDService=(PortletAppDescriptorService)clazz.newInstance();
  }
 catch (  ClassNotFoundException ex) {
    throw new PlutoConfigurationException("String_Node_Str" + className,ex);
  }
catch (  InstantiationException ex) {
    throw new PlutoConfigurationException("String_Node_Str" + className,ex);
  }
catch (  IllegalAccessException ex) {
    throw new PlutoConfigurationException("String_Node_Str" + className,ex);
  }
}
Program: 90700
Project: 90700
Buggy source:
/** 
 * Retrieve the Portlet Application Deployment Descriptor for the given servlet context.  Create it if it does not allready exist.
 * @param context
 * @return The portlet application deployment descriptor.
 * @throws PortletContainerException
 */
public PortletAppDD getPortletAppDD(ServletContext context) throws PortletContainerException {
  PortletAppDD dd=(PortletAppDD)cache.get(context);
  if (dd == null) {
    dd=createDefinition(context);
    cache.put(context,dd);
  }
  return dd;
}

Fixed version (ground truth):
/** 
 * Retrieve the Portlet Application Deployment Descriptor for the given servlet context.  Create it if it does not allready exist.
 * @param servletContext  the servlet context.
 * @return The portlet application deployment descriptor.
 * @throws PortletContainerException
 */
public PortletAppDD getPortletAppDD(ServletContext servletContext) throws PortletContainerException {
  PortletAppDD portletAppDD=(PortletAppDD)cache.get(servletContext);
  if (portletAppDD == null) {
    portletAppDD=createDefinition(servletContext);
    cache.put(servletContext,portletAppDD);
  }
  return portletAppDD;
}
Program: 90701
Project: 90701
Buggy source:
/** 
 * Create the portlet.xml deployment descriptor representation.
 * @param ctx the servlet context for which the DD is requested.
 * @return the Portlet Application Deployment Descriptor info.
 * @throws org.apache.pluto.PortletContainerException
 */
private PortletAppDD createDefinition(ServletContext ctx) throws PortletContainerException {
  PortletAppDD app=null;
  try {
    InputStream in=ctx.getResourceAsStream(PORTLET_XML);
    app=this.portletDDService.read(in);
  }
 catch (  IOException io) {
    throw new PortletContainerException(EXCEPTIONS.getString("String_Node_Str",new String[]{ctx.getServletContextName()}),io);
  }
  return app;
}

Fixed version (ground truth):
/** 
 * Creates the portlet.xml deployment descriptor representation.
 * @param servletContext  the servlet context for which the DD is requested.
 * @return the Portlet Application Deployment Descriptor.
 * @throws PortletContainerException
 */
private PortletAppDD createDefinition(ServletContext servletContext) throws PortletContainerException {
  PortletAppDD portletAppDD=null;
  try {
    InputStream in=servletContext.getResourceAsStream(PORTLET_XML);
    portletAppDD=portletDDService.read(in);
  }
 catch (  IOException ex) {
    throw new PortletContainerException(EXCEPTIONS.getString("String_Node_Str",new String[]{servletContext.getServletContextName()}),ex);
  }
  return portletAppDD;
}
Program: 90702
Project: 90702
Buggy source:
/** 
 * Stores the portlet preferences to a persistent storage.
 * @throws ValidatorException  if the portlet preferences are not valid.
 * @throws IOException  if an error occurs with the persistence mechanism.
 */
public void store() throws IOException, ValidatorException {
  if (!Constants.METHOD_ACTION.equals(methodId)) {
    throw new IllegalStateException("String_Node_Str");
  }
  String validatorClass=window.getPortletEntity().getPortletDefinition().getPortletPreferences().getPreferencesValidator();
  if (validatorClass != null) {
    ClassLoader loader=Thread.currentThread().getContextClassLoader();
    try {
      Class clazz=loader.loadClass(validatorClass);
      PreferencesValidator validator=(PreferencesValidator)clazz.newInstance();
      validator.validate(this);
    }
 catch (    InstantiationException ex) {
      LOG.error("String_Node_Str",ex);
      throw new ValidatorException(ex,null);
    }
catch (    IllegalAccessException ex) {
      LOG.error("String_Node_Str",ex);
      throw new ValidatorException(ex,null);
    }
catch (    ClassNotFoundException ex) {
      LOG.error("String_Node_Str",ex);
      throw new ValidatorException(ex,null);
    }
catch (    ValidatorException ex) {
      LOG.error("String_Node_Str" + ex.getMessage());
      throw ex;
    }
  }
  PortletPreference[] prefs=(PortletPreference[])new ArrayList(preferences.values()).toArray(new PortletPreference[preferences.size()]);
  try {
    preferencesService.store(window,request,prefs);
  }
 catch (  PortletContainerException ex) {
    LOG.error("String_Node_Str",ex);
    throw new IOException("String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Stores the portlet preferences to a persistent storage.
 * @throws ValidatorException  if the portlet preferences are not valid.
 * @throws IOException  if an error occurs with the persistence mechanism.
 */
public void store() throws IOException, ValidatorException {
  if (!Constants.METHOD_ACTION.equals(methodId)) {
    throw new IllegalStateException("String_Node_Str");
  }
  PreferencesValidator validator=window.getPortletEntity().getPreferencesValidator();
  if (validator != null) {
    validator.validate(this);
  }
  PortletPreference[] prefs=(PortletPreference[])new ArrayList(preferences.values()).toArray(new PortletPreference[preferences.size()]);
  try {
    preferencesService.store(window,request,prefs);
  }
 catch (  PortletContainerException ex) {
    LOG.error("String_Node_Str",ex);
    throw new IOException("String_Node_Str" + ex.getMessage());
  }
}
Program: 90703
Project: 90703
Buggy source:
/** 
 * Stores the portlet preferences to a persistent storage. If a preferences validator is defined for this portlet, this method firstly validates the portlet preferences.
 * @throws ValidatorException  if the portlet preferences are not valid.
 * @throws IOException  if an error occurs with the persistence mechanism.
 */
public void store() throws IOException, ValidatorException {
  if (!Constants.METHOD_ACTION.equals(methodId)) {
    throw new IllegalStateException("String_Node_Str");
  }
  PreferencesValidator validator=window.getPortletEntity().getPreferencesValidator();
  if (validator != null) {
    validator.validate(this);
  }
  PortletPreference[] prefs=(PortletPreference[])(new ArrayList(preferences.values())).toArray(new PortletPreference[preferences.size()]);
  try {
    preferencesService.store(window,request,prefs);
  }
 catch (  PortletContainerException ex) {
    LOG.error("String_Node_Str",ex);
    throw new IOException("String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Stores the portlet preferences to a persistent storage. This method should only be invoked within <code>processAction()</code> method.
 * @see #internalStore()
 * @throws IllegalStateException  if this method is not invoked within<code>processAction()</code> method.
 * @throws ValidatorException  if the portlet preferences are not valid.
 * @throws IOException  if an error occurs with the persistence mechanism.
 */
public void store() throws IOException, ValidatorException {
  if (!Constants.METHOD_ACTION.equals(methodId)) {
    throw new IllegalStateException("String_Node_Str");
  }
  internalStore();
}
Program: 90705
Project: 90705
Buggy source:
/** 
 * FIXME: portlet preference method ID!
 */
public PortletPreferences getPreferences(){
  if (portletPreferences == null) {
    portletPreferences=new PortletPreferencesImpl(getContainer(),getWindow(),this,Constants.METHOD_ACTION);
  }
  return portletPreferences;
}

Fixed version (ground truth):
/** 
 * FIXME: portlet preference method ID!
 */
public PortletPreferences getPreferences(){
  if (portletPreferences == null) {
    portletPreferences=new PortletPreferencesImpl(getContainer(),getWindow(),this,Constants.METHOD_RENDER);
  }
  return portletPreferences;
}
Program: 90706
Project: 90706
Buggy source:
public Object getAttribute(String name,int scope){
  ArgumentUtility.validateNotNull("String_Node_Str",name);
  if (scope == PortletSession.APPLICATION_SCOPE) {
    return httpSession.getAttribute(name);
  }
 else {
    String key=createPortletScopedId(name);
    Object attribute=httpSession.getAttribute(key);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + key);
      LOG.debug("String_Node_Str" + attribute);
      Enumeration enumer=httpSession.getAttributeNames();
      while (enumer.hasMoreElements()) {
        LOG.debug("String_Node_Str" + enumer.nextElement());
      }
    }
    if (attribute == null) {
      attribute=httpSession.getAttribute(name);
    }
    return attribute;
  }
}

Fixed version (ground truth):
/** 
 * Returns the attribute of the specified name under the given scope.
 * @param name  the attribute name.
 * @param scope  the scope under which the attribute object is stored.
 * @return the attribute object.
 */
public Object getAttribute(String name,int scope){
  ArgumentUtility.validateNotNull("String_Node_Str",name);
  if (scope == PortletSession.APPLICATION_SCOPE) {
    return httpSession.getAttribute(name);
  }
 else {
    String key=createPortletScopedId(name);
    Object attribute=httpSession.getAttribute(key);
    return attribute;
  }
}
Program: 90707
Project: 90707
Buggy source:
public Enumeration getAttributeNames(int scope){
  if (scope == PortletSession.APPLICATION_SCOPE) {
    return httpSession.getAttributeNames();
  }
 else {
    Enumeration attributes=httpSession.getAttributeNames();
    Vector portletAttributes=new Vector();
    while (attributes.hasMoreElements()) {
      String attribute=(String)attributes.nextElement();
      int scp=PortletSessionUtil.decodeScope(attribute);
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str" + attribute);
        LOG.debug("String_Node_Str" + (scp == PortletSession.PORTLET_SCOPE));
      }
      if (scp == PortletSession.PORTLET_SCOPE) {
        portletAttributes.add(PortletSessionUtil.decodeAttributeName(attribute));
      }
    }
    return portletAttributes.elements();
  }
}

Fixed version (ground truth):
public Enumeration getAttributeNames(int scope){
  if (scope == PortletSession.APPLICATION_SCOPE) {
    return httpSession.getAttributeNames();
  }
 else {
    Vector portletScopedNames=new Vector();
    for (Enumeration en=httpSession.getAttributeNames(); en.hasMoreElements(); ) {
      String name=(String)en.nextElement();
      if (isInCurrentPortletScope(name)) {
        portletScopedNames.add(PortletSessionUtil.decodeAttributeName(name));
      }
    }
    return portletScopedNames.elements();
  }
}
Program: 90708
Project: 90708
Buggy source:
/** 
 * Creates portlet-scoped ID for the specified attribute name.
 * @param name  the attribute name.
 * @return portlet-scoped ID for the attribute name.
 */
private String createPortletScopedId(String name){
  StringBuffer buffer=new StringBuffer();
  buffer.append("String_Node_Str");
  buffer.append(internalPortletWindow.getId()).append("String_Node_Str");
  buffer.append(name);
  return buffer.toString();
}

Fixed version (ground truth):
/** 
 * Creates portlet-scoped ID for the specified attribute name. Portlet-scoped ID for a given attribute name has the following form: <code>javax.portlet.p.&lt;ID&gt;?&lt;name&gt;</code> where <code>ID</code> is a unique identification for the portlet window (assigned by the portal/portlet-container) that must not contain a '?' character. <code>name</code> is the attribute name. <p> Refer to Portlet Specification PLT. 15.3 for more details. </p>
 * @param name  the attribute name.
 * @return portlet-scoped ID for the attribute name.
 */
private String createPortletScopedId(String name){
  StringBuffer buffer=new StringBuffer();
  buffer.append(PORTLET_SCOPE_NAMESPACE);
  buffer.append(internalPortletWindow.getId());
  buffer.append(ID_NAME_SEPARATOR);
  buffer.append(name);
  return buffer.toString();
}
Program: 90709
Project: 90709
Buggy source:
/** 
 * Override of toString() that prints out  name and values of fields.
 * @see java.lang.Object#toString()
 */
public String toString(){
  StringBuffer str=new StringBuffer();
  str.append(getClass().getName());
  str.append("String_Node_Str");
  str.append("String_Node_Str" + name + "String_Node_Str");
  for (int i=0; i < values.length; i++) {
    str.append("String_Node_Str" + i + "String_Node_Str"+ values[i]);
    if (i < values.length) {
      str.append("String_Node_Str");
    }
  }
  str.append("String_Node_Str");
  str.append("String_Node_Str" + readOnly);
  str.append("String_Node_Str");
  return str.toString();
}

Fixed version (ground truth):
/** 
 * Override of toString() that prints out  name and values of fields.
 * @see java.lang.Object#toString()
 */
public String toString(){
  StringBuffer buffer=new StringBuffer();
  buffer.append(getClass().getName());
  buffer.append("String_Node_Str");
  buffer.append("String_Node_Str" + name + "String_Node_Str");
  for (int i=0; i < values.length; i++) {
    buffer.append("String_Node_Str" + i + "String_Node_Str"+ values[i]);
  }
  buffer.append("String_Node_Str");
  buffer.append("String_Node_Str" + readOnly);
  buffer.append("String_Node_Str");
  return buffer.toString();
}
Program: 90710
Project: 90710
Buggy source:
public PortletPreferenceImpl(String name,String[] values,boolean readOnly){
  this.name=name;
  this.values=values;
  this.readOnly=readOnly;
}

Fixed version (ground truth):
/** 
 * FIXME: change to private!
 */
public PortletPreferenceImpl(){
}
Program: 90711
Project: 90711
Buggy source:
public void reset(String key) throws ReadOnlyException {
  if (isReadOnly(key)) {
    throw new ReadOnlyException(EXCEPTIONS.getString("String_Node_Str","String_Node_Str"));
  }
  for (int i=0; i < defaultPreferences.length; i++) {
    if (key.equals(defaultPreferences[i].getName())) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str" + key);
      }
      preferences.put(key,defaultPreferences[i]);
      return;
    }
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + key);
  }
}

Fixed version (ground truth):
public void reset(String key) throws ReadOnlyException {
  if (isReadOnly(key)) {
    throw new ReadOnlyException(EXCEPTIONS.getString("String_Node_Str","String_Node_Str"));
  }
  boolean resetDone=false;
  for (int i=0; !resetDone && i < defaultPreferences.length; i++) {
    if (key.equals(defaultPreferences[i].getName())) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str" + key);
      }
      preferences.put(key,(PortletPreference)defaultPreferences[i].clone());
      resetDone=true;
    }
  }
  if (!resetDone) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + key);
    }
    preferences.remove(key);
  }
}
Program: 90712
Project: 90712
Buggy source:
/** 
 * Returns the string representation of this object. Preferences are separated by ';' character, while values in one preference are separated by ',' character.
 * @return the string representation of this object.
 */
public String toString(){
  StringBuffer buffer=new StringBuffer("String_Node_Str");
  for (Enumeration en=getNames(); en.hasMoreElements(); ) {
    String name=(String)en.nextElement();
    buffer.append(name).append("String_Node_Str");
    String[] values=getValues(name,null);
    if (values != null) {
      for (int i=0; i < values.length; i++) {
        buffer.append(values[i]).append("String_Node_Str");
      }
    }
 else {
      buffer.append("String_Node_Str");
    }
    buffer.append("String_Node_Str");
    buffer.append(isReadOnly(name));
    buffer.append("String_Node_Str");
  }
  buffer.append("String_Node_Str");
  return buffer.toString();
}

Fixed version (ground truth):
/** 
 * Returns the string representation of this object. Preferences are separated by ';' character, while values in one preference are separated by ',' character.
 * @return the string representation of this object.
 */
public String toString(){
  StringBuffer buffer=new StringBuffer();
  buffer.append(getClass().getName()).append("String_Node_Str");
  for (Enumeration en=getNames(); en.hasMoreElements(); ) {
    String name=(String)en.nextElement();
    buffer.append(name).append("String_Node_Str");
    String[] values=getValues(name,null);
    if (values != null) {
      for (int i=0; i < values.length; i++) {
        buffer.append(values[i]).append("String_Node_Str");
      }
    }
 else {
      buffer.append("String_Node_Str");
    }
    buffer.append("String_Node_Str");
    buffer.append(isReadOnly(name));
    buffer.append("String_Node_Str");
  }
  buffer.append("String_Node_Str");
  return buffer.toString();
}
Program: 90713
Project: 90713
Buggy source:
/** 
 * Retrieve an invoker for the specified PortletWindow.
 * @param window the InternalPortletWindow used for invocation
 * @return an invoker which can be used to service the indicated portlet
 */
PortletInvokerService getPortletInvokerService(InternalPortletWindow window);

Fixed version (ground truth):
/** 
 * Returns an invoker for the specified PortletWindow.
 * @param portletWindow  the InternalPortletWindow used for invocation.
 * @return an invoker which can be used to service the indicated portlet.
 */
PortletInvokerService getPortletInvokerService(InternalPortletWindow portletWindow);
Program: 90714
Project: 90714
Buggy source:
PortletPreferencesService getPortletPreferencesService();

Fixed version (ground truth):
/** 
 * Returns the portlet preferences service implementation.
 * @return the portlet preferences service implementation.
 */
PortletPreferencesService getPortletPreferencesService();
Program: 90715
Project: 90715
Buggy source:
public PortletInvokerService getPortletInvokerService(InternalPortletWindow window){
  return null;
}

Fixed version (ground truth):
/** 
 * TODO:
 */
public PortletInvokerService getPortletInvokerService(InternalPortletWindow window){
  return null;
}
Program: 90716
Project: 90716
Buggy source:
public PortletEnvironmentService getPortletEnvironmentService(){
  return null;
}

Fixed version (ground truth):
/** 
 * TODO:
 */
public PortletEnvironmentService getPortletEnvironmentService(){
  return null;
}
Program: 90717
Project: 90717
Buggy source:
public DefaultOptionalContainerServices(OptionalContainerServices root){
  this();
  if (root.getPortletPreferencesService() != null) {
    this.preferenceService=root.getPortletPreferencesService();
  }
}

Fixed version (ground truth):
/** 
 * Constructs an instance using specified optional container services implementation. If the portlet preferences service is provided, it will be used. Otherwise, the default portlet preferences service will be used.
 * @param root  the root optional container services implementation.
 */
public DefaultOptionalContainerServices(OptionalContainerServices root){
  if (root.getPortletPreferencesService() != null) {
    preferenceService=root.getPortletPreferencesService();
  }
 else {
    preferenceService=new DefaultPortletPreferencesService();
  }
}
Program: 90718
Project: 90718
Buggy source:
String getName();

Fixed version (ground truth):
/** 
 * Returns the name of this portlet preference.
 * @return the name of this portlet preference.
 */
public String getName();
Program: 90719
Project: 90719
Buggy source:
boolean isReadOnly();

Fixed version (ground truth):
/** 
 * Returns true if this portlet preference is marked as read-only.
 * @return true if this portlet preference is marked as read-only.
 */
public boolean isReadOnly();
Program: 90720
Project: 90720
Buggy source:
String[] getValues();

Fixed version (ground truth):
/** 
 * Returns the values of this portlet preference, which is a string array.
 * @return the values of this portlet preference as a string array.
 */
public String[] getValues();
Program: 90721
Project: 90721
Buggy source:
void setValues(String[] values);

Fixed version (ground truth):
/** 
 * Sets values of this portlet preference.
 * @param values  values of this portlet preference to set.
 */
public void setValues(String[] values);
Program: 90722
Project: 90722
Buggy source:
private void load(){
  String context=window.getContextPath();
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + context);
  }
  ServletContext ctx=this.ctx.getContext(context);
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + ctx);
  }
  try {
    PortletAppDD appDD=PortletDescriptorRegistry.getRegistry().getPortletAppDD(ctx);
    Iterator dds=appDD.getPortlets().iterator();
    while (dds.hasNext()) {
      PortletDD pd=(PortletDD)dds.next();
      if (pd.getPortletName().equals(window.getPortletName())) {
        dd=pd;
      }
    }
  }
 catch (  PortletContainerException e) {
    String msg="String_Node_Str";
    LOG.error(msg,e);
    throw new NullPointerException(msg + e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Loads the portlet definition.
 */
private void load(){
  String contextPath=portletWindow.getContextPath();
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + contextPath);
  }
  ServletContext crossContext=servletContext.getContext(contextPath);
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + crossContext);
  }
  try {
    PortletAppDD appDD=PortletDescriptorRegistry.getRegistry().getPortletAppDD(crossContext);
    for (Iterator it=appDD.getPortlets().iterator(); it.hasNext(); ) {
      PortletDD portletDD=(PortletDD)it.next();
      if (portletDD.getPortletName().equals(portletWindow.getPortletName())) {
        portletDefinition=portletDD;
        break;
      }
    }
  }
 catch (  PortletContainerException ex) {
    String message="String_Node_Str" + ex.getMessage();
    LOG.error(message,ex);
    throw new NullPointerException(message);
  }
}
Program: 90723
Project: 90723
Buggy source:
/** 
 * Returns the portlet description The return value cannot be NULL.
 * @return the portlet description
 */
public PortletDD getPortletDefinition(){
  if (dd == null) {
    load();
  }
  return dd;
}

Fixed version (ground truth):
/** 
 * Returns the portlet description. The return value cannot be NULL.
 * @return the portlet description.
 */
public PortletDD getPortletDefinition(){
  if (portletDefinition == null) {
    load();
  }
  return portletDefinition;
}
Program: 90724
Project: 90724
Buggy source:
public String getControllerServletUri(){
  return PREFIX + window.getPortletName();
}

Fixed version (ground truth):
/** 
 * Returns the URI to the controller servlet that wraps this portlet.
 * @return the URI to the controller servlet that wraps this portlet.
 */
public String getControllerServletUri(){
  return PREFIX + portletWindow.getPortletName();
}
Program: 90725
Project: 90725
Buggy source:
/** 
 * Returns all preferences of this portlet The return value cannot be NULL.
 * @return the preference set
 */
public PortletPreference[] getDefaultPreferences(){
  if (prefs == null) {
    PortletDD dd=getPortletDefinition();
    PortletPreferencesDD ppdd=dd.getPortletPreferences();
    if (ppdd != null) {
      prefs=new PortletPreference[ppdd.getPortletPreferences().size()];
      Iterator pds=ppdd.getPortletPreferences().iterator();
      for (int i=0; pds.hasNext(); i++) {
        PortletPreferenceDD pd=(PortletPreferenceDD)pds.next();
        String[] values=(String[])pd.getValues().toArray(new String[pd.getValues().size()]);
        prefs[i]=new PortletPreferenceImpl(pd.getName(),values);
      }
    }
  }
  return prefs;
}

Fixed version (ground truth):
/** 
 * Returns all preferences of this portlet The return value cannot be NULL.
 * @return the preference set
 */
public PortletPreference[] getDefaultPreferences(){
  if (defaultPreferences == null) {
    PortletDD portletDD=getPortletDefinition();
    PortletPreferencesDD prefsDD=portletDD.getPortletPreferences();
    if (prefsDD != null) {
      List prefs=new ArrayList();
      for (Iterator it=prefsDD.getPortletPreferences().iterator(); it.hasNext(); ) {
        PortletPreferenceDD prefDD=(PortletPreferenceDD)it.next();
        String[] values=(String[])prefDD.getValues().toArray(new String[prefDD.getValues().size()]);
        PortletPreferenceImpl pref=new PortletPreferenceImpl(prefDD.getName(),values,prefDD.isReadOnly());
        prefs.add(pref);
      }
      defaultPreferences=(PortletPreference[])prefs.toArray(new PortletPreference[prefs.size()]);
    }
  }
  return defaultPreferences;
}
Program: 90726
Project: 90726
Buggy source:
PortletEntity(ServletContext ctx,PortletWindow window){
  this.ctx=ctx;
  this.window=window;
}

Fixed version (ground truth):
PortletEntity(ServletContext servletContext,PortletWindow portletWindow){
  this.servletContext=servletContext;
  this.portletWindow=portletWindow;
}