Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in SqlBatch with a constant parameter value of null #1761

Closed
rherrmann opened this issue Sep 24, 2020 · 1 comment · Fixed by #1762
Closed

NullPointerException in SqlBatch with a constant parameter value of null #1761

rherrmann opened this issue Sep 24, 2020 · 1 comment · Fixed by #1762
Labels

Comments

@rherrmann
Copy link
Contributor

I'm trying to execute an @SqlBatch with a constant parameter value of null. This causes a NullPointerException in JDBI while testing if arguments are iterable-like.

This code reproduces the issue:

public interface Sql {
  // create table user (tenant_id varchar(20), name varchar(20))
  @SqlBatch("insert into user(tenant_id, name) values (:tenantId, :name);")
  void insert(String tenantId, @Bind("name") List<String> names);
}

Jdbi jdbi = Jdbi.create(connectionUrl);
jdbi.installPlugin(new SqlObjectPlugin());
jdbi.useHandle(handle -> {
  Sql sql = handle.attach(Sql.class);
  sql.insert(null, asList("foo", "bar"));
});

Stacktrace:

java.lang.NullPointerException
	at org.jdbi.v3.core.internal.IterableLike.isIterable(IterableLike.java:48)
	at org.jdbi.v3.sqlobject.statement.internal.SqlBatchHandler.zipArgs(SqlBatchHandler.java:269)
	at org.jdbi.v3.sqlobject.statement.internal.SqlBatchHandler.invoke(SqlBatchHandler.java:174)
	at org.jdbi.v3.sqlobject.internal.SqlObjectInitData$1.lambda$invoke$0(SqlObjectInitData.java:125)
	at org.jdbi.v3.core.internal.Invocations.invokeWith(Invocations.java:44)
	at org.jdbi.v3.core.ConstantHandleSupplier.lambda$invokeInContext$0(ConstantHandleSupplier.java:56)
	at org.jdbi.v3.core.internal.Invocations.invokeWith(Invocations.java:44)
	at org.jdbi.v3.core.ConstantHandleSupplier.invokeInContext(ConstantHandleSupplier.java:52)
	at org.jdbi.v3.sqlobject.internal.SqlObjectInitData$1.call(SqlObjectInitData.java:131)
	at org.jdbi.v3.sqlobject.internal.SqlObjectInitData$1.invoke(SqlObjectInitData.java:125)
	at org.jdbi.v3.sqlobject.SqlObjectFactory.lambda$attach$2(SqlObjectFactory.java:110)
	at com.sun.proxy.$Proxy39.insert(Unknown Source)
@stevenschlansker
Copy link
Member

Thanks for reporting this, will be fixed in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants