nus-yam/ex-repair huggingface dataset:
Program: 54798
Project: 54798
Buggy source:
private Path deploy(final String library) throws Exception {
  URL url=loader.getResource(library);
  if (url == null) {
    throw new FileNotFoundException(library);
  }
  URI uri=url.toURI();
  log.debug("String_Node_Str",uri);
  Path outdir=this.basedir.toPath().resolve("String_Node_Str").resolve(library.replace("String_Node_Str","String_Node_Str"));
  Optional<Path> basedir=Try.of(() -> Paths.get(uri)).toJavaOptional();
  try (Library lib=loadLibrary(uri)){
    try (Stream<Path> stream=lib.stream()){
      stream.filter(it -> !Files.isDirectory(it)).forEach(it -> {
        String relative=basedir.map(d -> d.relativize(it).toString()).orElse(it.toString().substring(1));
        Path output=outdir.resolve(relative);
        File fout=output.toFile();
        boolean copy=!fout.exists() || coptions.contains(StandardCopyOption.REPLACE_EXISTING);
        if (copy) {
          log.info("String_Node_Str",it,fout);
          fout.getParentFile().mkdirs();
          StandardCopyOption[] coptions=this.coptions.toArray(new StandardCopyOption[this.coptions.size()]);
          Try.run(() -> Files.copy(it,output,coptions)).onFailure(x -> log.error("String_Node_Str",it,x));
        }
      }
);
    }
   }
   return outdir;
}

Fixed version (ground truth):
private Path deploy(final String library) throws Exception {
  URL url=loader.getResource(library);
  if (url == null) {
    throw new FileNotFoundException(library);
  }
  URI uri=url.toURI();
  log.debug("String_Node_Str",uri);
  Path outdir=this.basedir.toPath().resolve("String_Node_Str").resolve(library.replace("String_Node_Str","String_Node_Str"));
  Optional<Path> basedir=Try.of(() -> Paths.get(uri)).toJavaOptional();
  try (Library lib=loadLibrary(uri)){
    try (Stream<Path> stream=lib.stream()){
      stream.filter(it -> !Files.isDirectory(it)).forEach(it -> {
        String relative=basedir.map(d -> d.relativize(it).toString()).orElse(it.toString().substring(1));
        Path output=outdir.resolve(relative);
        File fout=output.toFile();
        boolean copy=!fout.exists() || coptions.contains(StandardCopyOption.REPLACE_EXISTING);
        if (copy) {
          log.debug("String_Node_Str",it,fout);
          fout.getParentFile().mkdirs();
          StandardCopyOption[] coptions=this.coptions.toArray(new StandardCopyOption[this.coptions.size()]);
          Try.run(() -> Files.copy(it,output,coptions)).onFailure(x -> log.error("String_Node_Str",it,x));
        }
      }
);
    }
   }
   return outdir;
}
Program: 54800
Project: 54800
Buggy source:
/** 
 * Build a flat jboss module, with some minor exceptions (like j2v8).
 * @param name module name.
 * @param mainClass
 * @param cp
 * @return
 * @throws Exception
 */
public static AppModuleLoader build(final String name,final String mainClass,final File... cp) throws Exception {
  Map<ModuleIdentifier,ModuleSpec> modules=newModule(name,mainClass,0,"String_Node_Str",cp);
  return new AppModuleLoader(modules);
}

Fixed version (ground truth):
/** 
 * Build a flat jboss module, with some minor exceptions (like j2v8).
 * @param name module name.
 * @param cp
 * @return
 * @throws Exception
 */
public static AppModuleLoader build(final String name,final File... cp) throws Exception {
  Map<ModuleIdentifier,ModuleSpec> modules=newModule(name,0,"String_Node_Str",cp);
  return new AppModuleLoader(modules);
}
Program: 54802
Project: 54802
Buggy source:
@SuppressWarnings("String_Node_Str") private void startApp(){
  if (app != null) {
    stopApp(app);
  }
  debug("String_Node_Str",mainClass);
  executor.execute(() -> {
    ClassLoader ctxLoader=Thread.currentThread().getContextClassLoader();
    try {
      module=loader.loadModule(mId);
      ModuleClassLoader mcloader=module.getClassLoader();
      Thread.currentThread().setContextClassLoader(mcloader);
      Class<?> joobyClass=mcloader.loadClass("String_Node_Str");
      if (mainClass.equals(joobyClass.getName())) {
        Object js=mcloader.loadClass("String_Node_Str").newInstance();
        Method runjs=js.getClass().getDeclaredMethod("String_Node_Str",File.class);
        this.app=((Supplier)runjs.invoke(js,new File("String_Node_Str"))).get();
      }
 else {
        this.app=joobyClass.getDeclaredConstructors()[0].newInstance();
      }
      debug("String_Node_Str",mainClass);
      Method joobyRun=joobyClass.getMethod("String_Node_Str");
      joobyRun.invoke(this.app);
    }
 catch (    Throwable ex) {
      Throwable cause=ex;
      if (ex instanceof InvocationTargetException) {
        cause=((InvocationTargetException)ex).getTargetException();
      }
      error("String_Node_Str",mainClass,cause);
    }
 finally {
      Thread.currentThread().setContextClassLoader(ctxLoader);
    }
  }
);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private void startApp(){
  if (app != null) {
    stopApp(app);
  }
  debug("String_Node_Str",mainClass);
  executor.execute(() -> {
    ClassLoader ctxLoader=Thread.currentThread().getContextClassLoader();
    try {
      module=loader.loadModule(mId);
      ModuleClassLoader mcloader=module.getClassLoader();
      Thread.currentThread().setContextClassLoader(mcloader);
      if (mainClass.endsWith("String_Node_Str")) {
        Object js=mcloader.loadClass("String_Node_Str").newInstance();
        Method runjs=js.getClass().getDeclaredMethod("String_Node_Str",File.class);
        this.app=((Supplier)runjs.invoke(js,new File(mainClass))).get();
      }
 else {
        this.app=mcloader.loadClass(mainClass).getDeclaredConstructors()[0].newInstance();
      }
      debug("String_Node_Str",mainClass);
      Method joobyRun=app.getClass().getMethod("String_Node_Str");
      joobyRun.invoke(this.app);
    }
 catch (    Throwable ex) {
      Throwable cause=ex;
      if (ex instanceof InvocationTargetException) {
        cause=((InvocationTargetException)ex).getTargetException();
      }
      error("String_Node_Str",mainClass,cause);
    }
 finally {
      Thread.currentThread().setContextClassLoader(ctxLoader);
    }
  }
);
}
Program: 54804
Project: 54804
Buggy source:
public Main(final String mId,final String mainClass,final File... cp) throws Exception {
  this.mainClass=mainClass;
  loader=AppModuleLoader.build(mId,mainClass,cp);
  this.mId=ModuleIdentifier.create(mId);
  this.executor=Executors.newSingleThreadExecutor(task -> new Thread(task,"String_Node_Str"));
  this.scanner=new Watcher(this::onChange,new Path[]{basedir.toPath()});
  includes("String_Node_Str");
  excludes("String_Node_Str");
}

Fixed version (ground truth):
public Main(final String mId,final String mainClass,final File... cp) throws Exception {
  this.mainClass=mainClass;
  loader=AppModuleLoader.build(mId,cp);
  this.mId=ModuleIdentifier.create(mId);
  this.executor=Executors.newSingleThreadExecutor(task -> new Thread(task,"String_Node_Str"));
  this.scanner=new Watcher(this::onChange,new Path[]{basedir.toPath()});
  includes("String_Node_Str");
  excludes("String_Node_Str");
}
Program: 54805
Project: 54805
Buggy source:
/** 
 * Overwrite the default bean parser with <code>null</code> supports. The default bean parser doesn't allow <code>null</code>, so if a parameter is optional you must declare it as  {@link Optional} otherwise parsing fails with a <code>404</code> status code.For example: <pre> {@code}public class Book  public String title; public Date releaseDate; public String toString() { return title + ":" + releaseDate; } } { parser(Parser.bean(true)); post("/", req -> { return req.params(Book.class).toString(); }); } }</pre> With <code>/?title=Title&releaseDate=</code> prints <code>Title:null</code>. Now, same call with <code>allowNulls=false</code> results in <code>Bad Request: 400</code> because <code>releaseDate</code> if required and isn't present in the HTTP request.
 * @param allowNulls Enabled null supports while parsing HTTP params as Java Beans.
 * @return A new parser.
 */
static Parser bean(final boolean allowNulls){
  return new BeanParser(allowNulls);
}

Fixed version (ground truth):
/** 
 * Overwrite the default bean parser with <code>null</code> supports. The default bean parser doesn't allow <code>null</code>, so if a parameter is optional you must declare it as  {@link Optional} otherwise parsing fails with a <code>404</code> status code.For example: <pre> {@code}public class Book  public String title; public Date releaseDate; public String toString() { return title + ":" + releaseDate; } } { parser(Parser.bean(true)); post("/", req -> { return req.params(Book.class).toString(); }); } }</pre> <p> With <code>/?title=Title&amp;releaseDate=</code> prints <code>Title:null</code>. </p> <p> Now, same call with <code>allowNulls=false</code> results in <code>Bad Request: 400</code> because <code>releaseDate</code> if required and isn't present in the HTTP request. </p>
 * @param allowNulls Enabled null supports while parsing HTTP params as Java Beans.
 * @return A new parser.
 */
static Parser bean(final boolean allowNulls){
  return new BeanParser(allowNulls);
}
Program: 54806
Project: 54806
Buggy source:
/** 
 * Map a reactor object like   {@link Flux} or {@link Mono} into a {@link Deferred} object.<pre> {@code ... import org.jooby.reactor.Reactor; ...}{ with(() -> { get("/lux", req -> Flux...); get("/mono", req -> Mono...); }).map(Reactor.reactor( flux -> flux.publishOn(Computations.concurrent()), mono -> mono.publishOn(Computations.concurrent())); } }</pre>
 * @param flux A flux adapter.
 * @param mono A mono adapter.
 * @return A new mapper.
 */
public static Route.Mapper<Object> reactor(){
  return reactor(Function.identity(),Function.identity());
}

Fixed version (ground truth):
/** 
 * Map a reactor object like   {@link Flux} or {@link Mono} into a {@link Deferred} object.<pre> {@code ... import org.jooby.reactor.Reactor; ...}{ with(() -> { get("/lux", req -> Flux...); get("/mono", req -> Mono...); }).map(Reactor.reactor( flux -> flux.publishOn(Computations.concurrent()), mono -> mono.publishOn(Computations.concurrent())); } }</pre>
 * @return A new mapper.
 */
public static Route.Mapper<Object> reactor(){
  return reactor(Function.identity(),Function.identity());
}
Program: 54807
Project: 54807
Buggy source:
/** 
 * Append a metric to the   {@link MetricRegistry}. The metric will be resolved by Guice. This call is identical to   {@link MetricRegistry#register(String,Metric)}.
 * @param name Name of the metric.
 * @param metric A metric object.
 * @return This metrics module.
 */
public <M extends Metric>Metrics metric(final String name,final Class<M> metric){
  bindings.add((binder,conf) -> {
    MapBinder.newMapBinder(binder,String.class,Metric.class).addBinding(name).to(metric);
  }
);
  return this;
}

Fixed version (ground truth):
/** 
 * Append a metric to the   {@link MetricRegistry}. The metric will be resolved by Guice. This call is identical to   {@link MetricRegistry#register(String,Metric)}.
 * @param name Name of the metric.
 * @param metric A metric object.
 * @param < M > Metric type.
 * @return This metrics module.
 */
public <M extends Metric>Metrics metric(final String name,final Class<M> metric){
  bindings.add((binder,conf) -> {
    MapBinder.newMapBinder(binder,String.class,Metric.class).addBinding(name).to(metric);
  }
);
  return this;
}
Program: 54808
Project: 54808
Buggy source:
/** 
 * Append a simple ping handler that results in a <code>200</code> responses with a <code>pong</code> body.
 * @return This metrics module.
 * @see PingHandler.
 */
public Metrics ping(){
  bindings.add((binder,conf) -> {
    Multibinder.newSetBinder(binder,Route.Definition.class).addBinding().toInstance(new Route.Definition("String_Node_Str",this.pattern + "String_Node_Str",new PingHandler()));
  }
);
  return this;
}

Fixed version (ground truth):
/** 
 * Append a simple ping handler that results in a <code>200</code> responses with a <code>pong</code> body. See   {@link PingHandler}
 * @return This metrics module.
 */
public Metrics ping(){
  bindings.add((binder,conf) -> {
    Multibinder.newSetBinder(binder,Route.Definition.class).addBinding().toInstance(new Route.Definition("String_Node_Str",this.pattern + "String_Node_Str",new PingHandler()));
  }
);
  return this;
}
Program: 54809
Project: 54809
Buggy source:
/** 
 * Append a health check to the   {@link HealthCheckRegistry}. The metric will be resolved by Guice. This call is identical to   {@link HealthCheckRegistry#register(String,HealthCheck)}.
 * @param name Name of the check.
 * @param metric A check object.
 * @return This metrics module.
 */
public <H extends HealthCheck>Metrics healthCheck(final String name,final Class<H> check){
  bindings.add((binder,conf) -> {
    MapBinder.newMapBinder(binder,String.class,HealthCheck.class).addBinding(name).to(check);
  }
);
  return this;
}

Fixed version (ground truth):
/** 
 * Append a health check to the   {@link HealthCheckRegistry}. The metric will be resolved by Guice. This call is identical to   {@link HealthCheckRegistry#register(String,HealthCheck)}.
 * @param name Name of the check.
 * @param check A check object.
 * @param < H > {@link HealthCheck} type.
 * @return This metrics module.
 */
public <H extends HealthCheck>Metrics healthCheck(final String name,final Class<H> check){
  bindings.add((binder,conf) -> {
    MapBinder.newMapBinder(binder,String.class,HealthCheck.class).addBinding(name).to(check);
  }
);
  return this;
}
Program: 54810
Project: 54810
Buggy source:
/** 
 * Append a handler that prints thread states (a.k.a thread dump).
 * @return This metrics module.
 * @see ThreadDumpHandler.
 */
public Metrics threadDump(){
  bindings.add((binder,conf) -> {
    Multibinder<Definition> routes=Multibinder.newSetBinder(binder,Route.Definition.class);
    routes.addBinding().toInstance(new Route.Definition("String_Node_Str",this.pattern + "String_Node_Str",new ThreadDumpHandler()));
  }
);
  return this;
}

Fixed version (ground truth):
/** 
 * Append a handler that prints thread states (a.k.a thread dump). See   {@link ThreadDumpHandler}.
 * @return This metrics module.
 */
public Metrics threadDump(){
  bindings.add((binder,conf) -> {
    Multibinder<Definition> routes=Multibinder.newSetBinder(binder,Route.Definition.class);
    routes.addBinding().toInstance(new Route.Definition("String_Node_Str",this.pattern + "String_Node_Str",new ThreadDumpHandler()));
  }
);
  return this;
}
Program: 54811
Project: 54811
Buggy source:
/** 
 * </p> Setup up an   {@link EntityInterceptor} on {@link PrePersist} events that generates anincremental ID. </p> Usage: <pre> { use(new Monphia().idGen(IdGen.GLOBAL); } </pre> <p> ID must be of type:  {@link Long} and annotated with {@link GeneratedValue}: </p> <pre> &#64;Entity public class MyEntity { &#64;Id &#64;GeneratedValue Long id; } </pre>
 * @param gen an {@link IdGen} strategy
 * @return This module.
 */
public Monphia with(final IdGen gen){
  this.gen=requireNonNull(gen,"String_Node_Str");
  return this;
}

Fixed version (ground truth):
/** 
 * <p> Setup up an   {@link EntityInterceptor} on {@link PrePersist} events that generates anincremental ID. </p> Usage: <pre> { use(new Monphia().idGen(IdGen.GLOBAL); } </pre> <p> ID must be of type:  {@link Long} and annotated with {@link GeneratedValue}: </p> <pre> &#64;Entity public class MyEntity { &#64;Id &#64;GeneratedValue Long id; } </pre>
 * @param gen an {@link IdGen} strategy
 * @return This module.
 */
public Monphia with(final IdGen gen){
  this.gen=requireNonNull(gen,"String_Node_Str");
  return this;
}
Program: 54813
Project: 54813
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test(expected=IOException.class) public void handleException() throws Exception {
  Class handlerClass=MvcHandlerTest.class;
  Object handler=new MvcHandlerTest();
  Method method=handlerClass.getDeclaredMethod("String_Node_Str");
  new MockUnit(RequestParamProvider.class,Request.class,Response.class).expect(unit -> {
    Request req=unit.get(Request.class);
    expect(req.require(handlerClass)).andReturn(handler);
  }
).expect(unit -> {
    List<RequestParam> params=Collections.emptyList();
    RequestParamProvider paramProvider=unit.get(RequestParamProvider.class);
    expect(paramProvider.parameters(method)).andReturn(params);
  }
).run(unit -> {
    new MvcHandler(method,unit.get(RequestParamProvider.class)).handle(unit.get(Request.class),unit.get(Response.class));
  }
);
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test(expected=IOException.class) public void handleException() throws Exception {
  Class handlerClass=MvcHandlerTest.class;
  MvcHandlerTest handler=new MvcHandlerTest();
  Method method=handlerClass.getDeclaredMethod("String_Node_Str");
  new MockUnit(RequestParamProvider.class,Request.class,Response.class).expect(unit -> {
    Request req=unit.get(Request.class);
    expect(req.require(MvcHandlerTest.class)).andReturn(handler);
  }
).expect(unit -> {
    List<RequestParam> params=Collections.emptyList();
    RequestParamProvider paramProvider=unit.get(RequestParamProvider.class);
    expect(paramProvider.parameters(method)).andReturn(params);
  }
).run(unit -> {
    new MvcHandler(method,unit.get(RequestParamProvider.class)).handle(unit.get(Request.class),unit.get(Response.class));
  }
);
}
Program: 54814
Project: 54814
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test(expected=RuntimeException.class) public void throwableException() throws Exception {
  Class handlerClass=MvcHandlerTest.class;
  Object handler=new MvcHandlerTest();
  Method method=handlerClass.getDeclaredMethod("String_Node_Str");
  new MockUnit(RequestParamProvider.class,Request.class,Response.class).expect(unit -> {
    Request req=unit.get(Request.class);
    expect(req.require(handlerClass)).andReturn(handler);
  }
).expect(unit -> {
    List<RequestParam> params=Collections.emptyList();
    RequestParamProvider paramProvider=unit.get(RequestParamProvider.class);
    expect(paramProvider.parameters(method)).andReturn(params);
  }
).run(unit -> {
    new MvcHandler(method,unit.get(RequestParamProvider.class)).handle(unit.get(Request.class),unit.get(Response.class));
  }
);
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test(expected=RuntimeException.class) public void throwableException() throws Exception {
  Class handlerClass=MvcHandlerTest.class;
  MvcHandlerTest handler=new MvcHandlerTest();
  Method method=handlerClass.getDeclaredMethod("String_Node_Str");
  new MockUnit(RequestParamProvider.class,Request.class,Response.class).expect(unit -> {
    Request req=unit.get(Request.class);
    expect(req.require(MvcHandlerTest.class)).andReturn(handler);
  }
).expect(unit -> {
    List<RequestParam> params=Collections.emptyList();
    RequestParamProvider paramProvider=unit.get(RequestParamProvider.class);
    expect(paramProvider.parameters(method)).andReturn(params);
  }
).run(unit -> {
    new MvcHandler(method,unit.get(RequestParamProvider.class)).handle(unit.get(Request.class),unit.get(Response.class));
  }
);
}
Program: 54815
Project: 54815
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test public void handle() throws Exception {
  Class handlerClass=MvcHandlerTest.class;
  Object handler=new MvcHandlerTest();
  Method method=handlerClass.getDeclaredMethod("String_Node_Str");
  new MockUnit(RequestParamProvider.class,Request.class,Response.class).expect(unit -> {
    Request req=unit.get(Request.class);
    expect(req.require(handlerClass)).andReturn(handler);
  }
).expect(unit -> {
    Response rsp=unit.get(Response.class);
    expect(rsp.status(Status.OK)).andReturn(rsp);
    rsp.send("String_Node_Str");
  }
).expect(unit -> {
    List<RequestParam> params=Collections.emptyList();
    RequestParamProvider paramProvider=unit.get(RequestParamProvider.class);
    expect(paramProvider.parameters(method)).andReturn(params);
  }
).run(unit -> {
    new MvcHandler(method,unit.get(RequestParamProvider.class)).handle(unit.get(Request.class),unit.get(Response.class));
  }
);
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test public void handle() throws Exception {
  Class handlerClass=MvcHandlerTest.class;
  MvcHandlerTest handler=new MvcHandlerTest();
  Method method=handlerClass.getDeclaredMethod("String_Node_Str");
  new MockUnit(RequestParamProvider.class,Request.class,Response.class).expect(unit -> {
    Request req=unit.get(Request.class);
    expect(req.require(MvcHandlerTest.class)).andReturn(handler);
  }
).expect(unit -> {
    Response rsp=unit.get(Response.class);
    expect(rsp.status(Status.OK)).andReturn(rsp);
    rsp.send("String_Node_Str");
  }
).expect(unit -> {
    List<RequestParam> params=Collections.emptyList();
    RequestParamProvider paramProvider=unit.get(RequestParamProvider.class);
    expect(paramProvider.parameters(method)).andReturn(params);
  }
).run(unit -> {
    new MvcHandler(method,unit.get(RequestParamProvider.class)).handle(unit.get(Request.class),unit.get(Response.class));
  }
);
}
Program: 54816
Project: 54816
Buggy source:
@Test public void globTrace() throws Exception {
  request().trace("String_Node_Str").expect(200).header("String_Node_Str",len -> {
    assertTrue(Integer.parseInt(len) >= 163);
  }
).startsWith("String_Node_Str");
}

Fixed version (ground truth):
@Test public void globTrace() throws Exception {
  request().trace("String_Node_Str").expect(200).startsWith("String_Node_Str");
}
Program: 54817
Project: 54817
Buggy source:
public Request patch(final String path){
  this.req=new Request(this,executor(),org.apache.http.client.fluent.Request.Patch(host + path));
  return req;
}

Fixed version (ground truth):
public Request patch(final String path){
  this.req=new Request(this,executor(),pathHack(host + path));
  return req;
}
Program: 54818
Project: 54818
Buggy source:
/** 
 * Attempt to write a message into the HTTP response body. <p> For text format (json, yaml, xml, etc.) a converter usually call to  {@link Context#text(Context.Text)} in order to set charset and close resources.</p> <p> For binary format a converter usually call to {@link Context#bytes(Context.Bytes)} in order to close resources.</p>
 * @param body A body message.
 * @param ctx A write context.
 * @throws Exception If write operation fail.
 */
void format(Object body,BodyFormatter.Context ctx) throws Exception ;

Fixed version (ground truth):
/** 
 * Attempt to write a message into the HTTP response body. <p> For text format (json, yaml, xml, etc.) a converter usually call to  {@link BodyFormatter.Context#text(BodyFormatter.Context.Text)} in orderto set charset and close resources. </p> <p> For binary format a converter usually call to {@link BodyFormatter.Context#bytes(BodyFormatter.Context.Bytes)} in orderto close resources. </p>
 * @param body A body message.
 * @param ctx A write context.
 * @throws Exception If write operation fail.
 */
void format(Object body,BodyFormatter.Context ctx) throws Exception ;
Program: 54819
Project: 54819
Buggy source:
/** 
 * Access to request locals. See   {@link Request#attributes()} and {@link Locals}.
 * @return Current request locals.
 */
Map<String,Object> locals();

Fixed version (ground truth):
/** 
 * Access to request locals. See   {@link Request#attributes()}.
 * @return Current request locals.
 */
Map<String,Object> locals();
Program: 54820
Project: 54820
Buggy source:
/** 
 * Attempt to read a message from HTTP request body. <p> For text format (json, yaml, xml, etc.) a converter usually call to  {@link Context#text(Context.Text)} in order to apply correct charset and closeresources. </p> <p> For binary format a converter usually call to  {@link Context#bytes(Context.Bytes)} inorder to close resources. </p>
 * @param type A type of message.
 * @param ctx A read context.
 * @param < T > Target type.
 * @return A body message.
 * @throws Exception If read operation fail.
 */
<T>T parse(TypeLiteral<T> type,BodyParser.Context ctx) throws Exception ;

Fixed version (ground truth):
/** 
 * Attempt to read a message from HTTP request body. <p> For text format (json, yaml, xml, etc.) a converter usually call to  {@link BodyParser.Context#text(BodyParser.Context.Text)} in order to apply correct charsetand close resources. </p> <p> For binary format a converter usually call to {@link BodyParser.Context#bytes(BodyParser.Context.Bytes)} in order to close resources.</p>
 * @param type A type of message.
 * @param ctx A read context.
 * @param < T > Target type.
 * @return A body message.
 * @throws Exception If read operation fail.
 */
<T>T parse(TypeLiteral<T> type,BodyParser.Context ctx) throws Exception ;
Program: 54821
Project: 54821
Buggy source:
/** 
 * Remove a request local attribute.
 * @param name Attribute's name.
 * @return A local attribute.
 */
<T>Optional<T> unset(String name);

Fixed version (ground truth):
/** 
 * Remove a request local attribute.
 * @param name Attribute's name.
 * @param < T > Target type.
 * @return A local attribute.
 */
<T>Optional<T> unset(String name);
Program: 54822
Project: 54822
Buggy source:
/** 
 * Get a request local attribute.
 * @param name Attribute's name.
 * @return A local attribute.
 */
<T>Optional<T> get(String name);

Fixed version (ground truth):
/** 
 * Get a request local attribute.
 * @param name Attribute's name.
 * @param < T > Target type.
 * @return A local attribute.
 */
<T>Optional<T> get(String name);
Program: 54823
Project: 54823
Buggy source:
/** 
 * Get a object from this session. If the object isn't found this method returns an empty optional.
 * @param name A local var's name.
 * @param < T > Target type.
 * @return A value or empty optional.
 */
Mutant get(final String name);

Fixed version (ground truth):
/** 
 * Get a object from this session. If the object isn't found this method returns an empty optional.
 * @param name A local var's name.
 * @return A value or empty optional.
 */
Mutant get(final String name);
Program: 54824
Project: 54824
Buggy source:
@Test public void arrayResponse() throws IOException {
  this.snippet.expectResponseFields("String_Node_Str").withContents(tableWithHeader("String_Node_Str","String_Node_Str","String_Node_Str").row("String_Node_Str","String_Node_Str","String_Node_Str"));
  MockHttpServletResponse response=new MockHttpServletResponse();
  response.getWriter().append("String_Node_Str");
  documentResponseFields("String_Node_Str",fieldWithPath("String_Node_Str").description("String_Node_Str")).handle(result(response));
}

Fixed version (ground truth):
@Test public void arrayResponse() throws IOException {
  this.snippet.expectResponseFields("String_Node_Str").withContents(tableWithHeader("String_Node_Str","String_Node_Str","String_Node_Str").row("String_Node_Str","String_Node_Str","String_Node_Str"));
  MockHttpServletResponse response=new MockHttpServletResponse();
  response.getWriter().append("String_Node_Str");
  documentResponseFields("String_Node_Str",null,fieldWithPath("String_Node_Str").description("String_Node_Str")).handle(result(response));
}
Program: 54826
Project: 54826
Buggy source:
@Override protected TokenResponse executeRefreshToken() throws IOException {
  Socket socket=new Socket("String_Node_Str",this.getAuthPort());
  socket.setSoTimeout(READ_TIMEOUT_MS);
  TokenResponse token=new TokenResponse();
  try {
    PrintWriter out=new PrintWriter(socket.getOutputStream(),true);
    out.println(GET_AUTH_TOKEN_REQUEST);
    BufferedReader input=new BufferedReader(new InputStreamReader(socket.getInputStream()));
    String ignoredSizeLine=input.readLine();
    Collection<Object> messageArray=jsonFactory.createJsonParser(input).parseArray(LinkedList.class,Object.class);
    String accessToken=((List<Object>)messageArray).get(ACCESS_TOKEN_INDEX).toString();
    token.setAccessToken(accessToken);
  }
  finally {
    socket.close();
  }
  return token;
}

Fixed version (ground truth):
@Override protected TokenResponse executeRefreshToken() throws IOException {
  Socket socket=new Socket("String_Node_Str",this.getAuthPort());
  socket.setSoTimeout(READ_TIMEOUT_MS);
  TokenResponse token=new TokenResponse();
  try {
    PrintWriter out=new PrintWriter(socket.getOutputStream(),true);
    out.println(GET_AUTH_TOKEN_REQUEST);
    BufferedReader input=new BufferedReader(new InputStreamReader(socket.getInputStream()));
    input.readLine();
    Collection<Object> messageArray=jsonFactory.createJsonParser(input).parseArray(LinkedList.class,Object.class);
    String accessToken=((List<Object>)messageArray).get(ACCESS_TOKEN_INDEX).toString();
    token.setAccessToken(accessToken);
  }
  finally {
    socket.close();
  }
  return token;
}
Program: 54827
Project: 54827
Buggy source:
/** 
 * {@link Beta} <br/>The call back method that will be invoked on a server error or an I/O exception during resumable upload inside  {@link #upload}. <p> This method changes the current request to query the current status of the upload to find how many bytes were successfully uploaded before the server error occurred. </p>
 */
@Beta void serverErrorCallback() throws IOException {
  Preconditions.checkNotNull(currentRequest,"String_Node_Str");
  currentRequest.setContent(new EmptyContent());
  currentRequest.getHeaders().setContentRange("String_Node_Str" + (isMediaLengthKnown() ? getMediaContentLength() : "String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * {@link Beta} <br/>The call back method that will be invoked on a server error or an I/O exception during resumable upload inside  {@link #upload}. <p> This method changes the current request to query the current status of the upload to find how many bytes were successfully uploaded before the server error occurred. </p>
 */
@Beta void serverErrorCallback() throws IOException {
  Preconditions.checkNotNull(currentRequest,"String_Node_Str");
  currentRequest.setContent(new EmptyContent());
  currentRequest.getHeaders().setContentRange("String_Node_Str" + mediaContentLengthStr);
}
Program: 54829
Project: 54829
Buggy source:
public void subtestUpload_ResumableWithError(ErrorType error,int contentLength,boolean contentLengthKnown,int maxByteIndexUploadedOnError,int chunks) throws Exception {
  MediaTransport fakeTransport=new MediaTransport(contentLength,true);
  if (error == ErrorType.IO_EXCEPTION) {
    fakeTransport.testIOException=true;
  }
 else   if (error == ErrorType.SERVER_UNAVAILABLE) {
    fakeTransport.testServerError=true;
  }
  fakeTransport.contentLengthNotSpecified=!contentLengthKnown;
  fakeTransport.maxByteIndexUploadedOnError=maxByteIndexUploadedOnError;
  byte[] testedData=new byte[contentLength];
  new Random().nextBytes(testedData);
  InputStream is=new ByteArrayInputStream(testedData);
  InputStreamContent mediaContent=new InputStreamContent(TEST_CONTENT_TYPE,is);
  if (contentLengthKnown) {
    mediaContent.setLength(contentLength);
  }
  MediaHttpUploader uploader=new MediaHttpUploader(mediaContent,fakeTransport,new ZeroBackOffRequestInitializer());
  uploader.setDisableGZipContent(true);
  HttpResponse response=uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
  assertEquals(200,response.getStatusCode());
  int calls=2 + chunks;
  assertEquals(calls,fakeTransport.lowLevelExecCalls);
  assertTrue(Arrays.equals(testedData,fakeTransport.bytesReceived));
}

Fixed version (ground truth):
public void subtestUpload_ResumableWithError(ErrorType error,int contentLength,boolean contentLengthKnown,int maxByteIndexUploadedOnError,int chunks,boolean force308OnRangeQueryResponse) throws Exception {
  MediaTransport fakeTransport=new MediaTransport(contentLength,true);
  if (error == ErrorType.IO_EXCEPTION) {
    fakeTransport.testIOException=true;
  }
 else   if (error == ErrorType.SERVER_UNAVAILABLE) {
    fakeTransport.testServerError=true;
  }
  fakeTransport.contentLengthNotSpecified=!contentLengthKnown;
  fakeTransport.maxByteIndexUploadedOnError=maxByteIndexUploadedOnError;
  fakeTransport.force308OnRangeQueryResponse=force308OnRangeQueryResponse;
  byte[] testedData=new byte[contentLength];
  new Random().nextBytes(testedData);
  InputStream is=new ByteArrayInputStream(testedData);
  InputStreamContent mediaContent=new InputStreamContent(TEST_CONTENT_TYPE,is);
  if (contentLengthKnown) {
    mediaContent.setLength(contentLength);
  }
  MediaHttpUploader uploader=new MediaHttpUploader(mediaContent,fakeTransport,new ZeroBackOffRequestInitializer());
  uploader.setDisableGZipContent(true);
  HttpResponse response=uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
  assertEquals(200,response.getStatusCode());
  int calls=2 + chunks;
  assertEquals(calls,fakeTransport.lowLevelExecCalls);
  assertTrue(Arrays.equals(testedData,fakeTransport.bytesReceived));
}
Program: 54831
Project: 54831
Buggy source:
private final GoogleCredential tryGetAppEngineCredential(HttpTransport transport,JsonFactory jsonFactory){
  if (checkedAppEngine) {
    return null;
  }
  checkedAppEngine=true;
  try {
    Class<?> credentialClass=forName(APP_ENGINE_CREDENTIAL_CLASS);
    Constructor<?> constructor=credentialClass.getConstructor(HttpTransport.class,JsonFactory.class);
    return (GoogleCredential)constructor.newInstance(transport,jsonFactory);
  }
 catch (  ClassNotFoundException expected) {
  }
catch (  NoSuchMethodException expected) {
  }
catch (  InstantiationException expected) {
  }
catch (  IllegalAccessException expected) {
  }
catch (  InvocationTargetException expected) {
  }
  return null;
}

Fixed version (ground truth):
private final GoogleCredential tryGetAppEngineCredential(HttpTransport transport,JsonFactory jsonFactory) throws IOException {
  if (checkedAppEngine) {
    return null;
  }
  boolean onAppEngine=runningOnAppEngine();
  checkedAppEngine=true;
  if (!onAppEngine) {
    return null;
  }
  Exception innerException=null;
  try {
    Class<?> credentialClass=forName(APP_ENGINE_CREDENTIAL_CLASS);
    Constructor<?> constructor=credentialClass.getConstructor(HttpTransport.class,JsonFactory.class);
    return (GoogleCredential)constructor.newInstance(transport,jsonFactory);
  }
 catch (  ClassNotFoundException e) {
    innerException=e;
  }
catch (  NoSuchMethodException e) {
    innerException=e;
  }
catch (  InstantiationException e) {
    innerException=e;
  }
catch (  IllegalAccessException e) {
    innerException=e;
  }
catch (  InvocationTargetException e) {
    innerException=e;
  }
  throw OAuth2Utils.exceptionWithCause(new IOException(String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str",APP_ENGINE_CREDENTIAL_CLASS)),innerException);
}
Program: 54832
Project: 54832
Buggy source:
public void testDefaultCredentialCaches() throws IOException {
  HttpTransport transport=new MockHttpTransport();
  TestDefaultCredentialProvider testProvider=new TestDefaultCredentialProvider();
  testProvider.addType(DefaultCredentialProvider.APP_ENGINE_CREDENTIAL_CLASS,MockAppEngineCredential.class);
  Credential firstCall=testProvider.getDefaultCredential(transport,JSON_FACTORY);
  assertNotNull(firstCall);
  Credential secondCall=testProvider.getDefaultCredential(transport,JSON_FACTORY);
  assertSame(firstCall,secondCall);
}

Fixed version (ground truth):
public void testDefaultCredentialCaches() throws IOException {
  HttpTransport transport=new MockHttpTransport();
  TestDefaultCredentialProvider testProvider=new TestDefaultCredentialProvider();
  testProvider.addType(DefaultCredentialProvider.APP_ENGINE_CREDENTIAL_CLASS,MockAppEngineCredential.class);
  testProvider.addType(GAE_SIGNAL_CLASS,MockAppEngineSystemProperty.class);
  Credential firstCall=testProvider.getDefaultCredential(transport,JSON_FACTORY);
  assertNotNull(firstCall);
  Credential secondCall=testProvider.getDefaultCredential(transport,JSON_FACTORY);
  assertSame(firstCall,secondCall);
}
Program: 54833
Project: 54833
Buggy source:
@Override protected TokenResponse executeRefreshToken() throws IOException {
  Socket socket=new Socket("String_Node_Str",this.getAuthPort());
  socket.setSoTimeout(READ_TIMEOUT_MS);
  TokenResponse token=new TokenResponse();
  try {
    PrintWriter out=new PrintWriter(socket.getOutputStream(),true);
    out.println(GET_AUTH_TOKEN_REQUEST);
    BufferedReader input=new BufferedReader(new InputStreamReader(socket.getInputStream()));
    String ignoredSizeLine=input.readLine();
    Collection<String> messageArray=jsonFactory.createJsonParser(input).parseArray(LinkedList.class,String.class);
    String accessToken=((List<String>)messageArray).get(ACCESS_TOKEN_INDEX);
    token.setAccessToken(accessToken);
  }
  finally {
    socket.close();
  }
  return token;
}

Fixed version (ground truth):
@Override protected TokenResponse executeRefreshToken() throws IOException {
  Socket socket=new Socket("String_Node_Str",this.getAuthPort());
  socket.setSoTimeout(READ_TIMEOUT_MS);
  TokenResponse token=new TokenResponse();
  try {
    PrintWriter out=new PrintWriter(socket.getOutputStream(),true);
    out.println(GET_AUTH_TOKEN_REQUEST);
    BufferedReader input=new BufferedReader(new InputStreamReader(socket.getInputStream()));
    String ignoredSizeLine=input.readLine();
    Collection<Object> messageArray=jsonFactory.createJsonParser(input).parseArray(LinkedList.class,Object.class);
    String accessToken=((List<Object>)messageArray).get(ACCESS_TOKEN_INDEX).toString();
    token.setAccessToken(accessToken);
  }
  finally {
    socket.close();
  }
  return token;
}
Program: 54834
Project: 54834
Buggy source:
/** 
 * Override in test code to isolate from environment
 */
Class<?> forName(String className) throws ClassNotFoundException {
  return Class.forName(className);
}

Fixed version (ground truth):
/** 
 * Override in test code to isolate from environment.
 */
Class<?> forName(String className) throws ClassNotFoundException {
  return Class.forName(className);
}
Program: 54840
Project: 54840
Buggy source:
/** 
 * The call back method that will be invoked on a server error or an I/O exception during resumable upload inside   {@link #upload}. <p> This method will query the current status of the upload to find how many bytes were successfully uploaded before the server error occurred. It will then adjust the HTTP Request object to contain the correct range header and media content chunk. </p>
 */
public void serverErrorCallback() throws IOException {
  Preconditions.checkNotNull(currentRequest,"String_Node_Str");
  HttpRequest request=requestFactory.buildPutRequest(currentRequest.getUrl(),new EmptyContent());
  request.getHeaders().setContentRange("String_Node_Str" + (getMediaContentLength() >= 0 ? getMediaContentLength() : "String_Node_Str"));
  HttpResponse response=executeCurrentRequestWithBackOffAndGZip(request);
  try {
    long bytesWritten=getNextByteIndex(response.getHeaders().getRange());
    String updatedUploadUrl=response.getHeaders().getLocation();
    if (updatedUploadUrl != null) {
      currentRequest.setUrl(new GenericUrl(updatedUploadUrl));
    }
    if (getMediaContentLength() >= 0) {
      contentInputStream.reset();
      long skipValue=bytesUploaded - bytesWritten;
      long actualSkipValue=contentInputStream.skip(skipValue);
      Preconditions.checkState(skipValue == actualSkipValue);
    }
    setContentAndHeadersOnCurrentRequest(bytesWritten);
  }
  finally {
    response.disconnect();
  }
}

Fixed version (ground truth):
/** 
 * {@link Beta} <br/>The call back method that will be invoked on a server error or an I/O exception during resumable upload inside  {@link #upload}. <p> This method will query the current status of the upload to find how many bytes were successfully uploaded before the server error occurred. It will then adjust the HTTP Request object to contain the correct range header and media content chunk. </p>
 */
@Beta public void serverErrorCallback() throws IOException {
  Preconditions.checkNotNull(currentRequest,"String_Node_Str");
  HttpRequest request=requestFactory.buildPutRequest(currentRequest.getUrl(),new EmptyContent());
  request.getHeaders().setContentRange("String_Node_Str" + (getMediaContentLength() >= 0 ? getMediaContentLength() : "String_Node_Str"));
  HttpResponse response=executeCurrentRequestWithBackOffAndGZip(request);
  try {
    long bytesWritten=getNextByteIndex(response.getHeaders().getRange());
    String updatedUploadUrl=response.getHeaders().getLocation();
    if (updatedUploadUrl != null) {
      currentRequest.setUrl(new GenericUrl(updatedUploadUrl));
    }
    if (getMediaContentLength() >= 0) {
      contentInputStream.reset();
      long skipValue=bytesUploaded - bytesWritten;
      long actualSkipValue=contentInputStream.skip(skipValue);
      Preconditions.checkState(skipValue == actualSkipValue);
    }
    setContentAndHeadersOnCurrentRequest(bytesWritten);
  }
  finally {
    response.disconnect();
  }
}
Program: 54841
Project: 54841
Buggy source:
public void testUploadServerErrorWithBackOffEnabled_WithNoContentSizeProvided() throws Exception {
  int contentLength=MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
  MediaTransport fakeTransport=new MediaTransport(contentLength);
  fakeTransport.testServerError=true;
  fakeTransport.contentLengthNotSpecified=true;
  InputStream is=new ByteArrayInputStream(new byte[contentLength]);
  InputStreamContent mediaContent=new InputStreamContent(TEST_CONTENT_TYPE,is);
  MediaHttpUploader uploader=new MediaHttpUploader(mediaContent,fakeTransport,null);
  uploader.setBackOffPolicyEnabled(true);
  uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
  assertEquals(5,fakeTransport.lowLevelExecCalls);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void testUploadServerErrorWithBackOffEnabled_WithNoContentSizeProvided() throws Exception {
  int contentLength=MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
  MediaTransport fakeTransport=new MediaTransport(contentLength);
  fakeTransport.testServerError=true;
  fakeTransport.contentLengthNotSpecified=true;
  InputStream is=new ByteArrayInputStream(new byte[contentLength]);
  InputStreamContent mediaContent=new InputStreamContent(TEST_CONTENT_TYPE,is);
  MediaHttpUploader uploader=new MediaHttpUploader(mediaContent,fakeTransport,null);
  uploader.setBackOffPolicyEnabled(true);
  uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
  assertEquals(5,fakeTransport.lowLevelExecCalls);
}
Program: 54842
Project: 54842
Buggy source:
public void testUploadServerErrorWithBackOffEnabled() throws Exception {
  int contentLength=MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
  MediaTransport fakeTransport=new MediaTransport(contentLength);
  fakeTransport.testServerError=true;
  InputStream is=new ByteArrayInputStream(new byte[contentLength]);
  InputStreamContent mediaContent=new InputStreamContent(TEST_CONTENT_TYPE,is);
  mediaContent.setLength(contentLength);
  MediaHttpUploader uploader=new MediaHttpUploader(mediaContent,fakeTransport,null);
  uploader.setBackOffPolicyEnabled(true);
  uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
  assertEquals(5,fakeTransport.lowLevelExecCalls);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void testUploadServerErrorWithBackOffEnabled() throws Exception {
  int contentLength=MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
  MediaTransport fakeTransport=new MediaTransport(contentLength);
  fakeTransport.testServerError=true;
  InputStream is=new ByteArrayInputStream(new byte[contentLength]);
  InputStreamContent mediaContent=new InputStreamContent(TEST_CONTENT_TYPE,is);
  mediaContent.setLength(contentLength);
  MediaHttpUploader uploader=new MediaHttpUploader(mediaContent,fakeTransport,null);
  uploader.setBackOffPolicyEnabled(true);
  uploader.upload(new GenericUrl(TEST_RESUMABLE_REQUEST_URL));
  assertEquals(5,fakeTransport.lowLevelExecCalls);
}
Program: 54843
Project: 54843
Buggy source:
public void testDirectUploadServerErrorWithBackOffEnabled() throws Exception {
  int contentLength=MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
  MediaTransport fakeTransport=new MediaTransport(contentLength);
  fakeTransport.testServerError=true;
  fakeTransport.directUploadEnabled=true;
  ByteArrayContent mediaContent=new ByteArrayContent(TEST_CONTENT_TYPE,new byte[contentLength]);
  MediaHttpUploader uploader=new MediaHttpUploader(mediaContent,fakeTransport,null);
  uploader.setDirectUploadEnabled(true);
  uploader.setBackOffPolicyEnabled(true);
  uploader.upload(new GenericUrl(TEST_DIRECT_REQUEST_URL));
  assertEquals(2,fakeTransport.lowLevelExecCalls);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void testDirectUploadServerErrorWithBackOffEnabled() throws Exception {
  int contentLength=MediaHttpUploader.DEFAULT_CHUNK_SIZE * 2;
  MediaTransport fakeTransport=new MediaTransport(contentLength);
  fakeTransport.testServerError=true;
  fakeTransport.directUploadEnabled=true;
  ByteArrayContent mediaContent=new ByteArrayContent(TEST_CONTENT_TYPE,new byte[contentLength]);
  MediaHttpUploader uploader=new MediaHttpUploader(mediaContent,fakeTransport,null);
  uploader.setDirectUploadEnabled(true);
  uploader.setBackOffPolicyEnabled(true);
  uploader.upload(new GenericUrl(TEST_DIRECT_REQUEST_URL));
  assertEquals(2,fakeTransport.lowLevelExecCalls);
}
Program: 54846
Project: 54846
Buggy source:
/** 
 * @param request HTTP GET request
 * @param notificationDeliveryMethod notification delivery method
 */
public SubscribeRequest(HttpRequest request,String notificationDeliveryMethod){
  this.request=Preconditions.checkNotNull(request);
  Preconditions.checkArgument(HttpMethods.GET.equals(request.getRequestMethod()));
  request.setRequestMethod(HttpMethods.POST);
  setNotificationDeliveryMethod(notificationDeliveryMethod);
  setSubscriptionId(UUID.randomUUID().toString());
}

Fixed version (ground truth):
/** 
 * @param request HTTP GET request
 * @param notificationDeliveryMethod notification delivery method
 */
public SubscribeRequest(HttpRequest request,String notificationDeliveryMethod){
  this.request=Preconditions.checkNotNull(request);
  Preconditions.checkArgument(HttpMethods.GET.equals(request.getRequestMethod()));
  request.setRequestMethod(HttpMethods.POST);
  request.setContent(new EmptyContent());
  setNotificationDeliveryMethod(notificationDeliveryMethod);
  setSubscriptionId(UUID.randomUUID().toString());
}
Program: 54847
Project: 54847
Buggy source:
@Override public void initialize(AbstractGoogleClientRequest<?> request){
  isCalled=true;
}

Fixed version (ground truth):
public void initialize(AbstractGoogleClientRequest<?> request){
  isCalled=true;
}
Program: 54848
Project: 54848
Buggy source:
/** 
 * Intercept the request by using the access token obtained from the   {@link AppIdentityService}. <p> Upgrade warning: this method now throws an   {@link Exception}. In prior version 1.11 it threw an  {@link java.io.IOException}. In prior version   {@link AppIdentityServiceFailureException} waswrapped with an  {@link Exception}, but now it is no longer wrapped. </p>
 */
@Override public void intercept(HttpRequest request) throws Exception {
  String accessToken=AppIdentityServiceFactory.getAppIdentityService().getAccessToken(scopes).getAccessToken();
  BearerToken.authorizationHeaderAccessMethod().intercept(request,accessToken);
}

Fixed version (ground truth):
/** 
 * Intercept the request by using the access token obtained from the   {@link AppIdentityService}. <p> Upgrade warning: this method now throws an   {@link Exception}. In prior version 1.11 it threw an  {@link java.io.IOException}. In prior version   {@link AppIdentityServiceFailureException} waswrapped with an  {@link Exception}, but now it is no longer wrapped. </p>
 */
@Override public void intercept(HttpRequest request) throws Exception {
  String accessToken=appIdentityService.getAccessToken(scopes).getAccessToken();
  BearerToken.authorizationHeaderAccessMethod().intercept(request,accessToken);
}