nus-yam/ex-repair huggingface dataset:
Program: 44125
Project: 44125
Buggy source:
@Test public void testPeriodicAndSizeRotate() throws Exception {
  final int logCount=100;
  final long rotateSize=1024L;
  final SimpleDateFormat fmt=new SimpleDateFormat("String_Node_Str");
  final Calendar cal=Calendar.getInstance();
  String extension="String_Node_Str" + fmt.format(cal.getTimeInMillis());
  PeriodicSizeRotatingFileHandler handler=new PeriodicSizeRotatingFileHandler();
  configureHandlerDefaults(handler);
  handler.setRotateSize(rotateSize);
  handler.setMaxBackupIndex(2);
  handler.setSuffix("String_Node_Str" + fmt.toPattern());
  handler.setFile(logFile);
  for (int i=0; i < logCount; i++) {
    handler.publish(createLogRecord("String_Node_Str",i));
  }
  File rotatedFile1=new File(BASE_LOG_DIR,FILENAME + extension + "String_Node_Str");
  File rotatedFile2=new File(BASE_LOG_DIR,FILENAME + extension + "String_Node_Str");
  Assert.assertTrue(logFile.exists());
  Assert.assertTrue(rotatedFile1.exists());
  Assert.assertTrue(rotatedFile2.exists());
  cal.add(Calendar.DAY_OF_MONTH,1);
  for (int i=0; i < logCount; i++) {
    ExtLogRecord record=createLogRecord("String_Node_Str",i);
    record.setMillis(cal.getTimeInMillis());
    handler.publish(record);
  }
  handler.close();
  extension="String_Node_Str" + fmt.format(cal.getTimeInMillis());
  rotatedFile1=new File(BASE_LOG_DIR,FILENAME + extension + "String_Node_Str");
  rotatedFile2=new File(BASE_LOG_DIR,FILENAME + extension + "String_Node_Str");
  Assert.assertTrue(logFile.exists());
  Assert.assertTrue(rotatedFile1.exists());
  Assert.assertTrue(rotatedFile2.exists());
  Assert.assertTrue(logFile.length() > 0L);
  Assert.assertTrue(rotatedFile1.length() > 0L);
  Assert.assertTrue(rotatedFile2.length() > 0L);
  rotatedFile1.delete();
  rotatedFile2.delete();
}

Fixed version (ground truth):
@Test public void testPeriodicAndSizeRotate() throws Exception {
  for (int i=0; i < supportedPeriods.size(); i++) {
    int j=i - 2;
    if (j < 0)     j=0;
    int handlerPeriod=supportedPeriods.get(i);
    for (; j <= i + 2; j++) {
      if (j >= supportedPeriods.size())       break;
      int logMessagePeriod=supportedPeriods.get(j);
      testPeriodicAndSizeRotate0(handlerPeriod,logMessagePeriod,true);
      testPeriodicAndSizeRotate0(handlerPeriod,logMessagePeriod,false);
    }
  }
}
Program: 44126
Project: 44126
Buggy source:
/** 
 * Construct a new instance.
 */
protected ExtHandler(){
  handlersUpdater.clear(this);
}

Fixed version (ground truth):
/** 
 * Construct a new instance.
 */
protected ExtHandler(){
  handlersUpdater.clear(this);
  super.setErrorManager(DEFAULT_ERROR_MANAGER);
}
Program: 44127
Project: 44127
Buggy source:
protected FastCopyHashMap<String,String> childValue(final Map<String,String> parentValue){
  return new FastCopyHashMap<String,String>(parentValue);
}

Fixed version (ground truth):
@Override protected FastCopyHashMap<String,String> childValue(final FastCopyHashMap<String,String> parentValue){
  return new FastCopyHashMap<String,String>(parentValue);
}
Program: 44128
Project: 44128
Buggy source:
protected FastCopyHashMap<String,String> initialValue(){
  return new FastCopyHashMap<String,String>();
}

Fixed version (ground truth):
@Override protected FastCopyHashMap<String,String> initialValue(){
  return new FastCopyHashMap<String,String>();
}
Program: 44129
Project: 44129
Buggy source:
private void calcNextRollover(final long fromTime){
  if (period == Period.NEVER) {
    nextRollover=Long.MAX_VALUE;
    return;
  }
  nextSuffix=format.format(new Date(fromTime));
  final Calendar calendar=Calendar.getInstance(timeZone);
  calendar.setTimeInMillis(fromTime);
  final Period period=this.period;
switch (period) {
default :
case YEAR:
    calendar.clear(Calendar.MONTH);
case MONTH:
  calendar.clear(Calendar.DAY_OF_MONTH);
calendar.clear(Calendar.WEEK_OF_MONTH);
case WEEK:
calendar.clear(Calendar.DAY_OF_WEEK);
calendar.clear(Calendar.DAY_OF_WEEK_IN_MONTH);
case DAY:
calendar.clear(Calendar.HOUR_OF_DAY);
case HALF_DAY:
calendar.clear(Calendar.HOUR);
case HOUR:
calendar.clear(Calendar.MINUTE);
case MINUTE:
calendar.clear(Calendar.SECOND);
calendar.clear(Calendar.MILLISECOND);
}
switch (period) {
case YEAR:
calendar.add(Calendar.YEAR,1);
break;
case MONTH:
calendar.add(Calendar.MONTH,1);
break;
case WEEK:
calendar.add(Calendar.WEEK_OF_YEAR,1);
break;
case DAY:
calendar.add(Calendar.DAY_OF_MONTH,1);
break;
case HALF_DAY:
calendar.add(Calendar.AM_PM,1);
break;
case HOUR:
calendar.add(Calendar.HOUR,1);
break;
case MINUTE:
calendar.add(Calendar.MINUTE,1);
break;
}
nextRollover=calendar.getTimeInMillis();
}

Fixed version (ground truth):
private void calcNextRollover(final long fromTime){
  if (period == Period.NEVER) {
    nextRollover=Long.MAX_VALUE;
    return;
  }
  nextSuffix=format.format(new Date(fromTime));
  final Calendar calendar=Calendar.getInstance(timeZone);
  calendar.setTimeInMillis(fromTime);
  final Period period=this.period;
switch (period) {
default :
case YEAR:
    calendar.clear(Calendar.MONTH);
case MONTH:
  calendar.clear(Calendar.DAY_OF_MONTH);
calendar.clear(Calendar.WEEK_OF_MONTH);
case WEEK:
calendar.clear(Calendar.DAY_OF_WEEK);
calendar.clear(Calendar.DAY_OF_WEEK_IN_MONTH);
case DAY:
calendar.set(Calendar.HOUR_OF_DAY,0);
case HALF_DAY:
calendar.clear(Calendar.HOUR);
case HOUR:
calendar.clear(Calendar.MINUTE);
case MINUTE:
calendar.clear(Calendar.SECOND);
calendar.clear(Calendar.MILLISECOND);
}
switch (period) {
case YEAR:
calendar.add(Calendar.YEAR,1);
break;
case MONTH:
calendar.add(Calendar.MONTH,1);
break;
case WEEK:
calendar.add(Calendar.WEEK_OF_YEAR,1);
break;
case DAY:
calendar.add(Calendar.DAY_OF_MONTH,1);
break;
case HALF_DAY:
calendar.add(Calendar.AM_PM,1);
break;
case HOUR:
calendar.add(Calendar.HOUR,1);
break;
case MINUTE:
calendar.add(Calendar.MINUTE,1);
break;
}
nextRollover=calendar.getTimeInMillis();
}
Program: 44130
Project: 44130
Buggy source:
public Logger run(){
  final Logger logger=new Logger(LoggerNode.this,fullName);
  logger.setLevel(null);
  return logger;
}

Fixed version (ground truth):
public Logger run(){
  final Logger logger=new Logger(LoggerNode.this,fullName);
  return logger;
}
Program: 44131
Project: 44131
Buggy source:
Logger createLogger(){
  final SecurityManager sm=System.getSecurityManager();
  if (sm != null) {
    return AccessController.doPrivileged(new PrivilegedAction<Logger>(){
      public Logger run(){
        final Logger logger=new Logger(LoggerNode.this,fullName);
        logger.setLevel(null);
        return logger;
      }
    }
);
  }
 else {
    final Logger logger=new Logger(this,fullName);
    logger.setLevel(null);
    return logger;
  }
}

Fixed version (ground truth):
Logger createLogger(){
  final SecurityManager sm=System.getSecurityManager();
  if (sm != null) {
    return AccessController.doPrivileged(new PrivilegedAction<Logger>(){
      public Logger run(){
        final Logger logger=new Logger(LoggerNode.this,fullName);
        return logger;
      }
    }
);
  }
 else {
    final Logger logger=new Logger(this,fullName);
    return logger;
  }
}
Program: 44132
Project: 44132
Buggy source:
/** 
 * Construct a child instance.
 * @param context the logmanager
 * @param parent the parent node
 * @param nodeName the name of this subnode
 */
private LoggerNode(LogContext context,LoggerNode parent,String nodeName){
  nodeName=nodeName.trim();
  if (nodeName.length() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.parent=parent;
  handlersUpdater.clear(this);
  if (parent.parent == null) {
    fullName=nodeName;
  }
 else {
    fullName=parent.fullName + "String_Node_Str" + nodeName;
  }
  this.context=context;
}

Fixed version (ground truth):
/** 
 * Construct a child instance.
 * @param context the logmanager
 * @param parent the parent node
 * @param nodeName the name of this subnode
 */
private LoggerNode(LogContext context,LoggerNode parent,String nodeName){
  nodeName=nodeName.trim();
  if (nodeName.length() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.parent=parent;
  handlersUpdater.clear(this);
  if (parent.parent == null) {
    fullName=nodeName;
  }
 else {
    fullName=parent.fullName + "String_Node_Str" + nodeName;
  }
  this.context=context;
  effectiveLevel=parent.effectiveLevel;
}
Program: 44137
Project: 44137
Buggy source:
/** 
 * Publish an   {@code ExtLogRecord}. <p/> The logging request was made initially to a Logger object, which initialized the LogRecord and forwarded it here. <p/> The   {@code ExtHandler} is responsible for formatting the message, when and if necessary. The formatting shouldinclude localization.
 * @param record the log record to publish
 */
public abstract void publish(final ExtLogRecord record);

Fixed version (ground truth):
/** 
 * Publish an   {@code ExtLogRecord}. <p/> The logging request was made initially to a Logger object, which initialized the LogRecord and forwarded it here. <p/> The   {@code ExtHandler} is responsible for formatting the message, when and if necessary. The formatting shouldinclude localization.
 * @param record the log record to publish
 */
public final void publish(final ExtLogRecord record){
  if (record != null && isLoggable(record)) {
    doPublish(record);
  }
}
Program: 44138
Project: 44138
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void setOutputStream(final OutputStream outputStream){
  if (outputStream == null || outputStream instanceof UncloseableOutputStream) {
    super.setOutputStream(outputStream);
  }
 else {
    super.setOutputStream(new UncloseableOutputStream(outputStream));
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void setOutputStream(final OutputStream outputStream){
  super.setOutputStream(wrap(outputStream));
}
Program: 44139
Project: 44139
Buggy source:
/** 
 * Construct a new instance.
 * @param target the target to write to, or {@code null} to start with an uninitialized target
 * @param formatter the formatter to use
 */
public ConsoleHandler(final Target target,final Formatter formatter){
  super(targets.get(target),formatter);
}

Fixed version (ground truth):
/** 
 * Construct a new instance.
 * @param target the target to write to, or {@code null} to start with an uninitialized target
 * @param formatter the formatter to use
 */
public ConsoleHandler(final Target target,final Formatter formatter){
  super(wrap(targets.get(target)),formatter);
}
Program: 44140
Project: 44140
Buggy source:
/** 
 * Set the output file.
 * @param file the file
 * @throws FileNotFoundException if an error occurs opening the file
 */
public void setFile(File file) throws FileNotFoundException {
synchronized (outputLock) {
    if (file == null) {
      setOutputStream(null);
    }
    final File parentFile=file.getParentFile();
    if (parentFile != null) {
      parentFile.mkdirs();
    }
    boolean ok=false;
    final FileOutputStream fos=new FileOutputStream(file,append);
    try {
      setOutputStream(fos);
      this.file=file;
    }
  finally {
      if (!ok) {
        safeClose(fos);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Set the output file.
 * @param file the file
 * @throws FileNotFoundException if an error occurs opening the file
 */
public void setFile(File file) throws FileNotFoundException {
synchronized (outputLock) {
    if (file == null) {
      setOutputStream(null);
      return;
    }
    final File parentFile=file.getParentFile();
    if (parentFile != null) {
      parentFile.mkdirs();
    }
    boolean ok=false;
    final FileOutputStream fos=new FileOutputStream(file,append);
    try {
      setOutputStream(fos);
      this.file=file;
      ok=true;
    }
  finally {
      if (!ok) {
        safeClose(fos);
      }
    }
  }
}
Program: 44141
Project: 44141
Buggy source:
/** 
 * Recursively update the effective log level of all log instances on all children.  The recursion depth will be proportionate to the log node nesting depth so stack use should not be an issue.  Must only be called while the log context's level change lock is held.
 * @param newLevel the new effective level
 */
void updateChildEffectiveLevel(int newLevel){
  for (  LoggerNode node : children.values()) {
    if (node != null) {
      final Logger instance=node.getLogger();
      if (instance != null) {
        instance.setEffectiveLevel(newLevel);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Recursively update the effective log level of all log instances on all children.  The recursion depth will be proportionate to the log node nesting depth so stack use should not be an issue.  Must only be called while the log context's level change lock is held.
 * @param newLevel the new effective level
 */
void updateChildEffectiveLevel(int newLevel){
  for (  LoggerNode node : children.values()) {
    if (node != null) {
      final Logger instance=node.getLogger();
      if (instance != null) {
        instance.setEffectiveLevel(newLevel);
      }
 else {
        node.updateChildEffectiveLevel(newLevel);
      }
    }
  }
}
Program: 44142
Project: 44142
Buggy source:
/** 
 * Create a wrapper that exposes the handler's close and flush methods via the I/O API.
 * @param handler the logging handler
 * @return the wrapper
 */
public static Flushable wrap(final Handler handler){
  return handler instanceof Flushable ? (Flushable)handler : new Flushable(){
    public void close(){
      handler.close();
    }
    public void flush(){
      handler.flush();
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Create a wrapper that exposes the handler's close and flush methods via the I/O API.
 * @param handler the logging handler
 * @return the wrapper
 */
public static FlushableCloseable wrap(final Handler handler){
  return handler instanceof FlushableCloseable ? (FlushableCloseable)handler : new FlushableCloseable(){
    public void close(){
      handler.close();
    }
    public void flush(){
      handler.flush();
    }
  }
;
}
Program: 44143
Project: 44143
Buggy source:
/** 
 * Get or create a logger instance for this node.
 * @return a logger instance
 */
Logger getOrCreateLogger(){
  final String fullName=this.fullName;
  final LoggerNode parent=this.parent;
  for (; ; ) {
    LoggerRef loggerRef=this.loggerRef;
    if (loggerRef != null) {
      final Logger logger=loggerRef.get();
      if (logger != null) {
        return logger;
      }
    }
    final Logger logger=new Logger(this,fullName);
    if (loggerRefUpdater.compareAndSet(this,null,parent == null ? new StrongLoggerRef(logger) : new WeakLoggerRef(logger))) {
      return logger;
    }
  }
}

Fixed version (ground truth):
/** 
 * Get or create a logger instance for this node.
 * @return a logger instance
 */
Logger getOrCreateLogger(){
  final String fullName=this.fullName;
  final LoggerNode parent=this.parent;
  for (; ; ) {
    final LoggerRef loggerRef=this.loggerRef;
    if (loggerRef != null) {
      final Logger logger=loggerRef.get();
      if (logger != null) {
        return logger;
      }
    }
    final Logger logger=new Logger(this,fullName);
    if (loggerRefUpdater.compareAndSet(this,loggerRef,parent == null ? new StrongLoggerRef(logger) : new WeakLoggerRef(logger))) {
      return logger;
    }
  }
}
Program: 44144
Project: 44144
Buggy source:
public void render(final StringBuilder builder,final ExtLogRecord record){
  final String subject=getSubject(record);
  final int len=subject.length();
  final int minimumWidth=this.minimumWidth;
  final int maximumWidth=this.maximumWidth;
  if (len > maximumWidth) {
    builder.append(subject.substring(len - maximumWidth));
    return;
  }
 else   if (len < minimumWidth) {
    if (leftJustify) {
      builder.append(subject);
      int spaces=minimumWidth - len;
      for (int i=0; i < spaces; i++) {
        builder.append(' ');
      }
    }
 else {
      int spaces=minimumWidth - len;
      for (int i=0; i < spaces; i++) {
        builder.append(' ');
      }
      builder.append(subject);
    }
  }
}

Fixed version (ground truth):
public void render(final StringBuilder builder,final ExtLogRecord record){
  final String subject=getSubject(record);
  final int len=subject.length();
  final int minimumWidth=this.minimumWidth;
  final int maximumWidth=this.maximumWidth;
  if (len > maximumWidth) {
    builder.append(subject.substring(len - maximumWidth));
  }
 else   if (len < minimumWidth) {
    if (leftJustify) {
      builder.append(subject);
      int spaces=minimumWidth - len;
      for (int i=0; i < spaces; i++) {
        builder.append(' ');
      }
    }
 else {
      int spaces=minimumWidth - len;
      for (int i=0; i < spaces; i++) {
        builder.append(' ');
      }
      builder.append(subject);
    }
  }
 else {
    builder.append(subject);
  }
}
Program: 44145
Project: 44145
Buggy source:
private String formatRecord(){
  final ResourceBundle bundle=getResourceBundle();
  String msg=getMessage();
  if (bundle != null) {
    try {
      msg=bundle.getString(msg);
    }
 catch (    MissingResourceException ex) {
    }
  }
  final Object[] parameters=getParameters();
  return parameters != null && parameters.length > 0 && msg.indexOf('{') >= 0 ? MessageFormat.format(msg,parameters) : msg;
}

Fixed version (ground truth):
private String formatRecord(){
  final ResourceBundle bundle=getResourceBundle();
  String msg=getMessage();
  if (bundle != null) {
    try {
      msg=bundle.getString(msg);
    }
 catch (    MissingResourceException ex) {
    }
  }
  final Object[] parameters=getParameters();
  if (parameters == null || parameters.length == 0) {
    return msg;
  }
switch (formatStyle) {
case PRINTF:
{
      return String.format(msg,parameters);
    }
case MESSAGE_FORMAT:
{
    return msg.indexOf('{') >= 0 ? MessageFormat.format(msg,parameters) : msg;
  }
}
return msg;
}
Program: 44146
Project: 44146
Buggy source:
public String getFormattedMessage(){
  if (formattedMessage == null) {
    formattedMessage=formatRecord();
  }
  return formattedMessage;
}

Fixed version (ground truth):
/** 
 * Get the fully formatted log record, with resources resolved and parameters applied.
 * @return the formatted log record
 */
public String getFormattedMessage(){
  if (formattedMessage == null) {
    formattedMessage=formatRecord();
  }
  return formattedMessage;
}
Program: 44147
Project: 44147
Buggy source:
/** 
 * Find the first stack frame below the call to the logger, and populate the log record with that information.
 */
private void calculateCaller(){
  if (!calculateCaller) {
    return;
  }
  calculateCaller=false;
  final StackTraceElement[] stack=new Throwable().getStackTrace();
  boolean found=false;
  for (  StackTraceElement element : stack) {
    final String className=element.getClassName();
    if (found && !loggerClassName.equals(className)) {
      setSourceClassName(className);
      setSourceMethodName(element.getMethodName());
      setSourceLineNumber(element.getLineNumber());
      setSourceFileName(element.getFileName());
      return;
    }
 else {
      found=loggerClassName.equals(className);
    }
  }
  setUnknownCaller();
}

Fixed version (ground truth):
/** 
 * Find the first stack frame below the call to the logger, and populate the log record with that information.
 */
private void calculateCaller(){
  if (!calculateCaller) {
    return;
  }
  calculateCaller=false;
  final StackTraceElement[] stack=new Throwable().getStackTrace();
  boolean found=false;
  for (  StackTraceElement element : stack) {
    final String className=element.getClassName();
    if (found) {
      if (!loggerClassName.equals(className)) {
        setSourceClassName(className);
        setSourceMethodName(element.getMethodName());
        setSourceLineNumber(element.getLineNumber());
        setSourceFileName(element.getFileName());
        return;
      }
    }
 else {
      found=loggerClassName.equals(className);
    }
  }
  setUnknownCaller();
}
Program: 44148
Project: 44148
Buggy source:
/** 
 * Construct a new instance.  Grabs the current NDC immediately.  MDC is deferred.
 * @param level a logging level value
 * @param msg the raw non-localized logging message (may be null)
 */
public ExtLogRecord(java.util.logging.Level level,String msg){
  super(level,msg);
  ndc=NDC.get();
}

Fixed version (ground truth):
/** 
 * Construct a new instance.  Grabs the current NDC immediately.  MDC is deferred.
 * @param level a logging level value
 * @param msg the raw non-localized logging message (may be null)
 */
public ExtLogRecord(java.util.logging.Level level,String msg){
  super(level,msg);
  setSourceClassName(null);
  ndc=NDC.get();
}
Program: 44149
Project: 44149
Buggy source:
void checkAccess(){
  final SecurityManager sm=System.getSecurityManager();
  if (sm != null) {
    sm.checkPermission(CONTROL_PERMISSION);
  }
}

Fixed version (ground truth):
static void checkAccess(){
  final SecurityManager sm=System.getSecurityManager();
  if (sm != null) {
    sm.checkPermission(CONTROL_PERMISSION);
  }
}
Program: 44150
Project: 44150
Buggy source:
public static List<Injector> getDefaultInjectors(Object managed){
  List<Injector> result=new ArrayList<Injector>();
  if (managed instanceof Activity) {
    result.add(new ViewInjector());
    result.add(new ServiceInjector());
    result.add(new IntentExtraInjector());
    result.add(new LayoutInjector());
    result.add(new ObjectInjector());
    result.add(new ResourceInjector());
  }
  if (managed instanceof Fragment) {
    result.add(new ViewInjector());
    result.add(new ServiceInjector());
    result.add(new ResourceInjector());
    result.add(new IntentExtraInjector());
    result.add(new ObjectInjector());
  }
  if (managed instanceof android.app.Fragment) {
    result.add(new ViewInjector());
    result.add(new ServiceInjector());
    result.add(new ResourceInjector());
    result.add(new IntentExtraInjector());
    result.add(new ObjectInjector());
  }
  return result;
}

Fixed version (ground truth):
public static List<Injector> getDefaultInjectors(Object managed){
  List<Injector> result=new ArrayList<Injector>();
  if (managed instanceof Activity) {
    result.add(new ViewInjector());
    result.add(new ServiceInjector());
    result.add(new IntentExtraInjector());
    result.add(new LayoutInjector());
    result.add(new ObjectInjector());
    result.add(new ResourceInjector());
  }
  if (managed instanceof Fragment) {
    result.add(new ViewInjector());
    result.add(new ServiceInjector());
    result.add(new ResourceInjector());
    result.add(new IntentExtraInjector());
    result.add(new ObjectInjector());
  }
  try {
    if (managed instanceof android.app.Fragment) {
      result.add(new ViewInjector());
      result.add(new ServiceInjector());
      result.add(new ResourceInjector());
      result.add(new IntentExtraInjector());
      result.add(new ObjectInjector());
    }
  }
 catch (  NoClassDefFoundError e) {
  }
  return result;
}
Program: 44151
Project: 44151
Buggy source:
/** 
 * Method called by the container to initialize the container.
 * @param context   the android context
 * @param container the roboject container
 * @param managed   the managed instance
 * @param clazz     the managed class (the class of <tt>managed</tt>)
 * @return <code>true</code> if the injector wants to contribute to themanagement of the instance, <code>false</code> otherwise. In this latter case, the injector will be ignored for this instance.
 * @throws RobojectException if the configuration failed.
 */
@Override public boolean configure(Context context,Container container,Object managed,Class<?> clazz) throws RobojectException {
  if (context instanceof Activity) {
    this.activity=(Activity)context;
  }
 else {
    return false;
  }
  this.managed=managed;
  if (managed instanceof Activity) {
    return true;
  }
  if (managed instanceof Fragment) {
    return true;
  }
  if (managed instanceof android.app.Fragment) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Method called by the container to initialize the container.
 * @param context   the android context
 * @param container the roboject container
 * @param managed   the managed instance
 * @param clazz     the managed class (the class of <tt>managed</tt>)
 * @return <code>true</code> if the injector wants to contribute to themanagement of the instance, <code>false</code> otherwise. In this latter case, the injector will be ignored for this instance.
 * @throws RobojectException if the configuration failed.
 */
@Override public boolean configure(Context context,Container container,Object managed,Class<?> clazz) throws RobojectException {
  if (context instanceof Activity) {
    this.activity=(Activity)context;
  }
 else {
    return false;
  }
  this.managed=managed;
  if (managed instanceof Activity) {
    return true;
  }
  if (managed instanceof Fragment) {
    return true;
  }
  try {
    if (managed instanceof android.app.Fragment) {
      return true;
    }
  }
 catch (  NoClassDefFoundError e) {
  }
  return false;
}
Program: 44152
Project: 44152
Buggy source:
@Override public void onCreate(){
  InjectLayout layoutAnnotation=ReflectionUtil.getAnnotation(managed.getClass(),InjectLayout.class);
  if (layoutAnnotation != null) {
    int id=AndroidUtil.getIdentifierFromR(activity,"String_Node_Str",layoutAnnotation.value());
    if (managed instanceof Activity) {
      ((Activity)managed).setContentView(id);
    }
    if (managed instanceof Fragment || managed instanceof android.app.Fragment)     throw new RuntimeException("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void onCreate(){
  InjectLayout layoutAnnotation=ReflectionUtil.getAnnotation(managed.getClass(),InjectLayout.class);
  if (layoutAnnotation != null) {
    int id=AndroidUtil.getIdentifierFromR(activity,"String_Node_Str",layoutAnnotation.value());
    if (managed instanceof Activity) {
      ((Activity)managed).setContentView(id);
    }
    try {
      if (managed instanceof Fragment || managed instanceof android.app.Fragment)       throw new RuntimeException("String_Node_Str");
    }
 catch (    NoClassDefFoundError e) {
    }
  }
}
Program: 44153
Project: 44153
Buggy source:
/** 
 * Method called by the container to initialize the container.
 * @param context   the android context
 * @param container the roboject container
 * @param managed   the managed instance
 * @param clazz     the managed class (the class of <tt>managed</tt>)
 * @return <code>true</code> if the injector wants to contribute to themanagement of the instance, <code>false</code> otherwise. In this latter case, the injector will be ignored for this instance.
 * @throws de.akquinet.android.roboject.RobojectException if the configuration failed.
 */
@Override public boolean configure(Context context,Container container,Object managed,Class<?> clazz) throws RobojectException {
  if (context instanceof Activity) {
    this.activity=(Activity)context;
  }
 else {
    return false;
  }
  this.managed=managed;
  if (managed instanceof Activity) {
    return true;
  }
  if (managed instanceof Fragment) {
    return true;
  }
  if (managed instanceof android.app.Fragment) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Method called by the container to initialize the container.
 * @param context   the android context
 * @param container the roboject container
 * @param managed   the managed instance
 * @param clazz     the managed class (the class of <tt>managed</tt>)
 * @return <code>true</code> if the injector wants to contribute to themanagement of the instance, <code>false</code> otherwise. In this latter case, the injector will be ignored for this instance.
 * @throws de.akquinet.android.roboject.RobojectException if the configuration failed.
 */
@Override public boolean configure(Context context,Container container,Object managed,Class<?> clazz) throws RobojectException {
  if (context instanceof Activity) {
    this.activity=(Activity)context;
  }
 else {
    return false;
  }
  this.managed=managed;
  if (managed instanceof Activity) {
    return true;
  }
  if (managed instanceof Fragment) {
    return true;
  }
  try {
    if (managed instanceof android.app.Fragment) {
      return true;
    }
  }
 catch (  NoClassDefFoundError e) {
  }
  return false;
}
Program: 44154
Project: 44154
Buggy source:
/** 
 * Method called by the container to initialize the container.
 * @param context   the android context
 * @param container the roboject container
 * @param managed   the managed instance
 * @param clazz     the managed class (the class of <tt>managed</tt>)
 * @return <code>true</code> if the injector wants to contribute to themanagement of the instance, <code>false</code> otherwise. In this latter case, the injector will be ignored for this instance.
 * @throws de.akquinet.android.roboject.RobojectException if the configuration failed.
 */
@Override public boolean configure(Context context,Container container,Object managed,Class<?> clazz) throws RobojectException {
  if (context instanceof Activity) {
    this.activity=(Activity)context;
  }
 else {
    return false;
  }
  this.managed=managed;
  if (managed instanceof Activity) {
    return true;
  }
  if (managed instanceof Fragment) {
    return true;
  }
  if (managed instanceof android.app.Fragment) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Method called by the container to initialize the container.
 * @param context   the android context
 * @param container the roboject container
 * @param managed   the managed instance
 * @param clazz     the managed class (the class of <tt>managed</tt>)
 * @return <code>true</code> if the injector wants to contribute to themanagement of the instance, <code>false</code> otherwise. In this latter case, the injector will be ignored for this instance.
 * @throws de.akquinet.android.roboject.RobojectException if the configuration failed.
 */
@Override public boolean configure(Context context,Container container,Object managed,Class<?> clazz) throws RobojectException {
  if (context instanceof Activity) {
    this.activity=(Activity)context;
  }
 else {
    return false;
  }
  this.managed=managed;
  if (managed instanceof Activity) {
    return true;
  }
  if (managed instanceof Fragment) {
    return true;
  }
  try {
    if (managed instanceof android.app.Fragment) {
      return true;
    }
  }
 catch (  NoClassDefFoundError e) {
  }
  return false;
}
Program: 44155
Project: 44155
Buggy source:
/** 
 * Method called by the container to initialize the container.
 * @param context   the android context
 * @param container the roboject container
 * @param managed   the managed instance
 * @param clazz     the managed class (the class of <tt>managed</tt>)
 * @return <code>true</code> if the injector wants to contribute to themanagement of the instance, <code>false</code> otherwise. In this latter case, the injector will be ignored for this instance.
 * @throws de.akquinet.android.roboject.RobojectException if the configuration failed.
 */
@Override public boolean configure(Context context,Container container,Object managed,Class<?> clazz) throws RobojectException {
  if (context instanceof Activity) {
    this.activity=(Activity)context;
  }
 else {
    return false;
  }
  this.managed=managed;
  if (managed instanceof Activity) {
    return true;
  }
  if (managed instanceof Fragment) {
    return true;
  }
  if (managed instanceof android.app.Fragment) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Method called by the container to initialize the container.
 * @param context   the android context
 * @param container the roboject container
 * @param managed   the managed instance
 * @param clazz     the managed class (the class of <tt>managed</tt>)
 * @return <code>true</code> if the injector wants to contribute to themanagement of the instance, <code>false</code> otherwise. In this latter case, the injector will be ignored for this instance.
 * @throws de.akquinet.android.roboject.RobojectException if the configuration failed.
 */
@Override public boolean configure(Context context,Container container,Object managed,Class<?> clazz) throws RobojectException {
  if (context instanceof Activity) {
    this.activity=(Activity)context;
  }
 else {
    return false;
  }
  this.managed=managed;
  if (managed instanceof Activity) {
    return true;
  }
  if (managed instanceof Fragment) {
    return true;
  }
  try {
    if (managed instanceof android.app.Fragment) {
      return true;
    }
  }
 catch (  NoClassDefFoundError e) {
  }
  return false;
}
Program: 44156
Project: 44156
Buggy source:
/** 
 * Method called by the container to initialize the container.
 * @param context   the android context
 * @param container the roboject container
 * @param managed   the managed instance
 * @param clazz     the managed class (the class of <tt>managed</tt>)
 * @return <code>true</code> if the injector wants to contribute to themanagement of the instance, <code>false</code> otherwise. In this latter case, the injector will be ignored for this instance.
 * @throws RobojectException if the configuration failed.
 */
@Override public boolean configure(Context context,Container container,Object managed,Class<?> clazz) throws RobojectException {
  this.context=context;
  this.managed=managed;
  this.container=container;
  if (managed instanceof Activity) {
    return true;
  }
  if (managed instanceof Fragment) {
    return true;
  }
  if (managed instanceof android.app.Fragment) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Method called by the container to initialize the container.
 * @param context   the android context
 * @param container the roboject container
 * @param managed   the managed instance
 * @param clazz     the managed class (the class of <tt>managed</tt>)
 * @return <code>true</code> if the injector wants to contribute to themanagement of the instance, <code>false</code> otherwise. In this latter case, the injector will be ignored for this instance.
 * @throws RobojectException if the configuration failed.
 */
@Override public boolean configure(Context context,Container container,Object managed,Class<?> clazz) throws RobojectException {
  this.context=context;
  this.managed=managed;
  this.container=container;
  if (managed instanceof Activity) {
    return true;
  }
  if (managed instanceof Fragment) {
    return true;
  }
  try {
    if (managed instanceof android.app.Fragment) {
      return true;
    }
  }
 catch (  NoClassDefFoundError e) {
  }
  return false;
}
Program: 44157
Project: 44157
Buggy source:
/** 
 * Method called by the container to initialize the container.
 * @param context   the android context
 * @param container the roboject container
 * @param managed   the managed instance
 * @param clazz     the managed class (the class of <tt>managed</tt>)
 * @return <code>true</code> if the injector wants to contribute to themanagement of the instance, <code>false</code> otherwise. In this latter case, the injector will be ignored for this instance.
 * @throws RobojectException if the configuration failed.
 */
@Override public boolean configure(Context context,Container container,Object managed,Class<?> clazz) throws RobojectException {
  if (context instanceof Activity) {
    this.activity=(Activity)context;
  }
 else {
    return false;
  }
  this.managed=managed;
  if (managed instanceof Activity) {
    return true;
  }
  if (managed instanceof Fragment) {
    return true;
  }
  if (managed instanceof android.app.Fragment) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Method called by the container to initialize the container.
 * @param context   the android context
 * @param container the roboject container
 * @param managed   the managed instance
 * @param clazz     the managed class (the class of <tt>managed</tt>)
 * @return <code>true</code> if the injector wants to contribute to themanagement of the instance, <code>false</code> otherwise. In this latter case, the injector will be ignored for this instance.
 * @throws RobojectException if the configuration failed.
 */
@Override public boolean configure(Context context,Container container,Object managed,Class<?> clazz) throws RobojectException {
  if (context instanceof Activity) {
    this.activity=(Activity)context;
  }
 else {
    return false;
  }
  this.managed=managed;
  if (managed instanceof Activity) {
    return true;
  }
  if (managed instanceof Fragment) {
    return true;
  }
  try {
    if (managed instanceof android.app.Fragment) {
      return true;
    }
  }
 catch (  NoClassDefFoundError e) {
  }
  return false;
}
Program: 44158
Project: 44158
Buggy source:
/** 
 * Contract for subclasses: You need to call super before relying on injections in  {@link #onCreate(Bundle)}.
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  try {
    new Container(this,this,getClass());
  }
 catch (  RobojectException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * Contract for subclasses: You need to call super before relying on injections in   {@link #onCreate(Bundle)}.
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  try {
    new Container(this,this,getClass());
  }
 catch (  RobojectException e) {
    throw new RuntimeException(e);
  }
}
Program: 44160
Project: 44160
Buggy source:
@Override public void onServiceConnected(ComponentName name,IBinder service){
  if (field.getType().isAssignableFrom(service.getClass())) {
    try {
      field.setAccessible(true);
      field.set(managed,service);
    }
 catch (    Exception e) {
      throw new RuntimeException("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
@Override public void onServiceConnected(ComponentName name,IBinder service){
  if (field.getType().isAssignableFrom(service.getClass())) {
    try {
      field.setAccessible(true);
      field.set(managed,service);
    }
 catch (    Exception e) {
      throw new RuntimeException("String_Node_Str",e);
    }
  }
  if (managed instanceof RobojectActivity) {
    ((RobojectActivity)managed).onServiceConnected(name,service);
  }
}
Program: 44161
Project: 44161
Buggy source:
private void injectService(final Field field,Inject annotation){
  Class<? extends Service> androidServiceClass=annotation.value();
  Intent intent=new Intent(context,androidServiceClass);
  context.bindService(intent,new ServiceConnection(){
    @Override public void onServiceConnected(    ComponentName name,    IBinder service){
      if (field.getType().isAssignableFrom(service.getClass())) {
        try {
          field.setAccessible(true);
          field.set(managed,service);
        }
 catch (        Exception e) {
          throw new RuntimeException("String_Node_Str",e);
        }
      }
    }
    @Override public void onServiceDisconnected(    ComponentName name){
      try {
        field.set(managed,null);
      }
 catch (      IllegalArgumentException e) {
      }
catch (      IllegalAccessException e) {
      }
      ServiceInjector.this.managed=null;
    }
  }
,Service.BIND_AUTO_CREATE);
}

Fixed version (ground truth):
private void injectService(final Field field,Inject annotation){
  Class<? extends Service> androidServiceClass=annotation.value();
  Intent intent=new Intent(context,androidServiceClass);
  context.bindService(intent,new ServiceConnection(){
    @Override public void onServiceConnected(    ComponentName name,    IBinder service){
      if (field.getType().isAssignableFrom(service.getClass())) {
        try {
          field.setAccessible(true);
          field.set(managed,service);
        }
 catch (        Exception e) {
          throw new RuntimeException("String_Node_Str",e);
        }
      }
      if (managed instanceof RobojectActivity) {
        ((RobojectActivity)managed).onServiceConnected(name,service);
      }
    }
    @Override public void onServiceDisconnected(    ComponentName name){
      try {
        field.set(managed,null);
      }
 catch (      IllegalArgumentException e) {
      }
catch (      IllegalAccessException e) {
      }
      ServiceInjector.this.managed=null;
    }
  }
,Service.BIND_AUTO_CREATE);
}
Program: 44163
Project: 44163
Buggy source:
private TimeLine generateCustomTimeLine(double[] timeSlices){
  int numberOfSlices=timeSlices.length;
  double startTime=mrsd.getTime() - (timeSlices[numberOfSlices - 1] * DayInMillis * DaysInYear* timescaler);
  double endTime=mrsd.getTime();
  TimeLine timeLine=new TimeLine(startTime,endTime,numberOfSlices);
  return timeLine;
}

Fixed version (ground truth):
private TimeLine generateCustomTimeLine(double[] timeSlices){
  int numberOfSlices=timeSlices.length;
  double firstSlice=timeSlices[0];
  double startTime=mrsd.getTime() - (firstSlice * DayInMillis * DaysInYear* timescaler);
  double endTime=mrsd.getTime();
  return new TimeLine(startTime,endTime,numberOfSlices);
}
Program: 44165
Project: 44165
Buggy source:
private TimeLine generateCustomTimeLine(double[] timeSlices){
  int numberOfSlices=timeSlices.length;
  double startTime=mrsd.getTime() - (timeSlices[numberOfSlices - 1] * DayInMillis * DaysInYear* timescaler);
  double endTime=mrsd.getTime();
  TimeLine timeLine=new TimeLine(startTime,endTime,numberOfSlices);
  return timeLine;
}

Fixed version (ground truth):
private TimeLine generateCustomTimeLine(double[] timeSlices){
  int numberOfSlices=timeSlices.length;
  double firstSlice=timeSlices[0];
  double startTime=mrsd.getTime() - (firstSlice * DayInMillis * DaysInYear* timescaler);
  double endTime=mrsd.getTime();
  return new TimeLine(startTime,endTime,numberOfSlices);
}
Program: 44166
Project: 44166
Buggy source:
public static int newton(int n,int k){
  BigInteger newton=BigInteger.valueOf(1);
  String newtonString=null;
  for (int i=1; i <= k; i++) {
    newton=newton.multiply(BigInteger.valueOf(n - i + 1)).divide(BigInteger.valueOf(i));
    newtonString=newton.toString();
  }
  return Integer.parseInt(newtonString);
}

Fixed version (ground truth):
/** 
 * maps a single value from its range into another interval
 * @param low1, high1 - range of value; low2, high2 - interval
 * @return the mapped value
 */
public static int newton(int n,int k){
  BigInteger newton=BigInteger.valueOf(1);
  String newtonString=null;
  for (int i=1; i <= k; i++) {
    newton=newton.multiply(BigInteger.valueOf(n - i + 1)).divide(BigInteger.valueOf(i));
    newtonString=newton.toString();
  }
  return Integer.parseInt(newtonString);
}
Program: 44167
Project: 44167
Buggy source:
public static double map(double x,double x1,double x2,double y1,double y2){
  double y=((y1 - y2) / (x1 - x2)) * x - ((x2 * y1 - x1 * y2) / (x1 - x2));
  return y;
}

Fixed version (ground truth):
public static double map(double value,double low1,double high1,double low2,double high2){
  return (value - low1) / (high1 - low1) * (high2 - low2) + low2;
}
Program: 44168
Project: 44168
Buggy source:
private boolean checkMccTree(String treeFilename,String coordinatesName) throws FileNotFoundException, IOException, ImportException {
  RootedTree tree=(RootedTree)new NexusImporter(new FileReader(treeFilename)).importNextTree();
  boolean flag=false;
  double nodeCount=Utils.getNodeCount(tree);
  double unannotatedNodeCount=0;
  for (  Node node : tree.getNodes()) {
    if (!tree.isRoot(node)) {
      Double longitude=(Double)node.getAttribute(coordinatesName + 2);
      Double latitude=(Double)node.getAttribute(coordinatesName + 1);
      if (longitude == null || latitude == null) {
        unannotatedNodeCount++;
      }
    }
  }
  if (unannotatedNodeCount == nodeCount) {
    flag=false;
    throw new RuntimeException("String_Node_Str" + coordinatesName + "String_Node_Str");
  }
 else   if (unannotatedNodeCount == 0) {
    flag=true;
  }
 else   if (unannotatedNodeCount < nodeCount) {
    notNull=true;
    System.out.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  return flag;
}

Fixed version (ground truth):
private boolean checkMccTree(String treeFilename,String coordinatesName) throws FileNotFoundException, IOException, ImportException {
  RootedTree tree=(RootedTree)new NexusImporter(new FileReader(treeFilename)).importNextTree();
  boolean flag=false;
  double nodeCount=Utils.getNodeCount(tree);
  double unannotatedNodeCount=0;
  for (  Node node : tree.getNodes()) {
    if (!tree.isRoot(node)) {
      Double longitude=(Double)node.getAttribute(coordinatesName + 2);
      Double latitude=(Double)node.getAttribute(coordinatesName + 1);
      if (longitude == null || latitude == null) {
        unannotatedNodeCount++;
      }
    }
  }
  if (unannotatedNodeCount == nodeCount) {
    flag=false;
    throw new RuntimeException("String_Node_Str" + coordinatesName + "String_Node_Str");
  }
 else   if (unannotatedNodeCount == 0) {
    flag=true;
  }
 else   if (unannotatedNodeCount < nodeCount) {
    notNull=true;
    System.out.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
 else {
    notNull=false;
    throw new RuntimeException("String_Node_Str");
  }
  return flag;
}
Program: 44171
Project: 44171
Buggy source:
private void drawBranches(){
  strokeWeight((float)branchWidth);
  for (  Node node : tree.getNodes()) {
    if (!tree.isRoot(node)) {
      Float longitude=(float)Utils.getDoubleNodeAttribute(node,longitudeName);
      Float latitude=(float)Utils.getDoubleNodeAttribute(node,latitudeName);
      Node parentNode=tree.getParent(node);
      Float parentLongitude=(float)Utils.getDoubleNodeAttribute(parentNode,longitudeName);
      Float parentLatitude=(float)Utils.getDoubleNodeAttribute(parentNode,latitudeName);
      float x0=map(parentLongitude,minX,maxX,0,width);
      float y0=map(parentLatitude,maxY,minY,0,height);
      float x1=map(longitude,minX,maxX,0,width);
      float y1=map(latitude,maxY,minY,0,height);
      double nodeHeight=tree.getHeight(node);
      int red=(int)Utils.map(nodeHeight,0,treeHeightMax,minBranchRedMapping,maxBranchRedMapping);
      int green=(int)Utils.map(nodeHeight,0,treeHeightMax,minBranchGreenMapping,maxBranchGreenMapping);
      int blue=(int)Utils.map(nodeHeight,0,treeHeightMax,minBranchBlueMapping,maxBranchBlueMapping);
      int alpha=(int)Utils.map(nodeHeight,0,treeHeightMax,maxBranchOpacityMapping,minBranchOpacityMapping);
      stroke(red,green,blue,alpha);
      line(x0,y0,x1,y1);
    }
  }
}

Fixed version (ground truth):
private void drawBranches(){
  strokeWeight((float)branchWidth);
  for (  Node node : tree.getNodes()) {
    if (!tree.isRoot(node)) {
      double longitude=Utils.getDoubleNodeAttribute(node,longitudeName);
      double latitude=Utils.getDoubleNodeAttribute(node,latitudeName);
      Node parentNode=tree.getParent(node);
      double parentLongitude=Utils.getDoubleNodeAttribute(parentNode,longitudeName);
      double parentLatitude=Utils.getDoubleNodeAttribute(parentNode,latitudeName);
      double x0=Utils.map(parentLongitude,minX,maxX,0,width);
      double y0=Utils.map(parentLatitude,maxY,minY,0,height);
      double x1=Utils.map(longitude,minX,maxX,0,width);
      double y1=Utils.map(latitude,maxY,minY,0,height);
      double nodeHeight=tree.getHeight(node);
      int red=(int)Utils.map(nodeHeight,0,treeHeightMax,minBranchRedMapping,maxBranchRedMapping);
      int green=(int)Utils.map(nodeHeight,0,treeHeightMax,minBranchGreenMapping,maxBranchGreenMapping);
      int blue=(int)Utils.map(nodeHeight,0,treeHeightMax,minBranchBlueMapping,maxBranchBlueMapping);
      int alpha=(int)Utils.map(nodeHeight,0,treeHeightMax,maxBranchOpacityMapping,minBranchOpacityMapping);
      stroke(red,green,blue,alpha);
      line((float)x0,(float)y0,(float)x1,(float)y1);
    }
  }
}
Program: 44173
Project: 44173
Buggy source:
public void setup(){
  minX=-180;
  maxX=180;
  minY=-80;
  maxY=90;
  mapBackground=new MapBackground(this);
}

Fixed version (ground truth):
public void setup(){
  minX=-180;
  maxX=180;
  minY=-90;
  maxY=90;
  mapBackground=new MapBackground(this);
}