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

Fix prepared statement error #1

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
56 changes: 16 additions & 40 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-mssql</artifactId>
<version>1.1.0.BUILD-SNAPSHOT</version>
<version>1.0.2.DSB</version>
<packaging>jar</packaging>

<name>Reactive Relational Database Connectivity - Microsoft SQL Server</name>
Expand All @@ -33,23 +33,22 @@

<properties>
<assertj.version>3.23.1</assertj.version>
<blockhound.version>1.0.6.RELEASE</blockhound.version>
<hikari-cp.version>4.0.3</hikari-cp.version>
<java.version>1.8</java.version>
<jsr305.version>3.0.2</jsr305.version>
<junit.version>5.9.1</junit.version>
<jmh.version>1.33</jmh.version>
<mbr.version>0.3.0.RELEASE</mbr.version>
<logback.version>1.2.11</logback.version>
<mockito.version>4.8.1</mockito.version>
<mssql-jdbc.version>11.1.2.jre8-preview</mssql-jdbc.version>
<mockito.version>4.11.0</mockito.version>
<mssql-jdbc.version>12.2.0.jre8</mssql-jdbc.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<r2dbc-spi.version>1.0.0.RELEASE</r2dbc-spi.version>
<r2dbc-pool.version>1.0.0.RELEASE</r2dbc-pool.version>
<reactor.version>2022.0.0</reactor.version>
<spring-framework.version>5.3.23</spring-framework.version>
<testcontainers.version>1.17.5</testcontainers.version>
<r2dbc-pool.version>1.0.1.RELEASE</r2dbc-pool.version>
<reactor.version>2022.0.9</reactor.version>
<spring-framework.version>5.3.29</spring-framework.version>
<testcontainers.version>1.18.3</testcontainers.version>
</properties>

<licenses>
Expand Down Expand Up @@ -135,12 +134,6 @@
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor.tools</groupId>
<artifactId>blockhound</artifactId>
<version>${blockhound.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-spi-test</artifactId>
Expand Down Expand Up @@ -216,7 +209,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.11.0</version>
<configuration>
<showWarnings>true</showWarnings>
<source>${java.version}</source>
Expand All @@ -243,12 +236,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
<executions>
<execution>
<id>enforce-no-snapshots</id>
Expand All @@ -269,7 +262,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<version>3.5.0</version>
<configuration>
<excludePackageNames>
io.r2dbc.mssql.authentication,io.r2dbc.mssql.client,io.r2dbc.mssql.codec,io.r2dbc.mssql.message,io.r2dbc.mssql.util
Expand All @@ -292,7 +285,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -305,7 +298,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.1.2</version>
<configuration>
<runOrder>random</runOrder>
<excludes>
Expand All @@ -320,7 +313,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
<version>3.1.2</version>
<executions>
<execution>
<goals>
Expand All @@ -341,7 +334,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.3.0</version>
<version>1.5.0</version>
<executions>
<execution>
<id>flatten</id>
Expand Down Expand Up @@ -388,22 +381,6 @@

<profiles>

<profile>
<id>java18-blockhound</id>
<activation>
<jdk>1.8</jdk>
</activation>

<dependencies>
<dependency>
<groupId>io.projectreactor.tools</groupId>
<artifactId>blockhound-junit-platform</artifactId>
<version>${blockhound.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>

<profile>
<id>jmh</id>
<dependencies>
Expand Down Expand Up @@ -517,7 +494,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down Expand Up @@ -547,7 +524,6 @@
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
<keepStagingRepositoryOnFailure>true</keepStagingRepositoryOnFailure>
<skipStagingRepositoryClose>true</skipStagingRepositoryClose>
</configuration>
</plugin>
</plugins>
Expand Down
4 changes: 2 additions & 2 deletions src/jmh/java/io/r2dbc/mssql/codec/BinaryCodecBenchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public Encoded encodeByteBuffer() {
@Benchmark
public Encoded encodeNull() {
Encoded encoded = codecs.encodeNull(alloc, byte[].class);
encoded.release();
encoded.dispose();
return encoded;
}

private Encoded doEncode(Object value) {
Encoded encoded = codecs.encode(alloc, RpcParameterContext.in(), value);
encoded.release();
encoded.dispose();
return encoded;
}
}
4 changes: 2 additions & 2 deletions src/jmh/java/io/r2dbc/mssql/codec/BooleanCodecBenchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public Encoded encode() {
@Benchmark
public Encoded encodeNull() {
Encoded encoded = codecs.encodeNull(alloc, Boolean.class);
encoded.release();
encoded.dispose();
return encoded;
}

private Encoded doEncode(Object value) {
Encoded encoded = codecs.encode(alloc, RpcParameterContext.in(), value);
encoded.release();
encoded.dispose();
return encoded;
}
}
4 changes: 2 additions & 2 deletions src/jmh/java/io/r2dbc/mssql/codec/ByteCodecBenchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public Encoded encode() {
@Benchmark
public Encoded encodeNull() {
Encoded encoded = codecs.encodeNull(alloc, Byte.class);
encoded.release();
encoded.dispose();
return encoded;
}

private Encoded doEncode(Object value) {
Encoded encoded = codecs.encode(alloc, RpcParameterContext.in(), value);
encoded.release();
encoded.dispose();
return encoded;
}
}
4 changes: 2 additions & 2 deletions src/jmh/java/io/r2dbc/mssql/codec/DecimalCodecBenchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public Encoded encode() {
@Benchmark
public Encoded encodeNull() {
Encoded encoded = codecs.encodeNull(alloc, BigDecimal.class);
encoded.release();
encoded.dispose();
return encoded;
}

private Encoded doEncode(Object value) {
Encoded encoded = codecs.encode(alloc, RpcParameterContext.in(), value);
encoded.release();
encoded.dispose();
return encoded;
}
}
4 changes: 2 additions & 2 deletions src/jmh/java/io/r2dbc/mssql/codec/DoubleCodecBenchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public Encoded encode() {
@Benchmark
public Encoded encodeNull() {
Encoded encoded = codecs.encodeNull(alloc, Double.class);
encoded.release();
encoded.dispose();
return encoded;
}

private Encoded doEncode(Object value) {
Encoded encoded = codecs.encode(alloc, RpcParameterContext.in(), value);
encoded.release();
encoded.dispose();
return encoded;
}
}
4 changes: 2 additions & 2 deletions src/jmh/java/io/r2dbc/mssql/codec/IntegerCodecBenchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public Encoded encode() {
@Benchmark
public Encoded encodeNull() {
Encoded encoded = codecs.encodeNull(alloc, Integer.class);
encoded.release();
encoded.dispose();
return encoded;
}

private Encoded doEncode(Object value) {
Encoded encoded = codecs.encode(alloc, RpcParameterContext.in(), value);
encoded.release();
encoded.dispose();
return encoded;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public Encoded encode() {
@Benchmark
public Encoded encodeNull() {
Encoded encoded = codecs.encodeNull(alloc, LocalDate.class);
encoded.release();
encoded.dispose();
return encoded;
}

private Encoded doEncode(Object value) {
Encoded encoded = codecs.encode(alloc, RpcParameterContext.in(), value);
encoded.release();
encoded.dispose();
return encoded;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ public Encoded encode() {
@Benchmark
public Encoded encodeNull() {
Encoded encoded = codecs.encodeNull(alloc, LocalDateTime.class);
encoded.release();
encoded.dispose();
return encoded;
}

private Encoded doEncode(Object value) {
Encoded encoded = codecs.encode(alloc, RpcParameterContext.in(), value);
encoded.release();
encoded.dispose();
return encoded;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public Encoded encode() {
@Benchmark
public Encoded encodeNull() {
Encoded encoded = codecs.encodeNull(alloc, LocalTime.class);
encoded.release();
encoded.dispose();
return encoded;
}

private Encoded doEncode(Object value) {
Encoded encoded = codecs.encode(alloc, RpcParameterContext.in(), value);
encoded.release();
encoded.dispose();
return encoded;
}
}
4 changes: 2 additions & 2 deletions src/jmh/java/io/r2dbc/mssql/codec/LongCodecBenchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public Encoded encode() {
@Benchmark
public Encoded encodeNull() {
Encoded encoded = codecs.encodeNull(alloc, Long.class);
encoded.release();
encoded.dispose();
return encoded;
}

private Encoded doEncode(Object value) {
Encoded encoded = codecs.encode(alloc, RpcParameterContext.in(), value);
encoded.release();
encoded.dispose();
return encoded;
}
}
4 changes: 2 additions & 2 deletions src/jmh/java/io/r2dbc/mssql/codec/ShortCodecBenchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public Encoded encode() {
@Benchmark
public Encoded encodeNull() {
Encoded encoded = codecs.encodeNull(alloc, Short.class);
encoded.release();
encoded.dispose();
return encoded;
}

private Encoded doEncode(Object value) {
Encoded encoded = codecs.encode(alloc, RpcParameterContext.in(), value);
encoded.release();
encoded.dispose();
return encoded;
}
}
4 changes: 2 additions & 2 deletions src/jmh/java/io/r2dbc/mssql/codec/StringCodecBenchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ public String decodeUuid() {
@Benchmark
public Encoded encodeNull() {
Encoded encoded = codecs.encodeNull(TestByteBufAllocator.TEST, String.class);
encoded.release();
encoded.dispose();
return encoded;
}

private Encoded doEncode(Collation collation, Object value) {
Encoded encoded = codecs.encode(TestByteBufAllocator.TEST, RpcParameterContext.in(ValueContext.character(collation, true)), value);
encoded.release();
encoded.dispose();
return encoded;
}
}
4 changes: 2 additions & 2 deletions src/jmh/java/io/r2dbc/mssql/codec/UuidCodecBenchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public Encoded encode() {
@Benchmark
public Encoded encodeNull() {
Encoded encoded = codecs.encodeNull(alloc, UUID.class);
encoded.release();
encoded.dispose();
return encoded;
}

private Encoded doEncode(Object value) {
Encoded encoded = codecs.encode(alloc, RpcParameterContext.in(), value);
encoded.release();
encoded.dispose();
return encoded;
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/r2dbc/mssql/Binding.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ boolean hasOutParameters() {
void clear() {

this.parameters.forEach((s, parameter) -> {
while (parameter.encoded.refCnt() > 0) {
parameter.encoded.release();
if (!parameter.encoded.isDisposed()) {
parameter.encoded.dispose();
}
});

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/io/r2dbc/mssql/ConnectionOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package io.r2dbc.mssql;

import io.r2dbc.mssql.codec.Codecs;
import io.r2dbc.mssql.codec.DefaultCodecs;
import reactor.util.annotation.Nullable;

import java.time.Duration;
Expand All @@ -37,6 +38,10 @@ class ConnectionOptions {

private volatile Duration statementTimeout = Duration.ZERO;

ConnectionOptions() {
this(sql -> false, new DefaultCodecs(), new IndefinitePreparedStatementCache(), true);
}

ConnectionOptions(Predicate<String> preferCursoredExecution, Codecs codecs, PreparedStatementCache preparedStatementCache, boolean sendStringParametersAsUnicode) {
this.preferCursoredExecution = preferCursoredExecution;
this.codecs = codecs;
Expand Down
Loading