google / error-prone

Catch common Java mistakes as compile-time errors

Home Page:https://errorprone.info

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FormatMethod: about the position of the argument: [FormatStringAnnotation] extra format arguments: used 0, provided 1

coolderli opened this issue · comments

Hi, I'm using @FormatMethod to format my code. Should the argument be behind the format string?

If I write as below, I will get an error.

@FormatMethod
  public GravitinoRuntimeException(@FormatString String message, Object... args) {
    super(String.format(message, args));
  }

@FormatMethod
public GravitinoRuntimeException(@FormatString String message, Throwable cause, Object... args) {
    super(String.format(message, args), cause);
  }

new GravitinoRuntimeException("Error creating datasource", exception)

The error like:

[FormatStringAnnotation] extra format arguments: used 0, provided 1

Thanks.