From 389b1f0310a3d45b03142cbc795a62b8bdceeb56 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Wed, 16 Jun 2021 18:03:01 +0200 Subject: [PATCH 01/20] [R2DBC-24] default conversion of Bit(1)/TINYINT(1) to Boolean new option `tinyInt1isBit` to disable that behavior --- .../java/org/mariadb/r2dbc/MariadbBatch.java | 3 +- ...iadbClientParameterizedQueryStatement.java | 6 ++- .../r2dbc/MariadbConnectionConfiguration.java | 33 +++++++++++++++- .../MariadbConnectionFactoryProvider.java | 1 + .../java/org/mariadb/r2dbc/MariadbResult.java | 11 ++++-- ...iadbServerParameterizedQueryStatement.java | 9 +++-- .../r2dbc/MariadbSimpleQueryStatement.java | 3 +- .../java/org/mariadb/r2dbc/client/Client.java | 2 + .../org/mariadb/r2dbc/client/ClientBase.java | 4 ++ .../mariadb/r2dbc/codec/BinaryRowDecoder.java | 8 ++-- .../org/mariadb/r2dbc/codec/RowDecoder.java | 6 ++- .../mariadb/r2dbc/codec/TextRowDecoder.java | 8 ++-- .../mariadb/r2dbc/codec/list/BlobCodec.java | 5 +-- .../server/ColumnDefinitionPacket.java | 7 +++- .../r2dbc/util/DefaultHostnameVerifier.java | 14 ++----- .../r2dbc/integration/codec/BitParseTest.java | 39 +++++++++++++++++++ .../integration/codec/TinyIntParseTest.java | 36 +++++++++++++++++ .../parameter/BitParameterTest.java | 2 +- 18 files changed, 161 insertions(+), 36 deletions(-) diff --git a/src/main/java/org/mariadb/r2dbc/MariadbBatch.java b/src/main/java/org/mariadb/r2dbc/MariadbBatch.java index aeaa61fb..d0123439 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbBatch.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbBatch.java @@ -78,7 +78,8 @@ public Flux execute() { dataRow, ExceptionFactory.INSTANCE, null, - client.getVersion().supportReturning())); + client.getVersion().supportReturning(), + client.getConf())); } } } diff --git a/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java index c4aa08b5..cb6e9cf5 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java @@ -169,7 +169,8 @@ public Flux execute() { dataRow, ExceptionFactory.INSTANCE, generatedColumns, - client.getVersion().supportReturning())); + client.getVersion().supportReturning(), + client.getConf())); } } @@ -212,7 +213,8 @@ private Flux execute( dataRow, factory, generatedColumns, - client.getVersion().supportReturning())); + client.getVersion().supportReturning(), + client.getConf())); return response.concatWith( Flux.create( sink -> { diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java index c3101f65..8755a0a3 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java @@ -56,6 +56,7 @@ public final class MariadbConnectionConfiguration { private IsolationLevel isolationLevel; private final boolean useServerPrepStmts; private final boolean autocommit; + private final boolean tinyInt1isBit; private MariadbConnectionConfiguration( @Nullable Duration connectTimeout, @@ -84,7 +85,8 @@ private MariadbConnectionConfiguration( boolean useServerPrepStmts, boolean autocommit, @Nullable Integer prepareCacheSize, - @Nullable CharSequence[] pamOtherPwd) { + @Nullable CharSequence[] pamOtherPwd, + boolean tinyInt1isBit) { this.connectTimeout = connectTimeout == null ? Duration.ofSeconds(10) : connectTimeout; this.socketTimeout = socketTimeout; this.tcpKeepAlive = tcpKeepAlive == null ? Boolean.FALSE : tcpKeepAlive; @@ -113,6 +115,7 @@ private MariadbConnectionConfiguration( this.prepareCacheSize = (prepareCacheSize == null) ? 250 : prepareCacheSize.intValue(); this.pamOtherPwd = pamOtherPwd; this.autocommit = autocommit; + this.tinyInt1isBit = tinyInt1isBit; } static boolean boolValue(Object value) { @@ -206,6 +209,12 @@ public static Builder fromOptions(ConnectionFactoryOptions connectionFactoryOpti boolValue( connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.AUTO_COMMIT))); } + if (connectionFactoryOptions.hasOption(MariadbConnectionFactoryProvider.TINY_IS_BIT)) { + builder.tinyInt1isBit( + boolValue( + connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.TINY_IS_BIT))); + } + if (connectionFactoryOptions.hasOption( MariadbConnectionFactoryProvider.CONNECTION_ATTRIBUTES)) { Map myMap = new HashMap<>(); @@ -358,6 +367,10 @@ public boolean autocommit() { return autocommit; } + public boolean tinyInt1isBit() { + return tinyInt1isBit; + } + public int getPrepareCacheSize() { return prepareCacheSize; } @@ -444,6 +457,8 @@ public String toString() { + useServerPrepStmts + ", autocommit=" + autocommit + + ", tinyInt1isBit=" + + tinyInt1isBit + ", pamOtherPwd=" + hiddenPamPwd + '}'; @@ -475,6 +490,7 @@ public static final class Builder implements Cloneable { private boolean allowPipelining = true; private boolean useServerPrepStmts = false; private boolean autocommit = true; + private boolean tinyInt1isBit = true; @Nullable Integer prepareCacheSize; @Nullable private List tlsProtocol; @Nullable private String serverSslCert; @@ -533,7 +549,8 @@ public MariadbConnectionConfiguration build() { this.useServerPrepStmts, this.autocommit, this.prepareCacheSize, - this.pamOtherPwd); + this.pamOtherPwd, + this.tinyInt1isBit); } /** @@ -768,6 +785,18 @@ public Builder autocommit(boolean autocommit) { return this; } + /** + * Permit to indicate how BIT(1) must return as boolean or byte . Default value True (returns + * boolean). + * + * @param tinyInt1isBit return boolean for BIT(1) + * @return this {@link Builder} + */ + public Builder tinyInt1isBit(boolean tinyInt1isBit) { + this.tinyInt1isBit = tinyInt1isBit; + return this; + } + /** * Permit pipelining (sending request before resolution of previous one). * diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java index 8d0d47fc..69eea41c 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java @@ -34,6 +34,7 @@ public final class MariadbConnectionFactoryProvider implements ConnectionFactory public static final Option ALLOW_PIPELINING = Option.valueOf("allowPipelining"); public static final Option USE_SERVER_PREPARE = Option.valueOf("useServerPrepStmts"); public static final Option AUTO_COMMIT = Option.valueOf("autoCommit"); + public static final Option TINY_IS_BIT = Option.valueOf("tinyInt1isBit"); public static final Option PREPARE_CACHE_SIZE = Option.valueOf("prepareCacheSize"); public static final Option SSL_MODE = Option.valueOf("sslMode"); public static final Option CONNECTION_ATTRIBUTES = Option.valueOf("connectionAttributes"); diff --git a/src/main/java/org/mariadb/r2dbc/MariadbResult.java b/src/main/java/org/mariadb/r2dbc/MariadbResult.java index c8f15883..4b906e92 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbResult.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbResult.java @@ -37,6 +37,7 @@ final class MariadbResult implements org.mariadb.r2dbc.api.MariadbResult { private final String[] generatedColumns; private final boolean supportReturning; private final boolean text; + private final MariadbConnectionConfiguration conf; private volatile ColumnDefinitionPacket[] metadataList; private volatile int metadataIndex; @@ -48,12 +49,14 @@ final class MariadbResult implements org.mariadb.r2dbc.api.MariadbResult { Flux dataRows, ExceptionFactory factory, String[] generatedColumns, - boolean supportReturning) { + boolean supportReturning, + MariadbConnectionConfiguration conf) { this.text = text; this.dataRows = dataRows; this.factory = factory; this.generatedColumns = generatedColumns; this.supportReturning = supportReturning; + this.conf = conf; } @Override @@ -101,8 +104,8 @@ public Flux map(BiFunction f) { rowMetadata = MariadbRowMetadata.toRowMetadata(this.metadataList); this.decoder = text - ? new TextRowDecoder(columnNumber, this.metadataList) - : new BinaryRowDecoder(columnNumber, this.metadataList); + ? new TextRowDecoder(columnNumber, this.metadataList, this.conf) + : new BinaryRowDecoder(columnNumber, this.metadataList, this.conf); } return; } @@ -140,7 +143,7 @@ public Flux map(BiFunction f) { return; } ByteBuf buf = getLongTextEncoded(okPacket.getLastInsertId()); - decoder = new TextRowDecoder(1, this.metadataList); + decoder = new TextRowDecoder(1, this.metadataList, this.conf); try { sink.next(f.apply(new MariadbRow(metadataList, decoder, buf), rowMetadata)); } finally { diff --git a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java index 073bd617..8768c797 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java @@ -233,7 +233,8 @@ public Flux execute() { dataRow, ExceptionFactory.INSTANCE, null, - client.getVersion().supportReturning())); + client.getVersion().supportReturning(), + client.getConf())); } } @@ -330,7 +331,8 @@ private Flux sendPrepareAndExecute( dataRow, factory, generatedColumns, - client.getVersion().supportReturning())); + client.getVersion().supportReturning(), + client.getConf())); } private Mono sendPrepare(String sql) { @@ -365,7 +367,8 @@ private Flux sendExecuteCmd( dataRow, factory, generatedColumns, - client.getVersion().supportReturning())); + client.getVersion().supportReturning(), + client.getConf())); } @Override diff --git a/src/main/java/org/mariadb/r2dbc/MariadbSimpleQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbSimpleQueryStatement.java index cbd6d2f4..83edf99e 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbSimpleQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbSimpleQueryStatement.java @@ -132,6 +132,7 @@ private Flux execute(String sql, String[] g dataRow, factory, generatedColumns, - client.getVersion().supportReturning())); + client.getVersion().supportReturning(), + client.getConf())); } } diff --git a/src/main/java/org/mariadb/r2dbc/client/Client.java b/src/main/java/org/mariadb/r2dbc/client/Client.java index 7bbe46b1..04a57e00 100644 --- a/src/main/java/org/mariadb/r2dbc/client/Client.java +++ b/src/main/java/org/mariadb/r2dbc/client/Client.java @@ -58,6 +58,8 @@ Mono sendSslRequest( void sendNext(); + MariadbConnectionConfiguration getConf(); + PrepareCache getPrepareCache(); Mono beginTransaction(); diff --git a/src/main/java/org/mariadb/r2dbc/client/ClientBase.java b/src/main/java/org/mariadb/r2dbc/client/ClientBase.java index 3acfd57f..7e8ccfea 100644 --- a/src/main/java/org/mariadb/r2dbc/client/ClientBase.java +++ b/src/main/java/org/mariadb/r2dbc/client/ClientBase.java @@ -391,6 +391,10 @@ private void clearWaitingListWithError(Throwable exception) { } } + public MariadbConnectionConfiguration getConf() { + return configuration; + } + public abstract void sendNext(); public PrepareCache getPrepareCache() { diff --git a/src/main/java/org/mariadb/r2dbc/codec/BinaryRowDecoder.java b/src/main/java/org/mariadb/r2dbc/codec/BinaryRowDecoder.java index 6c082d68..9990454a 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/BinaryRowDecoder.java +++ b/src/main/java/org/mariadb/r2dbc/codec/BinaryRowDecoder.java @@ -17,6 +17,7 @@ package org.mariadb.r2dbc.codec; import io.netty.buffer.ByteBuf; +import org.mariadb.r2dbc.MariadbConnectionConfiguration; import org.mariadb.r2dbc.message.server.ColumnDefinitionPacket; public class BinaryRowDecoder extends RowDecoder { @@ -25,8 +26,9 @@ public class BinaryRowDecoder extends RowDecoder { private ColumnDefinitionPacket[] columns; private byte[] nullBitmap; - public BinaryRowDecoder(int columnNumber, ColumnDefinitionPacket[] columns) { - super(); + public BinaryRowDecoder( + int columnNumber, ColumnDefinitionPacket[] columns, MariadbConnectionConfiguration conf) { + super(conf); this.columns = columns; this.columnNumber = columnNumber; } @@ -48,7 +50,7 @@ public T get(int index, ColumnDefinitionPacket column, Class type) // type generic, return "natural" java type if (Object.class == type || type == null) { - Codec defaultCodec = ((Codec) column.getDefaultCodec()); + Codec defaultCodec = ((Codec) column.getDefaultCodec(conf)); return defaultCodec.decodeBinary(buf, length, column, type); } diff --git a/src/main/java/org/mariadb/r2dbc/codec/RowDecoder.java b/src/main/java/org/mariadb/r2dbc/codec/RowDecoder.java index 4ac64fcd..3bdf48d3 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/RowDecoder.java +++ b/src/main/java/org/mariadb/r2dbc/codec/RowDecoder.java @@ -18,6 +18,7 @@ import io.netty.buffer.ByteBuf; import java.util.EnumSet; +import org.mariadb.r2dbc.MariadbConnectionConfiguration; import org.mariadb.r2dbc.message.server.ColumnDefinitionPacket; public abstract class RowDecoder { @@ -26,8 +27,11 @@ public abstract class RowDecoder { public ByteBuf buf; protected int length; protected int index; + protected MariadbConnectionConfiguration conf; - public RowDecoder() {} + public RowDecoder(MariadbConnectionConfiguration conf) { + this.conf = conf; + } public void resetRow(ByteBuf buf) { this.buf = buf; diff --git a/src/main/java/org/mariadb/r2dbc/codec/TextRowDecoder.java b/src/main/java/org/mariadb/r2dbc/codec/TextRowDecoder.java index da7aebc7..10c3d417 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/TextRowDecoder.java +++ b/src/main/java/org/mariadb/r2dbc/codec/TextRowDecoder.java @@ -16,12 +16,14 @@ package org.mariadb.r2dbc.codec; +import org.mariadb.r2dbc.MariadbConnectionConfiguration; import org.mariadb.r2dbc.message.server.ColumnDefinitionPacket; public class TextRowDecoder extends RowDecoder { - public TextRowDecoder(int columnNumber, ColumnDefinitionPacket[] columns) { - super(); + public TextRowDecoder( + int columnNumber, ColumnDefinitionPacket[] columns, MariadbConnectionConfiguration conf) { + super(conf); } @SuppressWarnings("unchecked") @@ -39,7 +41,7 @@ public T get(int index, ColumnDefinitionPacket column, Class type) // type generic, return "natural" java type if (Object.class == type || type == null) { - Codec defaultCodec = ((Codec) column.getDefaultCodec()); + Codec defaultCodec = ((Codec) column.getDefaultCodec(conf)); return defaultCodec.decodeText(buf, length, column, type); } diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/BlobCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/BlobCodec.java index 05ccc600..a37af3a0 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/BlobCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/BlobCodec.java @@ -52,10 +52,7 @@ public boolean canDecode(ColumnDefinitionPacket column, Class type) { @Override public Blob decodeText( - ByteBuf buf, - int length, - ColumnDefinitionPacket column, - Class type) { + ByteBuf buf, int length, ColumnDefinitionPacket column, Class type) { switch (column.getType()) { case STRING: case VARCHAR: diff --git a/src/main/java/org/mariadb/r2dbc/message/server/ColumnDefinitionPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/ColumnDefinitionPacket.java index 11acecbc..1eb7610c 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/ColumnDefinitionPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/ColumnDefinitionPacket.java @@ -27,6 +27,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.BitSet; +import org.mariadb.r2dbc.MariadbConnectionConfiguration; import org.mariadb.r2dbc.client.Context; import org.mariadb.r2dbc.codec.Codec; import org.mariadb.r2dbc.codec.DataType; @@ -291,7 +292,7 @@ public Class getJavaClass() { } } - public Codec getDefaultCodec() { + public Codec getDefaultCodec(MariadbConnectionConfiguration conf) { switch (dataType) { case VARCHAR: case JSON: @@ -301,6 +302,8 @@ public Codec getDefaultCodec() { case STRING: return isBinary() ? ByteArrayCodec.INSTANCE : StringCodec.INSTANCE; case TINYINT: + // TINYINT(1) are considered as boolean + if (length == 1 && conf.tinyInt1isBit()) return BooleanCodec.INSTANCE; return isSigned() ? ByteCodec.INSTANCE : ShortCodec.INSTANCE; case SMALLINT: return isSigned() ? ShortCodec.INSTANCE : IntCodec.INSTANCE; @@ -328,6 +331,8 @@ public Codec getDefaultCodec() { case DECIMAL: return BigDecimalCodec.INSTANCE; case BIT: + // BIT(1) are considered as boolean + if (length == 1 && conf.tinyInt1isBit()) return BooleanCodec.INSTANCE; return BitSetCodec.INSTANCE; case GEOMETRY: return ByteArrayCodec.INSTANCE; diff --git a/src/main/java/org/mariadb/r2dbc/util/DefaultHostnameVerifier.java b/src/main/java/org/mariadb/r2dbc/util/DefaultHostnameVerifier.java index 5a3ec605..3fdcd44b 100644 --- a/src/main/java/org/mariadb/r2dbc/util/DefaultHostnameVerifier.java +++ b/src/main/java/org/mariadb/r2dbc/util/DefaultHostnameVerifier.java @@ -156,8 +156,7 @@ private static String normalizedHostMsg(String normalizedHost) { private SubjectAltNames getSubjectAltNames(X509Certificate cert) throws CertificateParsingException { Collection> entries = cert.getSubjectAlternativeNames(); - SubjectAltNames subjectAltNames = - new SubjectAltNames(); + SubjectAltNames subjectAltNames = new SubjectAltNames(); if (entries != null) { for (List entry : entries) { if (entry.size() >= 2) { @@ -167,18 +166,14 @@ private SubjectAltNames getSubjectAltNames(X509Certificate cert) String altNameDns = (String) entry.get(1); if (altNameDns != null) { String normalizedSubjectAlt = altNameDns.toLowerCase(Locale.ROOT); - subjectAltNames.add( - new GeneralName( - normalizedSubjectAlt, Extension.DNS)); + subjectAltNames.add(new GeneralName(normalizedSubjectAlt, Extension.DNS)); } } if (type == 7) { // IP String altNameIp = (String) entry.get(1); if (altNameIp != null) { - subjectAltNames.add( - new GeneralName( - altNameIp, Extension.IP)); + subjectAltNames.add(new GeneralName(altNameIp, Extension.IP)); } } } @@ -249,8 +244,7 @@ public void verify(String host, X509Certificate cert, long serverThreadId) throw lowerCaseHost); } - if (entry.extension == Extension.IP - && lowerCaseHost.equals(entry.value)) { + if (entry.extension == Extension.IP && lowerCaseHost.equals(entry.value)) { return; } } diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/BitParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/BitParseTest.java index 9a0a92b6..bbc82a58 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/BitParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/BitParseTest.java @@ -25,6 +25,9 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.mariadb.r2dbc.BaseConnectionTest; +import org.mariadb.r2dbc.MariadbConnectionConfiguration; +import org.mariadb.r2dbc.MariadbConnectionFactory; +import org.mariadb.r2dbc.TestConfiguration; import org.mariadb.r2dbc.api.MariadbConnection; import reactor.test.StepVerifier; @@ -35,17 +38,23 @@ public static void before2() { .createStatement("CREATE TABLE BitTable (t1 BIT(16), t2 int, t3 BIT(3))") .execute() .blockLast(); + sharedConn.createStatement("CREATE TABLE BitTable2 (t1 BIT(1))").execute().blockLast(); sharedConn .createStatement( "INSERT INTO BitTable VALUES (b'0000', 1, b'0'), (b'0000000100000000', 2, b'1'),(b'0000111100000000', 3, b'10'),(b'1010', 4, b'11'), (null, 5, b'100')") .execute() .blockLast(); + sharedConn + .createStatement("INSERT INTO BitTable2 VALUES (b'0'), (true), (null)") + .execute() + .blockLast(); sharedConn.createStatement("FLUSH TABLES").execute().blockLast(); } @AfterAll public static void afterAll2() { sharedConn.createStatement("DROP TABLE BitTable").execute().blockLast(); + sharedConn.createStatement("DROP TABLE BitTable2").execute().blockLast(); } @Test @@ -58,6 +67,28 @@ void defaultValuePrepare() { defaultValue(sharedConnPrepare); } + @Test + void defaultValueNoTiny() throws Throwable { + MariadbConnectionConfiguration conf = + TestConfiguration.defaultBuilder.clone().tinyInt1isBit(false).build(); + MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); + try { + connection + .createStatement("SELECT t1 FROM BitTable2 WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0)))) + .as(StepVerifier::create) + .expectNext( + Optional.of(BitSet.valueOf(new byte[] {(byte) 0})), + Optional.of(BitSet.valueOf(new byte[] {(byte) 1})), + Optional.empty()) + .verifyComplete(); + } finally { + connection.close().block(); + } + } + private void defaultValue(MariadbConnection connection) { connection .createStatement("SELECT t1, t2 FROM BitTable WHERE 1 = ?") @@ -80,6 +111,14 @@ private void defaultValue(MariadbConnection connection) { Optional.of(BitSet.valueOf(new byte[] {(byte) 10})), Optional.empty()) .verifyComplete(); + connection + .createStatement("SELECT t1 FROM BitTable2 WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0)))) + .as(StepVerifier::create) + .expectNext(Optional.of(Boolean.FALSE), Optional.of(Boolean.TRUE), Optional.empty()) + .verifyComplete(); } @Test diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/TinyIntParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/TinyIntParseTest.java index a8b72489..ef1a2d0f 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/TinyIntParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/TinyIntParseTest.java @@ -25,6 +25,9 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.mariadb.r2dbc.BaseConnectionTest; +import org.mariadb.r2dbc.MariadbConnectionConfiguration; +import org.mariadb.r2dbc.MariadbConnectionFactory; +import org.mariadb.r2dbc.TestConfiguration; import org.mariadb.r2dbc.api.MariadbConnection; import reactor.test.StepVerifier; @@ -47,6 +50,11 @@ public static void before2() { .createStatement("INSERT INTO tinyIntUnsignedTable VALUES (0), (1), (255), (null)") .execute() .blockLast(); + sharedConn.createStatement("CREATE TABLE tinyIntTable1 (t1 TINYINT(1))").execute().blockLast(); + sharedConn + .createStatement("INSERT INTO tinyIntTable1 VALUES (0),(1),(null)") + .execute() + .blockLast(); sharedConn.createStatement("FLUSH TABLES").execute().blockLast(); } @@ -54,6 +62,7 @@ public static void before2() { public static void afterAll2() { sharedConn.createStatement("DROP TABLE tinyIntTable").execute().blockLast(); sharedConn.createStatement("DROP TABLE tinyIntUnsignedTable").execute().blockLast(); + sharedConn.createStatement("DROP TABLE tinyIntTable1").execute().blockLast(); } @Test @@ -66,6 +75,25 @@ void defaultValuePrepare() { defaultValue(sharedConnPrepare); } + @Test + void defaultValueNoTiny() throws Throwable { + MariadbConnectionConfiguration conf = + TestConfiguration.defaultBuilder.clone().tinyInt1isBit(false).build(); + MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); + try { + connection + .createStatement("SELECT t1 FROM tinyIntTable1 WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0)))) + .as(StepVerifier::create) + .expectNext(Optional.of((byte) 0), Optional.of((byte) 1), Optional.empty()) + .verifyComplete(); + } finally { + connection.close().block(); + } + } + private void defaultValue(MariadbConnection connection) { connection .createStatement("SELECT t1 FROM tinyIntTable WHERE 1 = ?") @@ -88,6 +116,14 @@ private void defaultValue(MariadbConnection connection) { Optional.of((short) 255), Optional.empty()) .verifyComplete(); + connection + .createStatement("SELECT t1 FROM tinyIntTable1 WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0)))) + .as(StepVerifier::create) + .expectNext(Optional.of(Boolean.FALSE), Optional.of(Boolean.TRUE), Optional.empty()) + .verifyComplete(); } @Test diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/BitParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/BitParameterTest.java index e926253d..b29d25b4 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/BitParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/BitParameterTest.java @@ -43,7 +43,7 @@ public class BitParameterTest extends BaseConnectionTest { @BeforeAll public static void before2() { sharedConn - .createStatement("CREATE TABLE ByteParam (t1 BIT(4), t2 BIT(20), t3 BIT(1))") + .createStatement("CREATE TABLE ByteParam (t1 BIT(4), t2 BIT(20), t3 BIT(2))") .execute() .blockLast(); } From af464bdca2f05b0a9c044164528a39f74a42225c Mon Sep 17 00:00:00 2001 From: kolzeq Date: Thu, 17 Jun 2021 14:29:46 +0200 Subject: [PATCH 02/20] [R2DBC-22] adding bind parameter example in README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ebe95ce0..ee0be168 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,8 @@ Basic example: MariadbConnectionFactory factory = new MariadbConnectionFactory(conf); MariadbConnection connection = factory.create().block(); - connection.createStatement("SELECT * FROM myTable") + connection.createStatement("SELECT * FROM myTable WHERE val = ?") + .bind(0, "myVal") // setting parameter .execute() .flatMap(r -> r.map((row, metadata) -> { return "value=" + row.get(0, String.class); From 3f63f0b5627a6d695d950e50d4939fae276f6b72 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Mon, 21 Jun 2021 14:45:44 +0200 Subject: [PATCH 03/20] [R2DBC-10] support 10.6 new feature metadata skip --- .../java/org/mariadb/r2dbc/MariadbBatch.java | 1 + ...iadbClientParameterizedQueryStatement.java | 2 + .../java/org/mariadb/r2dbc/MariadbResult.java | 21 +- ...iadbServerParameterizedQueryStatement.java | 86 ++++---- .../r2dbc/MariadbSimpleQueryStatement.java | 1 + .../mariadb/r2dbc/client/DecoderState.java | 189 +++++++++++------- .../r2dbc/client/MariadbPacketDecoder.java | 37 ++++ .../message/flow/AuthenticationFlow.java | 3 +- .../message/server/ColumnCountPacket.java | 15 +- .../message/server/CompletePrepareResult.java | 39 ++++ .../r2dbc/message/server/ErrorPacket.java | 11 +- .../message/server/PrepareResultPacket.java | 17 +- .../r2dbc/util/ServerPrepareResult.java | 19 +- .../r2dbc/util/constants/Capabilities.java | 3 + .../integration/PrepareResultSetTest.java | 1 - 15 files changed, 310 insertions(+), 135 deletions(-) create mode 100644 src/main/java/org/mariadb/r2dbc/message/server/CompletePrepareResult.java diff --git a/src/main/java/org/mariadb/r2dbc/MariadbBatch.java b/src/main/java/org/mariadb/r2dbc/MariadbBatch.java index d0123439..4cd168ac 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbBatch.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbBatch.java @@ -75,6 +75,7 @@ public Flux execute() { dataRow -> new org.mariadb.r2dbc.MariadbResult( true, + null, dataRow, ExceptionFactory.INSTANCE, null, diff --git a/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java index cb6e9cf5..1927082e 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java @@ -166,6 +166,7 @@ public Flux execute() { dataRow -> new MariadbResult( true, + null, dataRow, ExceptionFactory.INSTANCE, generatedColumns, @@ -210,6 +211,7 @@ private Flux execute( dataRow -> new MariadbResult( true, + null, dataRow, factory, generatedColumns, diff --git a/src/main/java/org/mariadb/r2dbc/MariadbResult.java b/src/main/java/org/mariadb/r2dbc/MariadbResult.java index 4b906e92..bee1a56c 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbResult.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbResult.java @@ -21,11 +21,13 @@ import io.r2dbc.spi.Row; import io.r2dbc.spi.RowMetadata; import java.nio.charset.StandardCharsets; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.BiFunction; import org.mariadb.r2dbc.codec.BinaryRowDecoder; import org.mariadb.r2dbc.codec.RowDecoder; import org.mariadb.r2dbc.codec.TextRowDecoder; import org.mariadb.r2dbc.message.server.*; +import org.mariadb.r2dbc.util.ServerPrepareResult; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -38,6 +40,7 @@ final class MariadbResult implements org.mariadb.r2dbc.api.MariadbResult { private final boolean supportReturning; private final boolean text; private final MariadbConnectionConfiguration conf; + private AtomicReference prepareResult; private volatile ColumnDefinitionPacket[] metadataList; private volatile int metadataIndex; @@ -46,6 +49,7 @@ final class MariadbResult implements org.mariadb.r2dbc.api.MariadbResult { MariadbResult( boolean text, + AtomicReference prepareResult, Flux dataRows, ExceptionFactory factory, String[] generatedColumns, @@ -57,6 +61,7 @@ final class MariadbResult implements org.mariadb.r2dbc.api.MariadbResult { this.generatedColumns = generatedColumns; this.supportReturning = supportReturning; this.conf = conf; + this.prepareResult = prepareResult; } @Override @@ -92,9 +97,21 @@ public Flux map(BiFunction f) { return; } + if (serverMessage instanceof CompletePrepareResult) { + this.prepareResult.set(((CompletePrepareResult) serverMessage).getPrepare()); + metadataList = this.prepareResult.get().getColumns(); + return; + } + if (serverMessage instanceof ColumnCountPacket) { this.columnNumber = ((ColumnCountPacket) serverMessage).getColumnCount(); - metadataList = new ColumnDefinitionPacket[this.columnNumber]; + if (!((ColumnCountPacket) serverMessage).isMetaFollows()) { + metadataList = this.prepareResult.get().getColumns(); + rowMetadata = MariadbRowMetadata.toRowMetadata(this.metadataList); + this.decoder = new BinaryRowDecoder(columnNumber, this.metadataList, this.conf); + } else { + metadataList = new ColumnDefinitionPacket[this.columnNumber]; + } return; } @@ -127,7 +144,7 @@ public Flux map(BiFunction f) { if (serverMessage instanceof OkPacket && generatedColumns != null && !supportReturning) { - if (metadataList == null) { + if (metadataList == null || metadataList.length == 0) { String colName = generatedColumns.length > 0 ? generatedColumns[0] : "ID"; metadataList = new ColumnDefinitionPacket[1]; metadataList[0] = ColumnDefinitionPacket.fromGeneratedId(colName); diff --git a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java index 8768c797..a9fd73b2 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; import org.mariadb.r2dbc.api.MariadbStatement; import org.mariadb.r2dbc.client.Client; import org.mariadb.r2dbc.client.DecoderState; @@ -30,7 +31,7 @@ import org.mariadb.r2dbc.codec.Parameter; import org.mariadb.r2dbc.message.client.ExecutePacket; import org.mariadb.r2dbc.message.client.PreparePacket; -import org.mariadb.r2dbc.message.server.PrepareResultPacket; +import org.mariadb.r2dbc.message.server.CompletePrepareResult; import org.mariadb.r2dbc.message.server.ServerMessage; import org.mariadb.r2dbc.util.Assert; import org.mariadb.r2dbc.util.ServerPrepareResult; @@ -46,7 +47,7 @@ final class MariadbServerParameterizedQueryStatement implements MariadbStatement private Map> parameters; private List>> batchingParameters; private String[] generatedColumns; - private ServerPrepareResult prepareResult; + private AtomicReference prepareResult; MariadbServerParameterizedQueryStatement( Client client, String sql, MariadbConnectionConfiguration configuration) { @@ -54,7 +55,7 @@ final class MariadbServerParameterizedQueryStatement implements MariadbStatement this.configuration = configuration; this.initialSql = Assert.requireNonNull(sql, "sql must not be null"); this.parameters = new HashMap<>(); - this.prepareResult = client.getPrepareCache().get(sql); + this.prepareResult = new AtomicReference<>(client.getPrepareCache().get(sql)); } static boolean supports(String sql) { @@ -65,8 +66,8 @@ static boolean supports(String sql) { @Override public MariadbServerParameterizedQueryStatement add() { // check valid parameters - if (prepareResult != null) { - for (int i = 0; i < prepareResult.getNumParams(); i++) { + if (prepareResult.get() != null) { + for (int i = 0; i < prepareResult.get().getNumParams(); i++) { if (parameters.get(i) == null) { throw new IllegalArgumentException( String.format("Parameter at position %s is not set", i)); @@ -94,11 +95,11 @@ public MariadbServerParameterizedQueryStatement bind(int index, @Nullable Object String.format("wrong index value %d, index must be positive", index)); } - if (prepareResult != null && index >= prepareResult.getNumParams()) { + if (prepareResult.get() != null && index >= prepareResult.get().getNumParams()) { throw new IndexOutOfBoundsException( String.format( "index must be in 0-%d range but value is %d", - prepareResult.getNumParams() - 1, index)); + prepareResult.get().getNumParams() - 1, index)); } if (value == null) return bindNull(index, null); @@ -129,11 +130,11 @@ public MariadbServerParameterizedQueryStatement bindNull(int index, @Nullable Cl String.format("wrong index value %d, index must be positive", index)); } - if (prepareResult != null && index >= prepareResult.getNumParams()) { + if (prepareResult.get() != null && index >= prepareResult.get().getNumParams()) { throw new IndexOutOfBoundsException( String.format( "index must be in 0-%d range but value is %d", - prepareResult.getNumParams() - 1, index)); + prepareResult.get().getNumParams() - 1, index)); } Parameter parameter = null; if (type != null) { @@ -168,11 +169,10 @@ private int getColumn(String name) { } private void validateParameters() { - if (prepareResult != null) { + if (prepareResult.get() != null) { // valid parameters - for (int i = 0; i < prepareResult.getNumParams(); i++) { + for (int i = 0; i < prepareResult.get().getNumParams(); i++) { if (parameters.get(i) == null) { - prepareResult.close(client); throw new IllegalArgumentException( String.format("Parameter at position %s is not set", i)); } @@ -188,36 +188,37 @@ public Flux execute() { generatedColumns.length == 0 ? " RETURNING *" : " RETURNING " + String.join(", ", generatedColumns); - prepareResult = null; - prepareResult = client.getPrepareCache().get(sql); + prepareResult.set(client.getPrepareCache().get(sql)); } if (batchingParameters == null) { validateParameters(); return execute(sql, parameters, this.generatedColumns); } else { - if (prepareResult == null) { - prepareResult = client.getPrepareCache().get(sql); - if (prepareResult == null) { + if (prepareResult.get() == null) { + prepareResult.set(client.getPrepareCache().get(sql)); + if (prepareResult.get() == null) { sendPrepare(sql).block(); } } Flux fluxMsg = this.client.sendCommand( - new ExecutePacket(prepareResult.getStatementId(), this.batchingParameters.get(0))); + new ExecutePacket( + prepareResult.get().getStatementId(), this.batchingParameters.get(0))); int index = 1; while (index < this.batchingParameters.size()) { fluxMsg = fluxMsg.concatWith( this.client.sendCommand( new ExecutePacket( - prepareResult.getStatementId(), this.batchingParameters.get(index++)))); + prepareResult.get().getStatementId(), + this.batchingParameters.get(index++)))); } fluxMsg = fluxMsg.concatWith( Flux.create( sink -> { - prepareResult.decrementUse(client); + prepareResult.get().decrementUse(client); sink.complete(); })); @@ -230,6 +231,7 @@ public Flux execute() { dataRow -> new MariadbResult( false, + prepareResult, dataRow, ExceptionFactory.INSTANCE, null, @@ -260,31 +262,31 @@ private Flux execute( String sql, Map> parameters, String[] generatedColumns) { ExceptionFactory factory = ExceptionFactory.withSql(sql); - if (prepareResult == null && client.getPrepareCache() != null) { - prepareResult = client.getPrepareCache().get(sql); + if (prepareResult.get() == null && client.getPrepareCache() != null) { + prepareResult.set(client.getPrepareCache().get(sql)); } Flux flux; - if (prepareResult != null) { + if (prepareResult.get() != null) { validateParameters(); ServerPrepareResult res; if (this.client.getPrepareCache() != null && (res = this.client.getPrepareCache().get(sql)) != null - && !res.equals(prepareResult)) { - prepareResult.decrementUse(client); - prepareResult = res; + && !res.equals(prepareResult.get())) { + prepareResult.get().decrementUse(client); + prepareResult.set(res); } else { - if (!prepareResult.incrementUse()) { - prepareResult = null; + if (!prepareResult.get().incrementUse()) { + prepareResult.set(null); } } - if (prepareResult != null) { + if (prepareResult.get() != null) { return sendExecuteCmd(factory, parameters, generatedColumns) .concatWith( Flux.create( sink -> { - prepareResult.decrementUse(client); + prepareResult.get().decrementUse(client); sink.complete(); parameters.clear(); })); @@ -300,16 +302,16 @@ private Flux execute( sendPrepare(sql) .flatMapMany( prepareResult1 -> { - prepareResult = prepareResult1; + prepareResult.set(prepareResult1); return sendExecuteCmd(factory, parameters, generatedColumns); }); } return flux.concatWith( Flux.create( sink -> { - prepareResult = client.getPrepareCache().get(sql); - if (prepareResult != null) { - prepareResult.decrementUse(client); + prepareResult.set(client.getPrepareCache().get(sql)); + if (prepareResult.get() != null) { + prepareResult.get().decrementUse(client); } sink.complete(); parameters.clear(); @@ -328,6 +330,7 @@ private Flux sendPrepareAndExecute( dataRow -> new MariadbResult( false, + this.prepareResult, dataRow, factory, generatedColumns, @@ -341,12 +344,9 @@ private Mono sendPrepare(String sql) { .sendCommand(new PreparePacket(sql), DecoderState.PREPARE_RESPONSE, sql) .handle( (it, sink) -> { - if (it instanceof PrepareResultPacket) { - PrepareResultPacket packet = (PrepareResultPacket) it; - prepareResult = - new ServerPrepareResult( - packet.getStatementId(), packet.getNumColumns(), packet.getNumParams()); - sink.next(prepareResult); + if (it instanceof CompletePrepareResult) { + prepareResult.set(((CompletePrepareResult) it).getPrepare()); + sink.next(prepareResult.get()); } if (it.ending()) sink.complete(); }); @@ -358,12 +358,14 @@ private Flux sendExecuteCmd( return this.client .sendCommand( new ExecutePacket( - prepareResult != null ? prepareResult.getStatementId() : -1, parameters)) + prepareResult.get() != null ? prepareResult.get().getStatementId() : -1, + parameters)) .windowUntil(it -> it.resultSetEnd()) .map( dataRow -> new MariadbResult( false, + prepareResult, dataRow, factory, generatedColumns, @@ -388,7 +390,7 @@ public String toString() { + ", generatedColumns=" + (generatedColumns != null ? Arrays.toString(generatedColumns) : null) + ", prepareResult=" - + prepareResult + + prepareResult.get() + '}'; } } diff --git a/src/main/java/org/mariadb/r2dbc/MariadbSimpleQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbSimpleQueryStatement.java index 83edf99e..2277bd2a 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbSimpleQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbSimpleQueryStatement.java @@ -129,6 +129,7 @@ private Flux execute(String sql, String[] g dataRow -> new MariadbResult( true, + null, dataRow, factory, generatedColumns, diff --git a/src/main/java/org/mariadb/r2dbc/client/DecoderState.java b/src/main/java/org/mariadb/r2dbc/client/DecoderState.java index 0f9291fc..a1cebe03 100644 --- a/src/main/java/org/mariadb/r2dbc/client/DecoderState.java +++ b/src/main/java/org/mariadb/r2dbc/client/DecoderState.java @@ -17,20 +17,7 @@ package org.mariadb.r2dbc.client; import io.netty.buffer.ByteBuf; -import org.mariadb.r2dbc.message.server.AuthMoreDataPacket; -import org.mariadb.r2dbc.message.server.AuthSwitchPacket; -import org.mariadb.r2dbc.message.server.ColumnCountPacket; -import org.mariadb.r2dbc.message.server.ColumnDefinitionPacket; -import org.mariadb.r2dbc.message.server.EofPacket; -import org.mariadb.r2dbc.message.server.ErrorPacket; -import org.mariadb.r2dbc.message.server.InitialHandshakePacket; -import org.mariadb.r2dbc.message.server.OkPacket; -import org.mariadb.r2dbc.message.server.PrepareResultPacket; -import org.mariadb.r2dbc.message.server.RowPacket; -import org.mariadb.r2dbc.message.server.Sequencer; -import org.mariadb.r2dbc.message.server.ServerMessage; -import org.mariadb.r2dbc.message.server.SkipPacket; -import org.mariadb.r2dbc.util.PrepareCache; +import org.mariadb.r2dbc.message.server.*; import org.mariadb.r2dbc.util.ServerPrepareResult; import org.mariadb.r2dbc.util.constants.Capabilities; @@ -142,19 +129,24 @@ public DecoderState decoder(short val, int len, long serverCapabilities) { }, COLUMN_COUNT { + ColumnCountPacket columnCountPacket; @Override public ServerMessage decode( ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { - ColumnCountPacket columnCountPacket = - ColumnCountPacket.decode(sequencer, body, decoder.getContext()); + columnCountPacket = ColumnCountPacket.decode(sequencer, body, decoder.getContext()); decoder.setStateCounter(columnCountPacket.getColumnCount()); return columnCountPacket; } @Override public DecoderState next(MariadbPacketDecoder decoder) { - return COLUMN_DEFINITION; + if (columnCountPacket.isMetaFollows()) return COLUMN_DEFINITION; + if ((decoder.getServerCapabilities() & Capabilities.CLIENT_DEPRECATE_EOF) > 0) { + return ROW_RESPONSE; + } else { + return EOF_INTERMEDIATE_RESPONSE; + } } }, @@ -252,7 +244,6 @@ public DecoderState next(MariadbPacketDecoder decoder) { }, PREPARE_RESPONSE { - PrepareResultPacket packet; public DecoderState decoder(short val, int len, long serverCapabilities) { switch (val) { @@ -266,37 +257,34 @@ public DecoderState decoder(short val, int len, long serverCapabilities) { @Override public ServerMessage decode( ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { - packet = PrepareResultPacket.decode(sequencer, body, decoder.getContext()); - ServerPrepareResult prepareResult = - new ServerPrepareResult( - packet.getStatementId(), packet.getNumColumns(), packet.getNumParams()); - - PrepareCache prepareCache = decoder.getClient().getPrepareCache(); - if (prepareCache != null && prepareCache.put(element.getSql(), prepareResult) != null) { - // race condition, remove new one to get the one in cache - prepareResult.decrementUse(decoder.getClient()); + PrepareResultPacket packet = + PrepareResultPacket.decode(sequencer, body, decoder.getContext(), false); + decoder.setPrepare(packet); + if (packet.getNumParams() == 0 && packet.getNumColumns() == 0) { + ServerPrepareResult serverPrepareResult = decoder.endPrepare(); + return new CompletePrepareResult(serverPrepareResult, false); } - return packet; + return new SkipPacket(false); } @Override public DecoderState next(MariadbPacketDecoder decoder) { - if ((decoder.getServerCapabilities() & Capabilities.CLIENT_DEPRECATE_EOF) > 0) { - decoder.setStateCounter(packet.getNumParams() + packet.getNumColumns()); - } else { - decoder.setStateCounter( - (packet.getNumParams() > 0 ? packet.getNumParams() + 1 : 0) - + (packet.getNumColumns() > 0 ? packet.getNumColumns() + 1 : 0)); - } - if (decoder.getStateCounter() > 0) { - return SKIP; + if (decoder.getPrepare().getNumParams() == 0) { + // if next, then columns > 0 + decoder.setStateCounter(decoder.getPrepare().getNumColumns()); + return PREPARE_COLUMN; } - throw new IllegalArgumentException("unexpected state"); + // skip param and EOF if needed + decoder.setStateCounter( + decoder.getPrepare().getNumParams() + + (((decoder.getServerCapabilities() & Capabilities.CLIENT_DEPRECATE_EOF) > 0) + ? 0 + : 1)); + return PREPARE_PARAMETER; } }, PREPARE_AND_EXECUTE_RESPONSE { - PrepareResultPacket packet; public DecoderState decoder(short val, int len, long serverCapabilities) { switch (val) { @@ -310,39 +298,35 @@ public DecoderState decoder(short val, int len, long serverCapabilities) { @Override public ServerMessage decode( ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { - - packet = PrepareResultPacket.decode(sequencer, body, decoder.getContext()); - - ServerPrepareResult prepareResult = - new ServerPrepareResult( - packet.getStatementId(), packet.getNumColumns(), packet.getNumParams()); - - PrepareCache prepareCache = decoder.getClient().getPrepareCache(); - if (prepareCache != null && prepareCache.put(element.getSql(), prepareResult) != null) { - // race condition, remove new one to get the one in cache - prepareResult.decrementUse(decoder.getClient()); + decoder.setPrepare(PrepareResultPacket.decode(sequencer, body, decoder.getContext(), true)); + if (decoder.getPrepare().getNumParams() == 0 && decoder.getPrepare().getNumColumns() == 0) { + ServerPrepareResult serverPrepareResult = decoder.endPrepare(); + return new CompletePrepareResult(serverPrepareResult, true); } - - return packet; + return new SkipPacket(false); } @Override public DecoderState next(MariadbPacketDecoder decoder) { - if ((decoder.getServerCapabilities() & Capabilities.CLIENT_DEPRECATE_EOF) > 0) { - decoder.setStateCounter(packet.getNumParams() + packet.getNumColumns()); - } else { - decoder.setStateCounter( - (packet.getNumParams() > 0 ? packet.getNumParams() + 1 : 0) - + (packet.getNumColumns() > 0 ? packet.getNumColumns() + 1 : 0)); - } - if (decoder.getStateCounter() > 0) { - return SKIP_EXECUTE; + if (decoder.getPrepare().getNumParams() == 0) { + if (decoder.getPrepare().getNumColumns() == 0) { + decoder.setPrepare(null); + return QUERY_RESPONSE; + } + decoder.setStateCounter(decoder.getPrepare().getNumColumns()); + return PREPARE_COLUMN; } - return QUERY_RESPONSE; + // skip param and EOF if needed + decoder.setStateCounter( + decoder.getPrepare().getNumParams() + + (((decoder.getServerCapabilities() & Capabilities.CLIENT_DEPRECATE_EOF) > 0) + ? 0 + : 1)); + return PREPARE_PARAMETER; } }, - SKIP { + PREPARE_PARAMETER { public DecoderState decoder(short val, int len, long serverCapabilities) { return this; } @@ -351,16 +335,30 @@ public DecoderState decoder(short val, int len, long serverCapabilities) { public ServerMessage decode( ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { decoder.decrementStateCounter(); - return SkipPacket.decode(decoder.getStateCounter() == 0); + if (decoder.getStateCounter() == 0 && decoder.getPrepare().getNumColumns() == 0) { + // end parameter without columns + boolean ending = !decoder.getPrepare().isContinueOnEnd(); + ServerPrepareResult serverPrepareResult = decoder.endPrepare(); + return new CompletePrepareResult(serverPrepareResult, ending); + } + return SkipPacket.decode(false); } @Override public DecoderState next(MariadbPacketDecoder decoder) { - return SKIP; + if (decoder.getStateCounter() <= 0) { + if (decoder.getPrepare() == null) { + return QUERY_RESPONSE; + } + decoder.setStateCounter(decoder.getPrepare().getNumColumns()); + return PREPARE_COLUMN; + } + return PREPARE_PARAMETER; } }, - SKIP_EXECUTE { + PREPARE_COLUMN { + public DecoderState decoder(short val, int len, long serverCapabilities) { return this; } @@ -368,16 +366,54 @@ public DecoderState decoder(short val, int len, long serverCapabilities) { @Override public ServerMessage decode( ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { + ColumnDefinitionPacket columnDefinitionPacket = + ColumnDefinitionPacket.decode(sequencer, body, decoder.getContext(), false); + decoder + .getPrepareColumns()[ + decoder.getPrepare().getNumColumns() - decoder.getStateCounter()] = + columnDefinitionPacket; decoder.decrementStateCounter(); + + if (decoder.getStateCounter() <= 0) { + if ((decoder.getServerCapabilities() & Capabilities.CLIENT_DEPRECATE_EOF) > 0) { + boolean ending = !decoder.getPrepare().isContinueOnEnd(); + ServerPrepareResult prepareResult = decoder.endPrepare(); + return new CompletePrepareResult(prepareResult, ending); + } + } + return SkipPacket.decode(false); } @Override public DecoderState next(MariadbPacketDecoder decoder) { if (decoder.getStateCounter() <= 0) { - return QUERY_RESPONSE; + if ((decoder.getServerCapabilities() & Capabilities.CLIENT_DEPRECATE_EOF) > 0) { + return QUERY_RESPONSE; + } + return PREPARE_COLUMN_EOF; } - return SKIP_EXECUTE; + return this; + } + }, + + PREPARE_COLUMN_EOF { + + public DecoderState decoder(short val, int len, long serverCapabilities) { + return this; + } + + @Override + public ServerMessage decode( + ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { + boolean ending = !decoder.getPrepare().isContinueOnEnd(); + ServerPrepareResult prepareResult = decoder.endPrepare(); + return new CompletePrepareResult(prepareResult, ending); + } + + @Override + public DecoderState next(MariadbPacketDecoder decoder) { + return QUERY_RESPONSE; } }, @@ -389,7 +425,7 @@ public DecoderState decoder(short val, int len, long serverCapabilities) { @Override public ServerMessage decode( ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { - return ErrorPacket.decode(sequencer, body); + return ErrorPacket.decode(sequencer, body, true); } @Override @@ -406,12 +442,25 @@ public DecoderState decoder(short val, int len, long serverCapabilities) { @Override public ServerMessage decode( ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { - return ErrorPacket.decode(sequencer, body); + return ErrorPacket.decode(sequencer, body, false); } @Override public DecoderState next(MariadbPacketDecoder decoder) { return SKIP_EXECUTE; } + }, + + SKIP_EXECUTE { + public DecoderState decoder(short val, int len, long serverCapabilities) { + return this; + } + + @Override + public ServerMessage decode( + ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { + decoder.decrementStateCounter(); + return SkipPacket.decode(true); + } } } diff --git a/src/main/java/org/mariadb/r2dbc/client/MariadbPacketDecoder.java b/src/main/java/org/mariadb/r2dbc/client/MariadbPacketDecoder.java index 68b5d810..a7082ee7 100644 --- a/src/main/java/org/mariadb/r2dbc/client/MariadbPacketDecoder.java +++ b/src/main/java/org/mariadb/r2dbc/client/MariadbPacketDecoder.java @@ -23,8 +23,12 @@ import io.r2dbc.spi.R2dbcNonTransientResourceException; import java.util.List; import java.util.Queue; +import org.mariadb.r2dbc.message.server.ColumnDefinitionPacket; +import org.mariadb.r2dbc.message.server.PrepareResultPacket; import org.mariadb.r2dbc.message.server.Sequencer; import org.mariadb.r2dbc.message.server.ServerMessage; +import org.mariadb.r2dbc.util.PrepareCache; +import org.mariadb.r2dbc.util.ServerPrepareResult; public class MariadbPacketDecoder extends ByteToMessageDecoder { @@ -38,6 +42,8 @@ public class MariadbPacketDecoder extends ByteToMessageDecoder { private CompositeByteBuf multipart; private long serverCapabilities; private int stateCounter = 0; + private PrepareResultPacket prepare; + private ColumnDefinitionPacket[] prepareColumns; public MariadbPacketDecoder(Queue responseReceivers, Client client) { this.responseReceivers = responseReceivers; @@ -145,6 +151,37 @@ public void setStateCounter(int counter) { stateCounter = counter; } + public PrepareResultPacket getPrepare() { + return prepare; + } + + public void setPrepare(PrepareResultPacket prepare) { + this.prepare = prepare; + this.prepareColumns = new ColumnDefinitionPacket[prepare.getNumColumns()]; + } + + public ColumnDefinitionPacket[] getPrepareColumns() { + return prepareColumns; + } + + public ServerPrepareResult endPrepare() { + // this.prepareColumns = new ColumnDefinitionPacket[prepare.getNumColumns()]; + ServerPrepareResult prepareResult = + new ServerPrepareResult( + this.prepare.getStatementId(), this.prepare.getNumParams(), prepareColumns); + PrepareCache prepareCache = client.getPrepareCache(); + if (prepareCache != null) { + ServerPrepareResult cached = prepareCache.put(cmdElement.getSql(), prepareResult); + if (cached != null) { + // race condition, remove new one to get the one in cache + prepareResult.decrementUse(client); + prepareResult = cached; + } + } + this.prepare = null; + return prepareResult; + } + public void decrementStateCounter() { stateCounter--; } diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java index fa8121c8..5286c512 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java @@ -99,7 +99,8 @@ private static long initializeClientCapabilities( | Capabilities.CONNECT_ATTRS | Capabilities.PLUGIN_AUTH_LENENC_CLIENT_DATA | Capabilities.CLIENT_SESSION_TRACK - | Capabilities.FOUND_ROWS; + | Capabilities.FOUND_ROWS + | Capabilities.MARIADB_CLIENT_CACHE_METADATA; if (configuration.allowMultiQueries()) { capabilities |= Capabilities.MULTI_STATEMENTS; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/ColumnCountPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/ColumnCountPacket.java index 5e6d20e4..331ffdf2 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/ColumnCountPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/ColumnCountPacket.java @@ -19,21 +19,32 @@ import io.netty.buffer.ByteBuf; import org.mariadb.r2dbc.client.Context; import org.mariadb.r2dbc.util.BufferUtils; +import org.mariadb.r2dbc.util.constants.Capabilities; public class ColumnCountPacket implements ServerMessage { private int columnCount; + private boolean metaFollows; - public ColumnCountPacket(int columnCount) { + public ColumnCountPacket(int columnCount, boolean metaFollows) { this.columnCount = columnCount; + this.metaFollows = metaFollows; } public static ColumnCountPacket decode(Sequencer sequencer, ByteBuf buf, Context context) { long columnCount = BufferUtils.readLengthEncodedInt(buf); - return new ColumnCountPacket((int) columnCount); + if ((context.getServerCapabilities() & Capabilities.MARIADB_CLIENT_CACHE_METADATA) > 0) { + int metaFollow = buf.readByte(); + return new ColumnCountPacket((int) columnCount, metaFollow == 1); + } + return new ColumnCountPacket((int) columnCount, true); } public int getColumnCount() { return columnCount; } + + public boolean isMetaFollows() { + return metaFollows; + } } diff --git a/src/main/java/org/mariadb/r2dbc/message/server/CompletePrepareResult.java b/src/main/java/org/mariadb/r2dbc/message/server/CompletePrepareResult.java new file mode 100644 index 00000000..03c8973e --- /dev/null +++ b/src/main/java/org/mariadb/r2dbc/message/server/CompletePrepareResult.java @@ -0,0 +1,39 @@ +/* + * Copyright 2020 MariaDB Ab. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.mariadb.r2dbc.message.server; + +import org.mariadb.r2dbc.util.ServerPrepareResult; + +public final class CompletePrepareResult implements ServerMessage { + + private final ServerPrepareResult prepare; + private boolean continueOnEnd; + + public CompletePrepareResult(final ServerPrepareResult prepare, boolean continueOnEnd) { + this.prepare = prepare; + this.continueOnEnd = continueOnEnd; + } + + @Override + public boolean ending() { + return continueOnEnd; + } + + public ServerPrepareResult getPrepare() { + return prepare; + } +} diff --git a/src/main/java/org/mariadb/r2dbc/message/server/ErrorPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/ErrorPacket.java index 11126845..8d516947 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/ErrorPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/ErrorPacket.java @@ -28,15 +28,18 @@ public final class ErrorPacket implements ServerMessage { private final String message; private final String sqlState; private Sequencer sequencer; + private final boolean ending; - private ErrorPacket(Sequencer sequencer, short errorCode, String sqlState, String message) { + private ErrorPacket( + Sequencer sequencer, short errorCode, String sqlState, String message, boolean ending) { this.sequencer = sequencer; this.errorCode = errorCode; this.message = message; this.sqlState = sqlState; + this.ending = ending; } - public static ErrorPacket decode(Sequencer sequencer, ByteBuf buf) { + public static ErrorPacket decode(Sequencer sequencer, ByteBuf buf, boolean ending) { Assert.requireNonNull(buf, "buffer must not be null"); buf.skipBytes(1); short errorCode = buf.readShortLE(); @@ -52,7 +55,7 @@ public static ErrorPacket decode(Sequencer sequencer, ByteBuf buf) { msg = buf.readCharSequence(buf.readableBytes(), StandardCharsets.UTF_8).toString(); sqlState = "HY000"; } - ErrorPacket err = new ErrorPacket(sequencer, errorCode, sqlState, msg); + ErrorPacket err = new ErrorPacket(sequencer, errorCode, sqlState, msg, ending); logger.warn("Error: '{}' sqlState='{}' code={} ", msg, sqlState, errorCode); return err; } @@ -71,6 +74,6 @@ public String getSqlState() { @Override public boolean ending() { - return true; + return ending; } } diff --git a/src/main/java/org/mariadb/r2dbc/message/server/PrepareResultPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/PrepareResultPacket.java index 37706eda..bd5b7495 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/PrepareResultPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/PrepareResultPacket.java @@ -27,26 +27,34 @@ public final class PrepareResultPacket implements ServerMessage { private final int numParams; private final boolean eofDeprecated; private Sequencer sequencer; + private boolean continueOnEnd; private PrepareResultPacket( final Sequencer sequencer, final int statementId, final int numColumns, final int numParams, - final boolean eofDeprecated) { + final boolean eofDeprecated, + boolean continueOnEnd) { this.sequencer = sequencer; this.statementId = statementId; this.numColumns = numColumns; this.numParams = numParams; this.eofDeprecated = eofDeprecated; + this.continueOnEnd = continueOnEnd; } @Override public boolean ending() { - return numParams == 0 && numColumns == 0 && eofDeprecated; + return continueOnEnd && numParams == 0 && numColumns == 0 && eofDeprecated; } - public static PrepareResultPacket decode(Sequencer sequencer, ByteBuf buffer, Context context) { + public boolean isContinueOnEnd() { + return continueOnEnd; + } + + public static PrepareResultPacket decode( + Sequencer sequencer, ByteBuf buffer, Context context, boolean continueOnEnd) { /* Prepared Statement OK */ buffer.readByte(); /* skip field count */ final int statementId = buffer.readIntLE(); @@ -57,7 +65,8 @@ public static PrepareResultPacket decode(Sequencer sequencer, ByteBuf buffer, Co statementId, numColumns, numParams, - ((context.getServerCapabilities() & Capabilities.CLIENT_DEPRECATE_EOF) > 0)); + ((context.getServerCapabilities() & Capabilities.CLIENT_DEPRECATE_EOF) > 0), + continueOnEnd); } public int getStatementId() { diff --git a/src/main/java/org/mariadb/r2dbc/util/ServerPrepareResult.java b/src/main/java/org/mariadb/r2dbc/util/ServerPrepareResult.java index b35108e8..7eccc346 100644 --- a/src/main/java/org/mariadb/r2dbc/util/ServerPrepareResult.java +++ b/src/main/java/org/mariadb/r2dbc/util/ServerPrepareResult.java @@ -21,35 +21,36 @@ import java.util.concurrent.atomic.AtomicInteger; import org.mariadb.r2dbc.client.Client; import org.mariadb.r2dbc.message.client.ClosePreparePacket; +import org.mariadb.r2dbc.message.server.ColumnDefinitionPacket; public class ServerPrepareResult { private final int statementId; - private final int numColumns; private final int numParams; + private final ColumnDefinitionPacket[] columns; private final AtomicBoolean closing = new AtomicBoolean(); private final AtomicInteger use = new AtomicInteger(1); private final AtomicBoolean cached = new AtomicBoolean(false); - public ServerPrepareResult(int statementId, int numColumns, int numParams) { + public ServerPrepareResult(int statementId, int numParams, ColumnDefinitionPacket[] columns) { this.statementId = statementId; - this.numColumns = numColumns; this.numParams = numParams; + this.columns = columns; } public int getStatementId() { return statementId; } - public int getNumColumns() { - return numColumns; - } - public int getNumParams() { return numParams; } + public ColumnDefinitionPacket[] getColumns() { + return columns; + } + public void close(Client client) { if (!cached.get() && closing.compareAndSet(false, true)) { client.sendCommandWithoutResult(new ClosePreparePacket(this.statementId)); @@ -89,10 +90,10 @@ public String toString() { return "ServerPrepareResult{" + "statementId=" + statementId - + ", numColumns=" - + numColumns + ", numParams=" + numParams + + ", numColumns=" + + columns.length + ", closing=" + closing + ", use=" diff --git a/src/main/java/org/mariadb/r2dbc/util/constants/Capabilities.java b/src/main/java/org/mariadb/r2dbc/util/constants/Capabilities.java index 6a38da22..ba57dd62 100644 --- a/src/main/java/org/mariadb/r2dbc/util/constants/Capabilities.java +++ b/src/main/java/org/mariadb/r2dbc/util/constants/Capabilities.java @@ -52,4 +52,7 @@ public class Capabilities { 1L << 32; /* Client support progress indicator (since 10.2) */ public static final long MARIADB_CLIENT_COM_MULTI = 1L << 33; /* bundle command during connection */ + + // permit skipping metadata + public static final long MARIADB_CLIENT_CACHE_METADATA = 1L << 36; } diff --git a/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java b/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java index 8dcc2abd..dac58864 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java @@ -147,7 +147,6 @@ void parameterLengthEncodedLong() { arr[i] = (char) ('a' + (i % 10)); } String val = String.valueOf(arr); - arr = null; sharedConnPrepare .createStatement( "CREATE TEMPORARY TABLE parameterLengthEncodedLong" From 7da976fe0a87165f55a33f73656c7771a57e741c Mon Sep 17 00:00:00 2001 From: kolzeq Date: Mon, 21 Jun 2021 14:45:55 +0200 Subject: [PATCH 04/20] [misc] test correction for PRs mariadb-enterprise testing addition --- .travis.yml | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index a024870e..ca8dc119 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,25 +25,32 @@ install: jobs: fast_finish: true allow_failures: - - env: srv=skysql - - env: srv=skysql-ha - - env: srv=mariadb-es v=10.5 + - env: srv=build v=10.6 include: - env: srv=mariadb v=10.5 os: windows language: shell - - env: srv=mariadb v=10.2 - - env: srv=mariadb v=10.3 - - env: srv=mariadb v=10.4 - - env: srv=mariadb v=10.5 + - env: srv=mariadb v=10.2 local=1 + - env: srv=mariadb v=10.3 local=1 + - env: srv=mariadb v=10.4 local=1 + - env: srv=mariadb v=10.5 local=1 + - env: srv=mariadb v=10.6 local=1 - env: srv=mariadb v=10.5 NO_BACKSLASH_ESCAPES=true - - env: srv=mariadb v=10.5 BENCH=1 - - env: srv=maxscale - - env: srv=skysql - - env: srv=skysql-ha - - env: srv=build v=10.6 - - env: srv=mysql v=5.7 - - env: srv=mysql v=8.0 + - env: srv=mariadb v=10.6 BENCH=1 + - if: env(CONNECTOR_TEST_SECRET_KEY) + env: srv=maxscale + - if: env(CONNECTOR_TEST_SECRET_KEY) + env: srv=mariadb-es v=10.5 + - if: env(CONNECTOR_TEST_SECRET_KEY) + env: srv=skysql + - if: env(CONNECTOR_TEST_SECRET_KEY) + env: srv=skysql-ha + - if: env(CONNECTOR_TEST_SECRET_KEY) + env: srv=build v=10.6 + - if: env(CONNECTOR_TEST_SECRET_KEY) + env: srv=mysql v=5.7 + - if: env(CONNECTOR_TEST_SECRET_KEY) + env: srv=mysql v=8.0 script: - mvn clean -Dmaven.test.skip > /dev/null From 0ceaf2ba26120e42ca335ea201137309cea62b09 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Mon, 21 Jun 2021 18:41:28 +0200 Subject: [PATCH 05/20] [misc] benchmark prepare correction --- .../java/org/mariadb/r2dbc/Select_1_user.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/benchmark/java/org/mariadb/r2dbc/Select_1_user.java b/src/benchmark/java/org/mariadb/r2dbc/Select_1_user.java index 6539e798..382f87af 100644 --- a/src/benchmark/java/org/mariadb/r2dbc/Select_1_user.java +++ b/src/benchmark/java/org/mariadb/r2dbc/Select_1_user.java @@ -28,36 +28,39 @@ public class Select_1_user extends Common { final int numberOfUserCol = 46; @Benchmark - public void testJdbc(MyState state, Blackhole blackhole) throws Throwable { - Statement st = state.jdbc.createStatement(); - ResultSet rs = st.executeQuery("select * FROM mysql.user LIMIT 1"); - rs.next(); - Object[] objs = new Object[numberOfUserCol]; - for (int i = 0; i < numberOfUserCol; i++) { - objs[i] = rs.getObject(i + 1); + public Object[] testJdbc(MyState state, Blackhole blackhole) throws Throwable { + try (java.sql.PreparedStatement prep = state.jdbc.prepareStatement("select * FROM mysql.user WHERE 1 = ? LIMIT 1")) { + prep.setInt(1, 1); + ResultSet rs = prep.executeQuery(); + rs.next(); + Object[] objs = new Object[numberOfUserCol]; + for (int i = 0; i < numberOfUserCol; i++) { + objs[i] = rs.getObject(i + 1); + } + return objs; } - blackhole.consume(objs); } @Benchmark - public void testR2dbc(MyState state, Blackhole blackhole) throws Throwable { - consume(state.r2dbc, blackhole); + public Object[] testR2dbc(MyState state, Blackhole blackhole) throws Throwable { + return consume(state.r2dbc, blackhole); } @Benchmark - public void testR2dbcPrepare(MyState state, Blackhole blackhole) throws Throwable { - consume(state.r2dbcPrepare, blackhole); + public Object[] testR2dbcPrepare(MyState state, Blackhole blackhole) throws Throwable { + return consume(state.r2dbcPrepare, blackhole); } // @Benchmark -// public void testR2dbcMySql(MyState state, Blackhole blackhole) throws Throwable { -// consume(state.r2dbcMysql, blackhole); +// public Object[] testR2dbcMySql(MyState state, Blackhole blackhole) throws Throwable { +// return consume(state.r2dbcMysql, blackhole); // } - private void consume(io.r2dbc.spi.Connection connection, Blackhole blackhole) { + private Object[] consume(io.r2dbc.spi.Connection connection, Blackhole blackhole) { io.r2dbc.spi.Statement statement = - connection.createStatement("select * FROM mysql.user LIMIT 1"); - Object[] obj = + connection.createStatement("select * FROM mysql.user WHERE 1 = ? LIMIT 1") + .bind(0, 1); + return Flux.from(statement.execute()) .flatMap( it -> @@ -70,6 +73,5 @@ private void consume(io.r2dbc.spi.Connection connection, Blackhole blackhole) { return objs; })) .blockLast(); - blackhole.consume(obj); } } From cb5e971c0bd58d73631bcedd9fc7a8c448f7527e Mon Sep 17 00:00:00 2001 From: kolzeq Date: Tue, 22 Jun 2021 18:05:04 +0200 Subject: [PATCH 06/20] [R2DBC-25] Statement::add correction after specification precision --- ...iadbClientParameterizedQueryStatement.java | 50 +++++++++++-------- ...iadbServerParameterizedQueryStatement.java | 39 +++++++++------ .../integration/StatementBatchingTest.java | 16 +++++- 3 files changed, 65 insertions(+), 40 deletions(-) diff --git a/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java index 1927082e..ea119d76 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java @@ -48,20 +48,23 @@ final class MariadbClientParameterizedQueryStatement implements MariadbStatement this.sql = Assert.requireNonNull(sql, "sql must not be null"); this.prepareResult = ClientPrepareResult.parameterParts(this.sql, this.client.noBackslashEscapes()); - this.parameters = new Parameter[prepareResult.getParamCount()]; + this.parameters = null; } @Override public MariadbClientParameterizedQueryStatement add() { // check valid parameters - for (int i = 0; i < prepareResult.getParamCount(); i++) { - if (parameters[i] == null) { - throw new IllegalArgumentException(String.format("Parameter at position %s is not set", i)); + if (this.parameters != null) { + for (int i = 0; i < prepareResult.getParamCount(); i++) { + if (parameters[i] == null) { + throw new IllegalArgumentException( + String.format("Parameter at position %s is not set", i)); + } } + if (batchingParameters == null) batchingParameters = new ArrayList<>(); + batchingParameters.add(parameters); + parameters = null; } - if (batchingParameters == null) batchingParameters = new ArrayList<>(); - batchingParameters.add(parameters); - parameters = new Parameter[prepareResult.getParamCount()]; return this; } @@ -85,6 +88,7 @@ public MariadbClientParameterizedQueryStatement bind(int index, @Nullable Object for (Codec codec : Codecs.LIST) { if (codec.canEncode(value.getClass())) { + if (parameters == null) parameters = new Parameter[prepareResult.getParamCount()]; parameters[index] = (Parameter) new Parameter(codec, value); return this; } @@ -109,6 +113,7 @@ public MariadbClientParameterizedQueryStatement bindNull(int index, @Nullable Cl "index must be in 0-%d range but value is " + "%d", prepareResult.getParamCount() - 1, index)); } + if (parameters == null) parameters = new Parameter[prepareResult.getParamCount()]; parameters[index] = Parameter.NULL_PARAMETER; return this; } @@ -127,6 +132,9 @@ private int getColumn(String name) { public Flux execute() { if (batchingParameters == null) { + if (parameters == null) { + throw new IllegalArgumentException("No parameter have been set"); + } // valid parameters for (int i = 0; i < prepareResult.getParamCount(); i++) { if (parameters[i] == null) { @@ -134,31 +142,29 @@ public Flux execute() { String.format("Parameter at position %s is not set", i)); } } - return execute(this.sql, this.prepareResult, this.generatedColumns); + return executeSingleQuery(this.sql, this.prepareResult, this.generatedColumns); } else { + // add current set of parameters. see https://github.com/r2dbc/r2dbc-spi/issues/229 + add(); + + String[] generatedCols = + generatedColumns != null && client.getVersion().supportReturning() + ? generatedColumns + : null; Flux fluxMsg = this.client.sendCommand( new QueryWithParametersPacket( - prepareResult, - this.batchingParameters.get(0), - generatedColumns != null && client.getVersion().supportReturning() - ? generatedColumns - : null)); + prepareResult, this.batchingParameters.get(0), generatedCols)); int index = 1; while (index < this.batchingParameters.size()) { fluxMsg = fluxMsg.concatWith( this.client.sendCommand( new QueryWithParametersPacket( - prepareResult, - this.batchingParameters.get(index++), - generatedColumns != null && client.getVersion().supportReturning() - ? generatedColumns - : null))); + prepareResult, this.batchingParameters.get(index++), generatedCols))); } - - this.batchingParameters.clear(); - this.parameters = new Parameter[prepareResult.getParamCount()]; + this.batchingParameters = null; + this.parameters = null; return fluxMsg .windowUntil(it -> it.resultSetEnd()) @@ -193,7 +199,7 @@ public MariadbClientParameterizedQueryStatement returnGeneratedValues(String... return this; } - private Flux execute( + private Flux executeSingleQuery( String sql, ClientPrepareResult prepareResult, String[] generatedColumns) { ExceptionFactory factory = ExceptionFactory.withSql(sql); diff --git a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java index a9fd73b2..e791d6fa 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java @@ -54,7 +54,7 @@ final class MariadbServerParameterizedQueryStatement implements MariadbStatement this.client = client; this.configuration = configuration; this.initialSql = Assert.requireNonNull(sql, "sql must not be null"); - this.parameters = new HashMap<>(); + this.parameters = null; this.prepareResult = new AtomicReference<>(client.getPrepareCache().get(sql)); } @@ -66,17 +66,19 @@ static boolean supports(String sql) { @Override public MariadbServerParameterizedQueryStatement add() { // check valid parameters - if (prepareResult.get() != null) { - for (int i = 0; i < prepareResult.get().getNumParams(); i++) { - if (parameters.get(i) == null) { - throw new IllegalArgumentException( - String.format("Parameter at position %s is not set", i)); + if (this.parameters != null) { + if (prepareResult.get() != null) { + for (int i = 0; i < prepareResult.get().getNumParams(); i++) { + if (parameters.get(i) == null) { + throw new IllegalArgumentException( + String.format("Parameter at position %s is not set", i)); + } } } + if (batchingParameters == null) batchingParameters = new ArrayList<>(); + batchingParameters.add(parameters); + parameters = null; } - if (batchingParameters == null) batchingParameters = new ArrayList<>(); - batchingParameters.add(parameters); - parameters = new HashMap<>(); return this; } @@ -102,10 +104,9 @@ public MariadbServerParameterizedQueryStatement bind(int index, @Nullable Object prepareResult.get().getNumParams() - 1, index)); } if (value == null) return bindNull(index, null); - + if (parameters == null) parameters = new HashMap<>(); for (Codec codec : Codecs.LIST) { if (codec.canEncode(value.getClass())) { - parameters.put(index, (Parameter) new Parameter(codec, value)); return this; } @@ -160,6 +161,7 @@ public boolean isNull() { if (parameter == null) { parameter = Parameter.NULL_PARAMETER; } + if (parameters == null) parameters = new HashMap<>(); parameters.put(index, parameter); return this; } @@ -169,7 +171,7 @@ private int getColumn(String name) { } private void validateParameters() { - if (prepareResult.get() != null) { + if (prepareResult.get() != null && this.parameters != null) { // valid parameters for (int i = 0; i < prepareResult.get().getNumParams(); i++) { if (parameters.get(i) == null) { @@ -193,14 +195,19 @@ public Flux execute() { if (batchingParameters == null) { validateParameters(); - return execute(sql, parameters, this.generatedColumns); + return executeSingleQuery(sql, parameters, this.generatedColumns); } else { + // add current set of parameters. see https://github.com/r2dbc/r2dbc-spi/issues/229 + this.add(); + + // prepare command, if not already done if (prepareResult.get() == null) { prepareResult.set(client.getPrepareCache().get(sql)); if (prepareResult.get() == null) { sendPrepare(sql).block(); } } + Flux fluxMsg = this.client.sendCommand( new ExecutePacket( @@ -222,8 +229,8 @@ public Flux execute() { sink.complete(); })); - this.batchingParameters.clear(); - this.parameters = new HashMap<>(); + this.batchingParameters = null; + this.parameters = null; return fluxMsg .windowUntil(it -> it.resultSetEnd()) @@ -258,7 +265,7 @@ public MariadbServerParameterizedQueryStatement returnGeneratedValues(String... return this; } - private Flux execute( + private Flux executeSingleQuery( String sql, Map> parameters, String[] generatedColumns) { ExceptionFactory factory = ExceptionFactory.withSql(sql); diff --git a/src/test/java/org/mariadb/r2dbc/integration/StatementBatchingTest.java b/src/test/java/org/mariadb/r2dbc/integration/StatementBatchingTest.java index da4439ce..27ad4c41 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/StatementBatchingTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/StatementBatchingTest.java @@ -47,6 +47,18 @@ void batchStatement(MariadbConnection connection) { .add() .bind(1, "test2") .bind(0, 2) + .execute() + .blockLast(); + + // this is normally an error in specs (see https://github.com/r2dbc/r2dbc-spi/issues/229) + // but permitting this allowed for old behavior to be ok and following spec + connection + .createStatement("INSERT INTO batchStatement values (?, ?)") + .bind(0, 3) + .bind(1, "test") + .add() + .bind(1, "test2") + .bind(0, 4) .add() .execute() .blockLast(); @@ -56,7 +68,7 @@ void batchStatement(MariadbConnection connection) { .execute() .flatMap(r -> r.map((row, metadata) -> row.get(0, String.class) + row.get(1, String.class))) .as(StepVerifier::create) - .expectNext("1test", "2test2") + .expectNext("1test", "2test2", "3test", "4test2") .verifyComplete(); } @@ -80,6 +92,7 @@ void batchStatementResultSet(MariadbConnection connection) { .createStatement("INSERT INTO batchStatementResultSet values (1, 'test1'), (2, 'test2')") .execute() .blockLast(); + connection .createStatement("SELECT test FROM batchStatementResultSet WHERE id = ?") .bind(0, 1) @@ -87,7 +100,6 @@ void batchStatementResultSet(MariadbConnection connection) { .bind(0, 2) .add() .bind(0, 1) - .add() .execute() .flatMap(r -> r.map((row, metadata) -> row.get(0, String.class))) .as(StepVerifier::create) From 326dbde3944af555aaa50b5ba8f04c155cd81f34 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Wed, 23 Jun 2021 12:44:16 +0200 Subject: [PATCH 07/20] [R2DBC-26] handle error like 'too many connection" on socket creation --- src/main/java/org/mariadb/r2dbc/client/DecoderState.java | 7 ++++++- .../org/mariadb/r2dbc/message/flow/AuthenticationFlow.java | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/mariadb/r2dbc/client/DecoderState.java b/src/main/java/org/mariadb/r2dbc/client/DecoderState.java index a1cebe03..b5527bc1 100644 --- a/src/main/java/org/mariadb/r2dbc/client/DecoderState.java +++ b/src/main/java/org/mariadb/r2dbc/client/DecoderState.java @@ -24,7 +24,12 @@ public enum DecoderState implements DecoderStateInterface { INIT_HANDSHAKE { public DecoderState decoder(short val, int len, long serverCapabilities) { - return this; + switch (val) { + case 255: // 0xFF + return ERROR; + default: + return this; + } } @Override diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java index 5286c512..19f109d8 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java @@ -140,7 +140,9 @@ Mono handle(AuthenticationFlow flow) { .receive(DecoderState.INIT_HANDSHAKE) .handle( (message, sink) -> { - if (message instanceof InitialHandshakePacket) { + if (message instanceof ErrorPacket) { + sink.error(ExceptionFactory.INSTANCE.from((ErrorPacket) message)); + } else if (message instanceof InitialHandshakePacket) { flow.client.setContext((InitialHandshakePacket) message); // TODO SET connection context with server data. InitialHandshakePacket packet = (InitialHandshakePacket) message; From 2bc8659e9c0ce7240e2d17dcf6b30bdb67da1e15 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Wed, 23 Jun 2021 12:57:21 +0200 Subject: [PATCH 08/20] [misc] bump dependencies --- pom.xml | 77 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/pom.xml b/pom.xml index a19dbe87..e959aa22 100644 --- a/pom.xml +++ b/pom.xml @@ -32,15 +32,14 @@ 1.8 3.0.2 - 5.7.1 - 1.27 + 5.7.2 + 1.32 1.2.3 - 4.1.59.Final + 4.1.65.Final UTF-8 - 0.8.4.RELEASE - Dysprosium-SR17 - 2.6.1 - 0.8.2.RELEASE + 0.8.5.RELEASE + Dysprosium-SR21 + 3.0.0-alpha benchmarks @@ -172,31 +171,6 @@ - - org.jacoco - jacoco-maven-plugin - 0.8.5 - - - org/mariadb/r2dbc - org/mariadb/r2dbc/** - - - - - - prepare-agent - - - - report - test - - report - - - - org.apache.maven.plugins maven-compiler-plugin @@ -303,7 +277,7 @@ com.coveo fmt-maven-plugin - 2.9 + 2.10 @@ -337,6 +311,38 @@ true + + test + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + + org/mariadb/r2dbc + org/mariadb/r2dbc/** + + + + + + prepare-agent + + + + report + test + + report + + + + + + + bench @@ -355,11 +361,6 @@ mariadb-java-client ${mariadb-jdbc.version} - - - - - ch.qos.logback logback-classic From f23cc7cd35c28f01517f3d5f0ff883ac03c89153 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Wed, 23 Jun 2021 15:27:09 +0200 Subject: [PATCH 09/20] [misc] benchmarks using binary protocol correction Additionally, jacoco dependency is only using a specific profile used in travis test to avoid wrong benchmarks --- .travis.yml | 2 +- .../java/org/mariadb/r2dbc/Common.java | 6 ++- .../java/org/mariadb/r2dbc/Select_1.java | 40 +++++++++++------ .../org/mariadb/r2dbc/Select_10000_Rows.java | 40 ++++++++--------- .../java/org/mariadb/r2dbc/Select_1_user.java | 44 ++++++++++++------- ...iadbServerParameterizedQueryStatement.java | 2 +- 6 files changed, 79 insertions(+), 55 deletions(-) diff --git a/.travis.yml b/.travis.yml index ca8dc119..fb1172c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,7 @@ script: - mvn clean -Dmaven.test.skip > /dev/null - if [ -n "$BENCH" ] ; then mvn package -P bench -Dmaven.test.skip; fi - if [ -n "$BENCH" ] ; then java -Duser.country=US -Duser.language=en -DTEST_PORT=$TEST_DB_PORT -DTEST_HOST=$TEST_DB_HOST -DTEST_USERNAME=$TEST_DB_USER -DTEST_PASSWORD=$TEST_DB_PASSWORD -jar target/benchmarks.jar; fi - - if [ -z "$BENCH" ] ; then MAVEN_SKIP_RC=true MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512m" mvn test -DjobId=${TRAVIS_JOB_ID}; fi + - if [ -z "$BENCH" ] ; then MAVEN_SKIP_RC=true MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512m" mvn test -P test -DjobId=${TRAVIS_JOB_ID}; fi after_success: diff --git a/src/benchmark/java/org/mariadb/r2dbc/Common.java b/src/benchmark/java/org/mariadb/r2dbc/Common.java index 7af4c494..eb62d78a 100644 --- a/src/benchmark/java/org/mariadb/r2dbc/Common.java +++ b/src/benchmark/java/org/mariadb/r2dbc/Common.java @@ -27,7 +27,7 @@ @State(Scope.Benchmark) @Warmup(iterations = 10, timeUnit = TimeUnit.SECONDS, time = 1) @Measurement(iterations = 10, timeUnit = TimeUnit.SECONDS, time = 1) -@Fork(value = 5) +@Fork(value = 2) @Threads(value = -1) // detecting CPU count @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) @@ -46,6 +46,8 @@ public static class MyState { // connections protected Connection jdbc; + protected Connection jdbcPrepare; + protected io.r2dbc.spi.Connection r2dbc; protected io.r2dbc.spi.Connection r2dbcPrepare; // protected io.r2dbc.spi.Connection r2dbcMysql; @@ -86,6 +88,7 @@ public void doSetup() throws Exception { try { jdbc = DriverManager.getConnection("jdbc:" + jdbcUrl); + jdbcPrepare = DriverManager.getConnection("jdbc:" + jdbcUrl + "&useServerPrepStmts=true"); r2dbc = MariadbConnectionFactory.from(conf).create().block(); r2dbcPrepare = MariadbConnectionFactory.from(confPrepare).create().block(); // r2dbcMysql = MySqlConnectionFactory.from(confMysql).create().block(); @@ -99,6 +102,7 @@ public void doSetup() throws Exception { @TearDown(Level.Trial) public void doTearDown() throws SQLException { jdbc.close(); + jdbcPrepare.close(); Mono.from(r2dbc.close()).block(); Mono.from(r2dbcPrepare.close()).block(); // Mono.from(r2dbcMysql.close()).block(); diff --git a/src/benchmark/java/org/mariadb/r2dbc/Select_1.java b/src/benchmark/java/org/mariadb/r2dbc/Select_1.java index 4bd789ed..f4df013c 100644 --- a/src/benchmark/java/org/mariadb/r2dbc/Select_1.java +++ b/src/benchmark/java/org/mariadb/r2dbc/Select_1.java @@ -26,24 +26,23 @@ public class Select_1 extends Common { @Benchmark - public void testJdbc(MyState state, Blackhole blackhole) throws Throwable { - Statement st = state.jdbc.createStatement(); - int rnd = (int) (Math.random() * 1000); - ResultSet rs = st.executeQuery("select " + rnd); - rs.next(); - Integer val = rs.getInt(1); - if (rnd != val) throw new IllegalStateException("ERROR"); - blackhole.consume(val); + public int testJdbc(MyState state) throws Throwable { + return consumeJdbc(state.jdbc); + } + + @Benchmark + public Integer testR2dbc(MyState state) throws Throwable { + return consume(state.r2dbc); } @Benchmark - public void testR2dbc(MyState state, Blackhole blackhole) throws Throwable { - consume(state.r2dbc, blackhole); + public int testJdbcPrepare(MyState state) throws Throwable { + return consumeJdbc(state.jdbcPrepare); } @Benchmark - public void testR2dbcPrepare(MyState state, Blackhole blackhole) throws Throwable { - consume(state.r2dbcPrepare, blackhole); + public Integer testR2dbcPrepare(MyState state) throws Throwable { + return consume(state.r2dbcPrepare); } // @Benchmark @@ -51,7 +50,7 @@ public void testR2dbcPrepare(MyState state, Blackhole blackhole) throws Throwabl // consume(state.r2dbcMysql, blackhole); // } - private void consume(io.r2dbc.spi.Connection connection, Blackhole blackhole) { + private Integer consume(io.r2dbc.spi.Connection connection) { int rnd = (int) (Math.random() * 1000); io.r2dbc.spi.Statement statement = connection.createStatement("select " + rnd); Integer val = @@ -60,6 +59,19 @@ private void consume(io.r2dbc.spi.Connection connection, Blackhole blackhole) { .blockLast(); if (rnd != val) throw new IllegalStateException("ERROR rnd:" + rnd + " different to val:" + val); - blackhole.consume(val); + return val; } + + private int consumeJdbc(java.sql.Connection connection) throws java.sql.SQLException { + try (java.sql.PreparedStatement prep = connection.prepareStatement("select ?")) { + int rnd = (int) (Math.random() * 1000); + prep.setInt(1, rnd); + ResultSet rs = prep.executeQuery(); + rs.next(); + int val = rs.getInt(1); + if (rnd != val) throw new IllegalStateException("ERROR"); + return val; + } + } + } diff --git a/src/benchmark/java/org/mariadb/r2dbc/Select_10000_Rows.java b/src/benchmark/java/org/mariadb/r2dbc/Select_10000_Rows.java index 9fc63a58..a7d3c759 100644 --- a/src/benchmark/java/org/mariadb/r2dbc/Select_10000_Rows.java +++ b/src/benchmark/java/org/mariadb/r2dbc/Select_10000_Rows.java @@ -27,29 +27,30 @@ public class Select_10000_Rows extends Common { private static final String sql = - "SELECT lpad(conv(floor(rand()*pow(36,8)), 10, 36), 8, 0) as rnd_str_8 FROM seq_1_to_10000"; + "SELECT lpad(conv(floor(rand()*pow(36,8)), 10, 36), 8, 0) as rnd_str_8 FROM seq_1_to_10000 WHERE 1 = ?"; @Benchmark - public void testJdbc(MyState state, Blackhole blackhole) throws Throwable { - PreparedStatement st = state.jdbc.prepareStatement(sql); - - ResultSet rs = st.executeQuery(); - String[] res = new String[10000]; - int i = 0; - while (rs.next()) { - res[i++] = rs.getString(1); + public String[] testJdbc(MyState state, Blackhole blackhole) throws Throwable { + try (PreparedStatement st = state.jdbc.prepareStatement(sql)) { + st.setInt(1, 1); + ResultSet rs = st.executeQuery(); + String[] res = new String[10000]; + int i = 0; + while (rs.next()) { + res[i++] = rs.getString(1); + } + return res; } - blackhole.consume(res); } @Benchmark - public void testR2dbc(MyState state, Blackhole blackhole) throws Throwable { - consume(state.r2dbc, blackhole); + public List testR2dbc(MyState state, Blackhole blackhole) throws Throwable { + return consume(state.r2dbc, blackhole); } @Benchmark - public void testR2dbcPrepare(MyState state, Blackhole blackhole) throws Throwable { - consume(state.r2dbcPrepare, blackhole); + public List testR2dbcPrepare(MyState state, Blackhole blackhole) throws Throwable { + return consume(state.r2dbcPrepare, blackhole); } // @Benchmark @@ -57,12 +58,9 @@ public void testR2dbcPrepare(MyState state, Blackhole blackhole) throws Throwabl // consume(state.r2dbcMysql, blackhole); // } - private void consume(io.r2dbc.spi.Connection connection, Blackhole blackhole) { - io.r2dbc.spi.Statement statement = connection.createStatement(sql); - Flux flux = - Flux.from(statement.execute()) - .flatMap(it -> it.map((row, rowMetadata) -> row.get(0, String.class))); - List body = flux.collectList().block(Duration.ofSeconds(1)); - blackhole.consume(body); + private List consume(io.r2dbc.spi.Connection connection, Blackhole blackhole) { + return Flux.from(connection.createStatement(sql).bind(0,1).execute()) + .flatMap(it -> it.map((row, rowMetadata) -> row.get(0, String.class))) + .collectList().block(Duration.ofSeconds(1)); } } diff --git a/src/benchmark/java/org/mariadb/r2dbc/Select_1_user.java b/src/benchmark/java/org/mariadb/r2dbc/Select_1_user.java index 382f87af..d7a73120 100644 --- a/src/benchmark/java/org/mariadb/r2dbc/Select_1_user.java +++ b/src/benchmark/java/org/mariadb/r2dbc/Select_1_user.java @@ -28,35 +28,31 @@ public class Select_1_user extends Common { final int numberOfUserCol = 46; @Benchmark - public Object[] testJdbc(MyState state, Blackhole blackhole) throws Throwable { - try (java.sql.PreparedStatement prep = state.jdbc.prepareStatement("select * FROM mysql.user WHERE 1 = ? LIMIT 1")) { - prep.setInt(1, 1); - ResultSet rs = prep.executeQuery(); - rs.next(); - Object[] objs = new Object[numberOfUserCol]; - for (int i = 0; i < numberOfUserCol; i++) { - objs[i] = rs.getObject(i + 1); - } - return objs; - } + public Object[] testJdbc(MyState state) throws Throwable { + return consumeJdbc(state.jdbc); + } + + @Benchmark + public Object[] testR2dbc(MyState state) throws Throwable { + return consume(state.r2dbc); } @Benchmark - public Object[] testR2dbc(MyState state, Blackhole blackhole) throws Throwable { - return consume(state.r2dbc, blackhole); + public Object[] testJdbcPrepare(MyState state) throws Throwable { + return consumeJdbc(state.jdbcPrepare); } @Benchmark - public Object[] testR2dbcPrepare(MyState state, Blackhole blackhole) throws Throwable { - return consume(state.r2dbcPrepare, blackhole); + public Object[] testR2dbcPrepare(MyState state) throws Throwable { + return consume(state.r2dbcPrepare); } // @Benchmark -// public Object[] testR2dbcMySql(MyState state, Blackhole blackhole) throws Throwable { +// public Object[] testR2dbcMySql(MyState state) throws Throwable { // return consume(state.r2dbcMysql, blackhole); // } - private Object[] consume(io.r2dbc.spi.Connection connection, Blackhole blackhole) { + private Object[] consume(io.r2dbc.spi.Connection connection) { io.r2dbc.spi.Statement statement = connection.createStatement("select * FROM mysql.user WHERE 1 = ? LIMIT 1") .bind(0, 1); @@ -74,4 +70,18 @@ private Object[] consume(io.r2dbc.spi.Connection connection, Blackhole blackhole })) .blockLast(); } + + + private Object[] consumeJdbc(java.sql.Connection connection) throws java.sql.SQLException { + try (java.sql.PreparedStatement prep = connection.prepareStatement("select * FROM mysql.user WHERE 1 = ? LIMIT 1")) { + prep.setInt(1, 1); + ResultSet rs = prep.executeQuery(); + rs.next(); + Object[] objs = new Object[numberOfUserCol]; + for (int i = 0; i < numberOfUserCol; i++) { + objs[i] = rs.getObject(i + 1); + } + return objs; + } + } } diff --git a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java index e791d6fa..337aea25 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java @@ -358,7 +358,7 @@ private Mono sendPrepare(String sql) { if (it.ending()) sink.complete(); }); return f.singleOrEmpty(); - }; + } private Flux sendExecuteCmd( ExceptionFactory factory, Map> parameters, String[] generatedColumns) { From 099815aa9eb45b8e2919e4b6a814e5aa1467508c Mon Sep 17 00:00:00 2001 From: kolzeq Date: Wed, 23 Jun 2021 15:40:48 +0200 Subject: [PATCH 10/20] [R2DBC-27] Options `pamOtherPwd` and `sessionVariables not parsed from connection string --- .../r2dbc/MariadbConnectionConfiguration.java | 48 ++++++++++--------- .../MariadbConnectionFactoryProvider.java | 1 + .../r2dbc/integration/ConfigurationTest.java | 13 ++++- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java index 8755a0a3..867415dc 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java @@ -191,6 +191,12 @@ public static Builder fromOptions(ConnectionFactoryOptions connectionFactoryOpti MariadbConnectionFactoryProvider.TCP_ABORTIVE_CLOSE))); } + if (connectionFactoryOptions.hasOption(MariadbConnectionFactoryProvider.SESSION_VARIABLES)) { + String sessionVarString = + connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.SESSION_VARIABLES); + builder.sessionVariables(getMapFromString(sessionVarString)); + } + if (connectionFactoryOptions.hasOption(MariadbConnectionFactoryProvider.ALLOW_PIPELINING)) { builder.allowPipelining( boolValue( @@ -217,16 +223,9 @@ public static Builder fromOptions(ConnectionFactoryOptions connectionFactoryOpti if (connectionFactoryOptions.hasOption( MariadbConnectionFactoryProvider.CONNECTION_ATTRIBUTES)) { - Map myMap = new HashMap<>(); - String s = + String connAttributes = connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.CONNECTION_ATTRIBUTES); - String[] pairs = s.split(","); - for (int i = 0; i < pairs.length; i++) { - String pair = pairs[i]; - String[] keyValue = pair.split("="); - myMap.put(keyValue[0], (keyValue.length > 1) ? keyValue[1] : ""); - } - builder.connectionAttributes(myMap); + builder.connectionAttributes(getMapFromString(connAttributes)); } if (connectionFactoryOptions.hasOption(MariadbConnectionFactoryProvider.PREPARE_CACHE_SIZE)) { @@ -260,7 +259,7 @@ public static Builder fromOptions(ConnectionFactoryOptions connectionFactoryOpti } if (connectionFactoryOptions.hasOption(MariadbConnectionFactoryProvider.PAM_OTHER_PASSWORD)) { String s = - connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.CONNECTION_ATTRIBUTES); + connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.PAM_OTHER_PASSWORD); String[] pairs = s.split(","); try { for (int i = 0; i < pairs.length; i++) { @@ -276,6 +275,19 @@ public static Builder fromOptions(ConnectionFactoryOptions connectionFactoryOpti return builder; } + private static Map getMapFromString(String s) { + Map map = new HashMap<>(); + if (s != null && !s.isEmpty()) { + String[] pairs = s.split(","); + for (int i = 0; i < pairs.length; i++) { + String pair = pairs[i]; + String[] keyValue = pair.split("="); + map.put(keyValue[0], (keyValue.length > 1) ? keyValue[1] : ""); + } + } + return map; + } + public static Builder builder() { return new Builder(); } @@ -391,16 +403,12 @@ public boolean isTcpAbortiveClose() { public String toString() { StringBuilder hiddenPwd = new StringBuilder(); if (password != null) { - for (int i = 0; i < password.length(); i++) { - hiddenPwd.append("*"); - } + hiddenPwd.append("*"); } StringBuilder hiddenPamPwd = new StringBuilder(); if (pamOtherPwd != null) { for (CharSequence s : pamOtherPwd) { - for (int i = 0; i < s.length(); i++) { - hiddenPamPwd.append("*"); - } + hiddenPamPwd.append("*"); hiddenPamPwd.append(","); } hiddenPamPwd.deleteCharAt(hiddenPamPwd.length() - 1); @@ -856,16 +864,12 @@ public Builder clone() throws CloneNotSupportedException { public String toString() { StringBuilder hiddenPwd = new StringBuilder(); if (password != null) { - for (int i = 0; i < password.length(); i++) { - hiddenPwd.append("*"); - } + hiddenPwd.append("*"); } StringBuilder hiddenPamPwd = new StringBuilder(); if (pamOtherPwd != null) { for (CharSequence s : pamOtherPwd) { - for (int i = 0; i < s.length(); i++) { - hiddenPamPwd.append("*"); - } + hiddenPamPwd.append("*"); hiddenPamPwd.append(","); } hiddenPamPwd.deleteCharAt(hiddenPamPwd.length() - 1); diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java index 69eea41c..a8d1d393 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java @@ -42,6 +42,7 @@ public final class MariadbConnectionFactoryProvider implements ConnectionFactory public static final Option SOCKET_TIMEOUT = Option.valueOf("socketTimeout"); public static final Option TCP_KEEP_ALIVE = Option.valueOf("tcpKeepAlive"); public static final Option TCP_ABORTIVE_CLOSE = Option.valueOf("tcpAbortiveClose"); + public static final Option SESSION_VARIABLES = Option.valueOf("sessionVariables"); static MariadbConnectionConfiguration createConfiguration( ConnectionFactoryOptions connectionFactoryOptions) { diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java index 9b8b345d..7e122ed9 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java @@ -96,7 +96,7 @@ void checkOptions() { Assertions.assertTrue(factory.toString().contains("prepareCacheSize=2560")); Assertions.assertTrue(factory.toString().contains("sslMode=ENABLE_TRUST")); Assertions.assertTrue(factory.toString().contains("connectionAttributes={test=2, h=4}")); - Assertions.assertTrue(factory.toString().contains("pamOtherPwd=******,***")); + Assertions.assertTrue(factory.toString().contains("pamOtherPwd=*,*")); Assertions.assertTrue(factory.toString().contains("connectTimeout=PT10S")); Assertions.assertTrue(factory.toString().contains("socketTimeout=PT1H")); Assertions.assertTrue(factory.toString().contains("tcpKeepAlive=true")); @@ -259,4 +259,15 @@ void confMinOption() { () -> MariadbConnectionConfiguration.builder().host("jj").build(), "username must not be null"); } + + @Test + void sessionVariablesParsing() { + String connectionUrl = + "r2dbc:mariadb://admin:pass@localhost:3306/dbname?sessionVariables=sql_mode='ANSI'"; + ConnectionFactoryOptions factoryOptions = ConnectionFactoryOptions.parse(connectionUrl); + Assertions.assertTrue(factoryOptions.toString().contains("sessionVariables=sql_mode='ANSI'")); + ConnectionFactory connectionFactory = ConnectionFactories.get(factoryOptions); + Assertions.assertTrue( + connectionFactory.toString().contains("sessionVariables={sql_mode='ANSI'}")); + } } From b34c5c8f422e7c404519f7da940dcbbf6f6282d7 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Wed, 23 Jun 2021 19:15:27 +0200 Subject: [PATCH 11/20] [misc] test additions --- .../r2dbc/MariadbConnectionConfiguration.java | 45 ++++---------- ...iadbServerParameterizedQueryStatement.java | 17 ++---- .../org/mariadb/r2dbc/util/SslConfig.java | 6 +- .../r2dbc/integration/ConfigurationTest.java | 21 ++++++- .../r2dbc/integration/ConnectionTest.java | 61 +++++++++++++++++++ .../integration/PrepareResultSetTest.java | 16 ++--- .../r2dbc/integration/ResultsetTest.java | 15 +++-- .../r2dbc/integration/StatementTest.java | 61 +++++++++++++------ .../mariadb/r2dbc/integration/TlsTest.java | 3 + .../authentication/Sha256PluginTest.java | 36 +++++------ .../parameter/StringParameterTest.java | 2 +- 11 files changed, 179 insertions(+), 104 deletions(-) diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java index 867415dc..353f24c9 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java @@ -122,30 +122,21 @@ static boolean boolValue(Object value) { if (value instanceof Boolean) { return ((Boolean) value).booleanValue(); } - if (value instanceof String) { - return Boolean.parseBoolean(value.toString()); - } - throw new IllegalArgumentException(String.format("Option %s wrong boolean format", value)); + return Boolean.parseBoolean(value.toString()); } static Duration durationValue(Object value) { if (value instanceof Duration) { return ((Duration) value); } - if (value instanceof String) { - return Duration.parse(value.toString()); - } - throw new IllegalArgumentException(String.format("Option %s wrong duration format", value)); + return Duration.parse(value.toString()); } static int intValue(Object value) { if (value instanceof Number) { return ((Number) value).intValue(); } - if (value instanceof String) { - return Integer.parseInt(value.toString()); - } - throw new IllegalArgumentException(String.format("Option %s wrong integer format", value)); + return Integer.parseInt(value.toString()); } public static Builder fromOptions(ConnectionFactoryOptions connectionFactoryOptions) { @@ -264,10 +255,9 @@ public static Builder fromOptions(ConnectionFactoryOptions connectionFactoryOpti try { for (int i = 0; i < pairs.length; i++) { pairs[i] = URLDecoder.decode(pairs[i], StandardCharsets.UTF_8.toString()); - ; } } catch (UnsupportedEncodingException e) { - // eat + // eat, StandardCharsets.UTF_8 is always supported } builder.pamOtherPwd(pairs); } @@ -876,17 +866,14 @@ public String toString() { } return "Builder{" - + "rsaPublicKey='" + + "rsaPublicKey=" + rsaPublicKey - + '\'' - + ", cachingRsaPublicKey='" + + ", cachingRsaPublicKey=" + cachingRsaPublicKey - + '\'' + ", allowPublicKeyRetrieval=" + allowPublicKeyRetrieval - + ", username='" + + ", username=" + username - + '\'' + ", connectTimeout=" + connectTimeout + ", socketTimeout=" @@ -895,12 +882,10 @@ public String toString() { + tcpKeepAlive + ", tcpAbortiveClose=" + tcpAbortiveClose - + ", database='" + + ", database=" + database - + '\'' - + ", host='" + + ", host=" + host - + '\'' + ", sessionVariables=" + sessionVariables + ", connectionAttributes=" @@ -909,9 +894,8 @@ public String toString() { + hiddenPwd + ", port=" + port - + ", socket='" + + ", socket=" + socket - + '\'' + ", allowMultiQueries=" + allowMultiQueries + ", allowPipelining=" @@ -922,15 +906,12 @@ public String toString() { + prepareCacheSize + ", tlsProtocol=" + tlsProtocol - + ", serverSslCert='" + + ", serverSslCert=" + serverSslCert - + '\'' - + ", clientSslCert='" + + ", clientSslCert=" + clientSslCert - + '\'' - + ", clientSslKey='" + + ", clientSslKey=" + clientSslKey - + '\'' + ", clientSslPassword=" + clientSslPassword + ", sslMode=" diff --git a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java index 337aea25..8479c866 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java @@ -58,11 +58,6 @@ final class MariadbServerParameterizedQueryStatement implements MariadbStatement this.prepareResult = new AtomicReference<>(client.getPrepareCache().get(sql)); } - static boolean supports(String sql) { - Assert.requireNonNull(sql, "sql must not be null"); - return !sql.trim().isEmpty(); - } - @Override public MariadbServerParameterizedQueryStatement add() { // check valid parameters @@ -273,22 +268,18 @@ private Flux executeSingleQuery( prepareResult.set(client.getPrepareCache().get(sql)); } - Flux flux; if (prepareResult.get() != null) { validateParameters(); + ServerPrepareResult res; if (this.client.getPrepareCache() != null && (res = this.client.getPrepareCache().get(sql)) != null && !res.equals(prepareResult.get())) { prepareResult.get().decrementUse(client); prepareResult.set(res); - } else { - if (!prepareResult.get().incrementUse()) { - prepareResult.set(null); - } } - if (prepareResult.get() != null) { + if (prepareResult.get().incrementUse()) { return sendExecuteCmd(factory, parameters, generatedColumns) .concatWith( Flux.create( @@ -297,9 +288,13 @@ private Flux executeSingleQuery( sink.complete(); parameters.clear(); })); + } else { + // prepare is closing + prepareResult.set(null); } } + Flux flux; if (configuration.allowPipelining() && client.getVersion().isMariaDBServer() && client.getVersion().versionGreaterOrEqual(10, 2, 0)) { diff --git a/src/main/java/org/mariadb/r2dbc/util/SslConfig.java b/src/main/java/org/mariadb/r2dbc/util/SslConfig.java index e2b0286b..71c05489 100644 --- a/src/main/java/org/mariadb/r2dbc/util/SslConfig.java +++ b/src/main/java/org/mariadb/r2dbc/util/SslConfig.java @@ -184,12 +184,10 @@ public String toString() { return "SslConfig{" + "sslMode=" + sslMode - + ", serverSslCert='" + + ", serverSslCert=" + serverSslCert - + '\'' - + ", clientSslCert='" + + ", clientSslCert=" + clientSslCert - + '\'' + ", tlsProtocol=" + tlsProtocol + '}'; diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java index 7e122ed9..effb4e3f 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java @@ -89,8 +89,8 @@ void checkOptions() { Assertions.assertTrue(factory.toString().contains("socket='ff'")); Assertions.assertTrue(factory.toString().contains("allowMultiQueries=true")); Assertions.assertTrue(factory.toString().contains("tlsProtocol=[TLSv1.2]")); - Assertions.assertTrue(factory.toString().contains("serverSslCert='myCert'")); - Assertions.assertTrue(factory.toString().contains("clientSslCert='myClientCert'")); + Assertions.assertTrue(factory.toString().contains("serverSslCert=myCert")); + Assertions.assertTrue(factory.toString().contains("clientSslCert=myClientCert")); Assertions.assertTrue(factory.toString().contains("allowPipelining=true")); Assertions.assertTrue(factory.toString().contains("useServerPrepStmts=true")); Assertions.assertTrue(factory.toString().contains("prepareCacheSize=2560")); @@ -270,4 +270,21 @@ void sessionVariablesParsing() { Assertions.assertTrue( connectionFactory.toString().contains("sessionVariables={sql_mode='ANSI'}")); } + + @Test + void confStringValue() { + String connectionUrl = + "r2dbc:mariadb://admin:pass@localhost:3306/dbname?allowMultiQueries=blabla"; + ConnectionFactoryOptions options = ConnectionFactoryOptions.parse(connectionUrl); + MariadbConnectionConfiguration.Builder builder = + MariadbConnectionConfiguration.fromOptions(options); + builder.tlsProtocol(null); + Assertions.assertEquals( + "Builder{rsaPublicKey=null, cachingRsaPublicKey=null, allowPublicKeyRetrieval=false, username=admin, connectTimeout=null, socketTimeout=null, tcpKeepAlive=null, tcpAbortiveClose=null, database=dbname, host=localhost, sessionVariables=null, connectionAttributes=null, password=*, port=3306, socket=null, allowMultiQueries=false, allowPipelining=true, useServerPrepStmts=false, prepareCacheSize=null, tlsProtocol=null, serverSslCert=null, clientSslCert=null, clientSslKey=null, clientSslPassword=null, sslMode=DISABLED, pamOtherPwd=}", + builder.toString()); + MariadbConnectionConfiguration conf = builder.build(); + Assertions.assertEquals( + "SslConfig{sslMode=DISABLED, serverSslCert=null, clientSslCert=null, tlsProtocol=null}", + conf.getSslConfig().toString()); + } } diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java index 6e3b22ae..ff753b67 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java @@ -16,6 +16,8 @@ package org.mariadb.r2dbc.integration; +import static org.junit.jupiter.api.Assertions.*; + import ch.qos.logback.classic.Level; import io.r2dbc.spi.*; import java.math.BigInteger; @@ -36,6 +38,7 @@ import org.mariadb.r2dbc.api.MariadbResult; import org.mariadb.r2dbc.api.MariadbStatement; import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; import reactor.test.StepVerifier; public class ConnectionTest extends BaseConnectionTest { @@ -685,4 +688,62 @@ void toStringTest() { connection.close().block(); } } + + @Test + public void isolationLevel() { + MariadbConnection connection = + new MariadbConnectionFactory(TestConfiguration.defaultBuilder.build()).create().block(); + + Assertions.assertThrows( + Exception.class, + () -> connection.setTransactionIsolationLevel((IsolationLevel) null).block()); + IsolationLevel[] levels = + new IsolationLevel[] { + IsolationLevel.READ_UNCOMMITTED, + IsolationLevel.READ_COMMITTED, + IsolationLevel.SERIALIZABLE, + IsolationLevel.REPEATABLE_READ + }; + for (IsolationLevel level : levels) { + connection.setTransactionIsolationLevel(level).block(); + assertEquals(level, connection.getTransactionIsolationLevel()); + } + connection.close().block(); + Assertions.assertThrows( + R2dbcNonTransientResourceException.class, + () -> connection.setTransactionIsolationLevel(IsolationLevel.READ_UNCOMMITTED).block()); + } + + @Test + public void errorOnConnection() { + BigInteger maxConn = + sharedConn + .createStatement("select @@max_connections") + .execute() + .flatMap(r -> r.map((row, metadata) -> row.get(0, BigInteger.class))) + .blockLast(); + Assumptions.assumeTrue(maxConn.intValue() < 200); + + R2dbcTransientResourceException expected = null; + Mono[] cons = new Mono[maxConn.intValue()]; + for (int i = 0; i < maxConn.intValue(); i++) { + cons[i] = new MariadbConnectionFactory(TestConfiguration.defaultBuilder.build()).create(); + } + MariadbConnection[] connections = new MariadbConnection[maxConn.intValue()]; + for (int i = 0; i < maxConn.intValue(); i++) { + try { + connections[i] = cons[i].block(); + } catch (R2dbcTransientResourceException e) { + expected = e; + } + } + + for (int i = 0; i < maxConn.intValue(); i++) { + if (connections[i] != null) { + connections[i].close().block(); + } + } + Assertions.assertNotNull(expected); + Assertions.assertTrue(expected.getMessage().contains("Too many connections")); + } } diff --git a/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java b/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java index dac58864..5f23dc0f 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java @@ -237,13 +237,15 @@ public void returning() { .execute() .blockLast(); - sharedConnPrepare - .createStatement("INSERT INTO INSERT_RETURNING(test) VALUES (?), (?)") - .bind(0, "test1") - .bind(1, "test2") - .fetchSize(44) - .returnGeneratedValues("id", "test") - .execute() + MariadbStatement st = + sharedConnPrepare + .createStatement("INSERT INTO INSERT_RETURNING(test) VALUES (?), (?)") + .bind(0, "test1") + .bind(1, "test2") + .fetchSize(44) + .returnGeneratedValues("id", "test"); + Assertions.assertTrue(st.toString().contains("generatedColumns=[id, test]")); + st.execute() .flatMap(r -> r.map((row, metadata) -> row.get(0, String.class) + row.get(1, String.class))) .as(StepVerifier::create) .expectNext("1test1", "2test2") diff --git a/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java b/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java index 5d60c7f3..edc46d9c 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java @@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test; import org.mariadb.r2dbc.BaseConnectionTest; import org.mariadb.r2dbc.api.MariadbConnection; +import org.mariadb.r2dbc.api.MariadbStatement; import reactor.test.StepVerifier; public class ResultsetTest extends BaseConnectionTest { @@ -89,12 +90,14 @@ public void returning() { .execute() .blockLast(); - sharedConn - .createStatement("INSERT INTO INSERT_RETURNING(test) VALUES (?), (?)") - .bind(0, "test1") - .bind(1, "test2") - .returnGeneratedValues("id", "test") - .execute() + MariadbStatement st = + sharedConn + .createStatement("INSERT INTO INSERT_RETURNING(test) VALUES (?), (?)") + .bind(0, "test1") + .bind(1, "test2") + .returnGeneratedValues("id", "test"); + Assertions.assertTrue(st.toString().contains("generatedColumns=[id, test]")); + st.execute() .flatMap(r -> r.map((row, metadata) -> row.get(0, String.class) + row.get(1, String.class))) .as(StepVerifier::create) .expectNext("1test1", "2test2") diff --git a/src/test/java/org/mariadb/r2dbc/integration/StatementTest.java b/src/test/java/org/mariadb/r2dbc/integration/StatementTest.java index bebb97fc..4a4f51f8 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/StatementTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/StatementTest.java @@ -282,7 +282,15 @@ public void getPosition() { @Test public void returning() { - Assumptions.assumeTrue(isMariaDBServer() && minVersion(10, 5, 1)); + Assumptions.assumeTrue(isMariaDBServer()); + if (!minVersion(10, 5, 1)) { + Assertions.assertThrows( + IllegalArgumentException.class, + () -> + sharedConn + .createStatement("INSERT INTO INSERT_RETURNING(test) VALUES ('test1'), ('test2')") + .returnGeneratedValues("id", "test")); + } sharedConn .createStatement( @@ -291,31 +299,44 @@ public void returning() { .blockLast(); sharedConn - .createStatement("INSERT INTO INSERT_RETURNING(test) VALUES ('test1'), ('test2')") - .returnGeneratedValues("id", "test") - .execute() - .flatMap(r -> r.map((row, metadata) -> row.get(0, String.class) + row.get(1, String.class))) - .as(StepVerifier::create) - .expectNext("1test1", "2test2") - .verifyComplete(); - - sharedConn - .createStatement("INSERT INTO INSERT_RETURNING(test) VALUES ('test3'), ('test4')") + .createStatement("INSERT INTO INSERT_RETURNING(test) VALUES ('test3')") .returnGeneratedValues("id") .execute() .flatMap(r -> r.map((row, metadata) -> row.get(0, String.class))) .as(StepVerifier::create) - .expectNext("3", "4") + .expectNext("1") .verifyComplete(); - sharedConn - .createStatement("INSERT INTO INSERT_RETURNING(test) VALUES ('a'), ('b')") - .returnGeneratedValues() - .execute() - .flatMap(r -> r.map((row, metadata) -> row.get(0, String.class) + row.get(1, String.class))) - .as(StepVerifier::create) - .expectNext("5a", "6b") - .verifyComplete(); + if (minVersion(10, 5, 1)) { + + sharedConn + .createStatement("INSERT INTO INSERT_RETURNING(test) VALUES ('test3'), ('test4')") + .returnGeneratedValues("id") + .execute() + .flatMap(r -> r.map((row, metadata) -> row.get(0, String.class))) + .as(StepVerifier::create) + .expectNext("2", "3") + .verifyComplete(); + sharedConn + .createStatement("INSERT INTO INSERT_RETURNING(test) VALUES ('test1'), ('test2')") + .returnGeneratedValues("id", "test") + .execute() + .flatMap( + r -> r.map((row, metadata) -> row.get(0, String.class) + row.get(1, String.class))) + .as(StepVerifier::create) + .expectNext("4test1", "5test2") + .verifyComplete(); + + sharedConn + .createStatement("INSERT INTO INSERT_RETURNING(test) VALUES ('a'), ('b')") + .returnGeneratedValues() + .execute() + .flatMap( + r -> r.map((row, metadata) -> row.get(0, String.class) + row.get(1, String.class))) + .as(StepVerifier::create) + .expectNext("6a", "7b") + .verifyComplete(); + } } @Test diff --git a/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java b/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java index a1acfda0..78001f4c 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java @@ -159,6 +159,9 @@ void wrongCertificateFiles() throws Exception { .serverSslCert(serverSslCert) .clientSslCert("wrongFile") .clientSslKey("dd") + .clientSslPassword(null) + .rsaPublicKey(null) + .cachingRsaPublicKey(null) .build(), "Failed to find clientSslCert file. clientSslCert=wrongFile"); if (clientSslCert != null) { diff --git a/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java b/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java index 8d1c029d..d90570eb 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java @@ -85,36 +85,24 @@ public static void init() throws Exception { } } } - - sharedConn - .createStatement("DROP USER IF EXISTS 'sha256User'@'%'") - .execute() - .map(res -> res.getRowsUpdated()) - .onErrorReturn(Mono.empty()) - .blockLast(); - sharedConn - .createStatement("DROP USER IF EXISTS 'cachingSha256User'@'%'") - .execute() - .map(res -> res.getRowsUpdated()) - .onErrorReturn(Mono.empty()) - .blockLast(); - sharedConn - .createStatement("DROP USER IF EXISTS 'cachingSha256User2'@'%'") - .execute() - .map(res -> res.getRowsUpdated()) - .onErrorReturn(Mono.empty()) - .blockLast(); + dropAll(); String sqlCreateUser; String sqlGrant; if (minVersion(8, 0, 0)) { sqlCreateUser = "CREATE USER 'sha256User'@'%' IDENTIFIED WITH sha256_password BY 'password'"; sqlGrant = "GRANT ALL PRIVILEGES ON *.* TO 'sha256User'@'%'"; + sqlCreateUser = "CREATE USER 'sha256User2'@'%' IDENTIFIED WITH sha256_password BY 'password'"; + sqlGrant = "GRANT ALL PRIVILEGES ON *.* TO 'sha256User2'@'%'"; } else { sqlCreateUser = "CREATE USER 'sha256User'@'%'"; sqlGrant = "GRANT ALL PRIVILEGES ON *.* TO 'sha256User'@'%' IDENTIFIED WITH " + "sha256_password BY 'password'"; + sqlCreateUser = "CREATE USER 'sha256User2'@'%'"; + sqlGrant = + "GRANT ALL PRIVILEGES ON *.* TO 'sha256User2'@'%' IDENTIFIED WITH " + + "sha256_password BY 'password'"; } sharedConn.createStatement(sqlCreateUser).execute().blockLast(); sharedConn.createStatement(sqlGrant).execute().blockLast(); @@ -150,7 +138,7 @@ public static void init() throws Exception { } @AfterAll - public static void after2() { + public static void dropAll() { Assumptions.assumeTrue(!isMariaDBServer() && minVersion(5, 7, 0)); sharedConn .createStatement("DROP USER sha256User") @@ -158,6 +146,12 @@ public static void after2() { .map(res -> res.getRowsUpdated()) .onErrorReturn(Mono.empty()) .blockLast(); + sharedConn + .createStatement("DROP USER sha256User2") + .execute() + .map(res -> res.getRowsUpdated()) + .onErrorReturn(Mono.empty()) + .blockLast(); sharedConn .createStatement("DROP USER cachingSha256User") .execute() @@ -201,7 +195,7 @@ public void sha256PluginTestWithoutServerRsaKey() throws Exception { MariadbConnectionConfiguration conf = TestConfiguration.defaultBuilder .clone() - .username("sha256User") + .username("sha256User2") .password("password") .allowPublicKeyRetrieval(true) .build(); diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/StringParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/StringParameterTest.java index d2f9a713..99e9b613 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/StringParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/StringParameterTest.java @@ -81,7 +81,7 @@ private void nullValue(MariadbConnection connection) { .createStatement("INSERT INTO StringParam VALUES (?,?,?)") .bindNull(0, BigInteger.class) .bindNull(1, BigInteger.class) - .bindNull(2, BigInteger.class) + .bindNull(2, null) .execute() .blockLast(); validate(Optional.empty(), Optional.empty(), Optional.empty()); From d6d8178afec2baa5148bc3cadef19e0a85ea8006 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Thu, 24 Jun 2021 11:48:26 +0200 Subject: [PATCH 12/20] [misc] coverage generation correction --- .travis.yml | 2 +- pom.xml | 6 +- .../r2dbc/MariadbConnectionConfiguration.java | 5 +- .../r2dbc/integration/ConfigurationTest.java | 6 +- .../r2dbc/integration/ConnectionTest.java | 4 +- .../authentication/Sha256PluginTest.java | 175 ++++++++++-------- 6 files changed, 109 insertions(+), 89 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb1172c9..e70542aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,7 @@ script: - mvn clean -Dmaven.test.skip > /dev/null - if [ -n "$BENCH" ] ; then mvn package -P bench -Dmaven.test.skip; fi - if [ -n "$BENCH" ] ; then java -Duser.country=US -Duser.language=en -DTEST_PORT=$TEST_DB_PORT -DTEST_HOST=$TEST_DB_HOST -DTEST_USERNAME=$TEST_DB_USER -DTEST_PASSWORD=$TEST_DB_PASSWORD -jar target/benchmarks.jar; fi - - if [ -z "$BENCH" ] ; then MAVEN_SKIP_RC=true MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512m" mvn test -P test -DjobId=${TRAVIS_JOB_ID}; fi + - if [ -z "$BENCH" ] ; then MAVEN_SKIP_RC=true MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512m" mvn test -P continuous-integration -DjobId=${TRAVIS_JOB_ID}; fi after_success: diff --git a/pom.xml b/pom.xml index e959aa22..036d873b 100644 --- a/pom.xml +++ b/pom.xml @@ -236,9 +236,8 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 3.0.0-M5 - -Xmx1024m paranoid @@ -312,7 +311,7 @@ - test + continuous-integration @@ -320,6 +319,7 @@ jacoco-maven-plugin 0.8.5 + true org/mariadb/r2dbc org/mariadb/r2dbc/** diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java index 353f24c9..a2026653 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java @@ -637,10 +637,11 @@ public Builder tlsProtocol(String... tlsProtocol) { this.tlsProtocol = null; return this; } - this.tlsProtocol = new ArrayList<>(); + List tmp = new ArrayList<>(); for (String protocol : tlsProtocol) { - this.tlsProtocol.add(protocol); + if (protocol != null) tmp.add(protocol); } + if (!tmp.isEmpty()) this.tlsProtocol = tmp; return this; } diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java index effb4e3f..553df13a 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java @@ -278,7 +278,11 @@ void confStringValue() { ConnectionFactoryOptions options = ConnectionFactoryOptions.parse(connectionUrl); MariadbConnectionConfiguration.Builder builder = MariadbConnectionConfiguration.fromOptions(options); - builder.tlsProtocol(null); + builder.tlsProtocol((String[]) null); + Assertions.assertEquals( + "Builder{rsaPublicKey=null, cachingRsaPublicKey=null, allowPublicKeyRetrieval=false, username=admin, connectTimeout=null, socketTimeout=null, tcpKeepAlive=null, tcpAbortiveClose=null, database=dbname, host=localhost, sessionVariables=null, connectionAttributes=null, password=*, port=3306, socket=null, allowMultiQueries=false, allowPipelining=true, useServerPrepStmts=false, prepareCacheSize=null, tlsProtocol=null, serverSslCert=null, clientSslCert=null, clientSslKey=null, clientSslPassword=null, sslMode=DISABLED, pamOtherPwd=}", + builder.toString()); + builder.tlsProtocol((String) null); Assertions.assertEquals( "Builder{rsaPublicKey=null, cachingRsaPublicKey=null, allowPublicKeyRetrieval=false, username=admin, connectTimeout=null, socketTimeout=null, tcpKeepAlive=null, tcpAbortiveClose=null, database=dbname, host=localhost, sessionVariables=null, connectionAttributes=null, password=*, port=3306, socket=null, allowMultiQueries=false, allowPipelining=true, useServerPrepStmts=false, prepareCacheSize=null, tlsProtocol=null, serverSslCert=null, clientSslCert=null, clientSslKey=null, clientSslPassword=null, sslMode=DISABLED, pamOtherPwd=}", builder.toString()); diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java index ff753b67..130e8b0e 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java @@ -725,14 +725,14 @@ public void errorOnConnection() { Assumptions.assumeTrue(maxConn.intValue() < 200); R2dbcTransientResourceException expected = null; - Mono[] cons = new Mono[maxConn.intValue()]; + Mono[] cons = new Mono[maxConn.intValue()]; for (int i = 0; i < maxConn.intValue(); i++) { cons[i] = new MariadbConnectionFactory(TestConfiguration.defaultBuilder.build()).create(); } MariadbConnection[] connections = new MariadbConnection[maxConn.intValue()]; for (int i = 0; i < maxConn.intValue(); i++) { try { - connections[i] = cons[i].block(); + connections[i] = (MariadbConnection) cons[i].block(); } catch (R2dbcTransientResourceException e) { expected = e; } diff --git a/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java b/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java index d90570eb..bfe5bc66 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java @@ -17,6 +17,7 @@ package org.mariadb.r2dbc.integration.authentication; import io.r2dbc.spi.R2dbcNonTransientResourceException; +import io.r2dbc.spi.R2dbcTransientResourceException; import java.io.File; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assumptions; @@ -49,15 +50,19 @@ public static void init() throws Exception { Assumptions.assumeTrue(!isMariaDBServer() && minVersion(5, 7, 0)); rsaPublicKey = System.getProperty("rsaPublicKey"); - if (!validPath(rsaPublicKey) && minVersion(8, 0, 0)) { - rsaPublicKey = - sharedConn - .createStatement("SELECT @@caching_sha2_password_public_key_path") - .execute() - .flatMap(r -> r.map((row, metadata) -> row.get(0, String.class))) - .blockLast(); + if (!validPath(rsaPublicKey) && minVersion(5, 7, 0)) { + rsaPublicKey = System.getenv("TEST_DB_RSA_PUBLIC_KEY"); if (!validPath(rsaPublicKey)) { - rsaPublicKey = System.getenv("TEST_DB_RSA_PUBLIC_KEY"); + try { + rsaPublicKey = + sharedConn + .createStatement("SELECT @@sha256_password_public_key_path") + .execute() + .flatMap(r -> r.map((row, metadata) -> row.get(0, String.class))) + .blockLast(); + } catch (R2dbcTransientResourceException e) { + // eat + } if (!validPath(rsaPublicKey)) { File sslDir = new File(System.getProperty("user.dir") + "/ssl"); if (sslDir.exists() && sslDir.isDirectory()) { @@ -65,75 +70,85 @@ public static void init() throws Exception { } else rsaPublicKey = null; } } - } - cachingRsaPublicKey = System.getProperty("cachingRsaPublicKey"); - if (!validPath(cachingRsaPublicKey)) { - cachingRsaPublicKey = - sharedConn - .createStatement("SELECT @@sha256_password_public_key_path") - .execute() - .flatMap(r -> r.map((row, metadata) -> row.get(0, String.class))) - .blockLast(); + cachingRsaPublicKey = System.getProperty("cachingRsaPublicKey"); if (!validPath(cachingRsaPublicKey)) { cachingRsaPublicKey = System.getenv("TEST_DB_RSA_PUBLIC_KEY"); if (!validPath(cachingRsaPublicKey)) { - File sslDir = new File(System.getProperty("user.dir") + "/ssl"); - if (sslDir.exists() && sslDir.isDirectory()) { - cachingRsaPublicKey = System.getProperty("user.dir") + "/ssl/public.key"; - } else cachingRsaPublicKey = null; + try { + cachingRsaPublicKey = + sharedConn + .createStatement("SELECT @@caching_sha2_password_public_key_path") + .execute() + .flatMap(r -> r.map((row, metadata) -> row.get(0, String.class))) + .blockLast(); + } catch (R2dbcTransientResourceException e) { + // eat + } + if (!validPath(cachingRsaPublicKey)) { + File sslDir = new File(System.getProperty("user.dir") + "/ssl"); + if (sslDir.exists() && sslDir.isDirectory()) { + cachingRsaPublicKey = System.getProperty("user.dir") + "/ssl/public.key"; + } else cachingRsaPublicKey = null; + } } } - } - dropAll(); + dropAll(); - String sqlCreateUser; - String sqlGrant; - if (minVersion(8, 0, 0)) { - sqlCreateUser = "CREATE USER 'sha256User'@'%' IDENTIFIED WITH sha256_password BY 'password'"; - sqlGrant = "GRANT ALL PRIVILEGES ON *.* TO 'sha256User'@'%'"; - sqlCreateUser = "CREATE USER 'sha256User2'@'%' IDENTIFIED WITH sha256_password BY 'password'"; - sqlGrant = "GRANT ALL PRIVILEGES ON *.* TO 'sha256User2'@'%'"; - } else { - sqlCreateUser = "CREATE USER 'sha256User'@'%'"; - sqlGrant = - "GRANT ALL PRIVILEGES ON *.* TO 'sha256User'@'%' IDENTIFIED WITH " - + "sha256_password BY 'password'"; - sqlCreateUser = "CREATE USER 'sha256User2'@'%'"; - sqlGrant = - "GRANT ALL PRIVILEGES ON *.* TO 'sha256User2'@'%' IDENTIFIED WITH " - + "sha256_password BY 'password'"; - } - sharedConn.createStatement(sqlCreateUser).execute().blockLast(); - sharedConn.createStatement(sqlGrant).execute().blockLast(); - if (minVersion(8, 0, 0)) { - sharedConn - .createStatement( - "CREATE USER 'cachingSha256User'@'%' IDENTIFIED WITH caching_sha2_password BY 'password'") - .execute() - .blockLast(); - sharedConn - .createStatement("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User'@'%'") - .execute() - .blockLast(); - sharedConn - .createStatement( - "CREATE USER 'cachingSha256User2'@'%' IDENTIFIED WITH caching_sha2_password BY 'password'") - .execute() - .blockLast(); - sharedConn - .createStatement("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User2'@'%'") - .execute() - .blockLast(); - sharedConn - .createStatement( - "CREATE USER 'cachingSha256User3'@'%' IDENTIFIED WITH caching_sha2_password BY 'password'") - .execute() - .blockLast(); - sharedConn - .createStatement("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User3'@'%'") - .execute() - .blockLast(); + String sqlCreateUser; + String sqlGrant; + String sqlCreateUser2; + String sqlGrant2; + if (minVersion(8, 0, 0)) { + sqlCreateUser = + "CREATE USER 'sha256User'@'%' IDENTIFIED WITH sha256_password BY 'password'"; + sqlGrant = "GRANT ALL PRIVILEGES ON *.* TO 'sha256User'@'%'"; + sqlCreateUser2 = + "CREATE USER 'sha256User2'@'%' IDENTIFIED WITH sha256_password BY 'password'"; + sqlGrant2 = "GRANT ALL PRIVILEGES ON *.* TO 'sha256User2'@'%'"; + } else { + sqlCreateUser = "CREATE USER 'sha256User'@'%'"; + sqlGrant = + "GRANT ALL PRIVILEGES ON *.* TO 'sha256User'@'%' IDENTIFIED WITH " + + "sha256_password BY 'password'"; + sqlCreateUser2 = "CREATE USER 'sha256User2'@'%'"; + sqlGrant2 = + "GRANT ALL PRIVILEGES ON *.* TO 'sha256User2'@'%' IDENTIFIED WITH " + + "sha256_password BY 'password'"; + } + sharedConn.createStatement(sqlCreateUser).execute().blockLast(); + sharedConn.createStatement(sqlGrant).execute().blockLast(); + sharedConn.createStatement(sqlCreateUser2).execute().blockLast(); + sharedConn.createStatement(sqlGrant2).execute().blockLast(); + if (minVersion(8, 0, 0)) { + sharedConn + .createStatement( + "CREATE USER 'cachingSha256User'@'%' IDENTIFIED WITH caching_sha2_password BY 'password'") + .execute() + .blockLast(); + sharedConn + .createStatement("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User'@'%'") + .execute() + .blockLast(); + sharedConn + .createStatement( + "CREATE USER 'cachingSha256User2'@'%' IDENTIFIED WITH caching_sha2_password BY 'password'") + .execute() + .blockLast(); + sharedConn + .createStatement("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User2'@'%'") + .execute() + .blockLast(); + sharedConn + .createStatement( + "CREATE USER 'cachingSha256User3'@'%' IDENTIFIED WITH caching_sha2_password BY 'password'") + .execute() + .blockLast(); + sharedConn + .createStatement("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User3'@'%'") + .execute() + .blockLast(); + } } } @@ -175,7 +190,7 @@ public static void dropAll() { @Test public void sha256PluginTestWithServerRsaKey() throws Exception { Assumptions.assumeTrue( - !isWindows && !isMariaDBServer() && rsaPublicKey != null && minVersion(8, 0, 0)); + !isWindows && !isMariaDBServer() && rsaPublicKey != null && minVersion(5, 7, 0)); MariadbConnectionConfiguration conf = TestConfiguration.defaultBuilder @@ -269,15 +284,15 @@ public void cachingSha256PluginTestWithoutServerRsaKey() throws Exception { .build(); MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); connection.close().block(); - - MariadbConnectionConfiguration conf2 = - TestConfiguration.defaultBuilder - .clone() - .username("cachingSha256User") - .password("password") - .build(); - MariadbConnection connection2 = new MariadbConnectionFactory(conf2).create().block(); - connection2.close().block(); + // + // MariadbConnectionConfiguration conf2 = + // TestConfiguration.defaultBuilder + // .clone() + // .username("cachingSha256User") + // .password("password") + // .build(); + // MariadbConnection connection2 = new MariadbConnectionFactory(conf2).create().block(); + // connection2.close().block(); } @Test From 31c525f7d384cd6f046f1e58dd0cd4886a6bb008 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Thu, 24 Jun 2021 16:24:25 +0200 Subject: [PATCH 13/20] [misc] coverage addition + SslMode parameter unification with jdbc driver --- README.md | 2 +- .../r2dbc/MariadbConnectionConfiguration.java | 16 ++++-- .../MariadbConnectionFactoryProvider.java | 5 +- .../java/org/mariadb/r2dbc/MariadbResult.java | 12 ++--- src/main/java/org/mariadb/r2dbc/SslMode.java | 32 +++++++++--- .../message/flow/AuthenticationFlow.java | 2 +- .../message/flow/CachingSha2PasswordFlow.java | 2 +- .../flow/Sha256PasswordPluginFlow.java | 2 +- .../org/mariadb/r2dbc/util/SslConfig.java | 10 ++-- .../r2dbc/integration/ConfigurationTest.java | 18 ++++--- .../integration/ConnectionMetadataTest.java | 4 +- .../r2dbc/integration/ConnectionTest.java | 42 +++++++++++---- .../mariadb/r2dbc/integration/TlsTest.java | 30 +++++------ .../authentication/Sha256PluginTest.java | 4 +- .../org/mariadb/r2dbc/unit/SslModeTest.java | 51 +++++++++++++++++++ 15 files changed, 170 insertions(+), 62 deletions(-) create mode 100644 src/test/java/org/mariadb/r2dbc/unit/SslModeTest.java diff --git a/README.md b/README.md index ee0be168..e3c3b4f2 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ Basic example: | **`clientSslCert`** | Permits providing client's certificate in DER form (use only for mutual authentication). Can be used in one of 3 forms :
  • clientSslCert=/path/to/cert.pem (full path to certificate)
  • clientSslCert=classpath:relative/cert.pem (relative to current classpath)
  • as verbatim DER-encoded certificate string "------BEGIN CERTIFICATE-----"
|*String*| | | **`clientSslKey`** | client private key path(for mutual authentication) |*String* | | | **`clientSslPassword`** | client private key password |*charsequence* | | -| **`sslMode`** | ssl requirement. Possible value are
  • DISABLED, // NO SSL
  • ENABLE_TRUST, // Encryption, but no certificate and hostname validation (DEVELOPMENT ONLY)
  • ENABLE_WITHOUT_HOSTNAME_VERIFICATION, // Encryption, certificates validation, BUT no hostname validation
  • ENABLE, // Standard SSL use: Encryption, certificate validation and hostname validation
| SslMode |DISABLED| +| **`sslMode`** | ssl requirement. Possible value are
  • DISABLE, // NO SSL
  • TRUST, // Encryption, but no certificate and hostname validation (DEVELOPMENT ONLY)
  • VERIFY_CA, // Encryption, certificates validation, BUT no hostname validation
  • VERIFY_FULL, // Standard SSL use: Encryption, certificate validation and hostname validation
| SslMode |DISABLE| | **`rsaPublicKey`** | only for MySQL server
Server RSA public key, for SHA256 authentication |*String* | | | **`cachingRsaPublicKey`** | only for MySQL server
Server caching RSA public key, for cachingSHA256 authentication |*String* | | | **`allowPublicKeyRetrieval`** | only for MySQL server
Permit retrieved Server RSA public key from server. This can create a security issue |*boolean* | true | diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java index a2026653..ca8481e7 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java @@ -101,7 +101,7 @@ private MariadbConnectionConfiguration( this.username = username; this.allowMultiQueries = allowMultiQueries; this.allowPipelining = allowPipelining; - if (sslMode == SslMode.DISABLED) { + if (sslMode == SslMode.DISABLE) { this.sslConfig = SslConfig.DISABLE_INSTANCE; } else { this.sslConfig = @@ -122,7 +122,7 @@ static boolean boolValue(Object value) { if (value instanceof Boolean) { return ((Boolean) value).booleanValue(); } - return Boolean.parseBoolean(value.toString()); + return Boolean.parseBoolean(value.toString()) || "1".equals(value); } static Duration durationValue(Object value) { @@ -235,6 +235,10 @@ public static Builder fromOptions(ConnectionFactoryOptions connectionFactoryOpti connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.SERVER_SSL_CERT)); builder.clientSslCert( connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.CLIENT_SSL_CERT)); + builder.clientSslKey( + connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.CLIENT_SSL_KEY)); + builder.clientSslPassword( + connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.CLIENT_SSL_PWD)); if (connectionFactoryOptions.hasOption(MariadbConnectionFactoryProvider.TLS_PROTOCOL)) { String[] protocols = @@ -495,7 +499,7 @@ public static final class Builder implements Cloneable { @Nullable private String clientSslCert; @Nullable private String clientSslKey; @Nullable private CharSequence clientSslPassword; - private SslMode sslMode = SslMode.DISABLED; + private SslMode sslMode = SslMode.DISABLE; private CharSequence[] pamOtherPwd; private Builder() {} @@ -725,7 +729,7 @@ public Builder clientSslPassword(CharSequence clientSslPassword) { public Builder sslMode(SslMode sslMode) { this.sslMode = sslMode; - if (sslMode == null) this.sslMode = SslMode.DISABLED; + if (sslMode == null) this.sslMode = SslMode.DISABLE; return this; } @@ -919,6 +923,10 @@ public String toString() { + sslMode + ", pamOtherPwd=" + hiddenPamPwd + + ", tinyInt1isBit=" + + tinyInt1isBit + + ", autoCommit=" + + autocommit + '}'; } } diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java index a8d1d393..c3a908da 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java @@ -31,12 +31,15 @@ public final class MariadbConnectionFactoryProvider implements ConnectionFactory public static final Option TLS_PROTOCOL = Option.valueOf("tlsProtocol"); public static final Option SERVER_SSL_CERT = Option.valueOf("serverSslCert"); public static final Option CLIENT_SSL_CERT = Option.valueOf("clientSslCert"); + public static final Option CLIENT_SSL_KEY = Option.valueOf("clientSslKey"); + public static final Option CLIENT_SSL_PWD = Option.valueOf("clientSslPassword"); public static final Option ALLOW_PIPELINING = Option.valueOf("allowPipelining"); public static final Option USE_SERVER_PREPARE = Option.valueOf("useServerPrepStmts"); public static final Option AUTO_COMMIT = Option.valueOf("autoCommit"); public static final Option TINY_IS_BIT = Option.valueOf("tinyInt1isBit"); public static final Option PREPARE_CACHE_SIZE = Option.valueOf("prepareCacheSize"); public static final Option SSL_MODE = Option.valueOf("sslMode"); + public static final Option CONNECTION_ATTRIBUTES = Option.valueOf("connectionAttributes"); public static final Option PAM_OTHER_PASSWORD = Option.valueOf("pamOtherPwd"); public static final Option SOCKET_TIMEOUT = Option.valueOf("socketTimeout"); @@ -65,6 +68,6 @@ public boolean supports(ConnectionFactoryOptions connectionFactoryOptions) { Assert.requireNonNull(connectionFactoryOptions, "connectionFactoryOptions must not be null"); String driver = connectionFactoryOptions.getValue(DRIVER); - return driver != null && driver.equals(MARIADB_DRIVER); + return MARIADB_DRIVER.equals(driver); } } diff --git a/src/main/java/org/mariadb/r2dbc/MariadbResult.java b/src/main/java/org/mariadb/r2dbc/MariadbResult.java index bee1a56c..eeca32f0 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbResult.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbResult.java @@ -144,12 +144,12 @@ public Flux map(BiFunction f) { if (serverMessage instanceof OkPacket && generatedColumns != null && !supportReturning) { - if (metadataList == null || metadataList.length == 0) { - String colName = generatedColumns.length > 0 ? generatedColumns[0] : "ID"; - metadataList = new ColumnDefinitionPacket[1]; - metadataList[0] = ColumnDefinitionPacket.fromGeneratedId(colName); - rowMetadata = MariadbRowMetadata.toRowMetadata(this.metadataList); - } + + String colName = generatedColumns.length > 0 ? generatedColumns[0] : "ID"; + metadataList = new ColumnDefinitionPacket[1]; + metadataList[0] = ColumnDefinitionPacket.fromGeneratedId(colName); + rowMetadata = MariadbRowMetadata.toRowMetadata(this.metadataList); + OkPacket okPacket = ((OkPacket) serverMessage); if (okPacket.getAffectedRows() > 1) { sink.error( diff --git a/src/main/java/org/mariadb/r2dbc/SslMode.java b/src/main/java/org/mariadb/r2dbc/SslMode.java index 0a13c4fd..8bf444ee 100644 --- a/src/main/java/org/mariadb/r2dbc/SslMode.java +++ b/src/main/java/org/mariadb/r2dbc/SslMode.java @@ -17,17 +17,37 @@ package org.mariadb.r2dbc; public enum SslMode { - DISABLED, // NO SSL - ENABLE_TRUST, // Encryption, but no certificate and hostname validation (DEVELOPMENT ONLY) - ENABLE_WITHOUT_HOSTNAME_VERIFICATION, // Encryption, certificates validation, BUT no hostname - // validation - ENABLE; // Standard SSL use: Encryption, certificate validation and hostname validation + + // NO SSL + DISABLE("disable", new String[] {"DISABLED", "0", "false"}), + + // Encryption only (no certificate and hostname validation) (DEVELOPMENT ONLY) + TRUST("trust", new String[] {"REQUIRED", "ENABLE_TRUST"}), + + // Encryption, certificates validation, BUT no hostname verification + VERIFY_CA("verify-ca", new String[] {"VERIFY_CA", "ENABLE_WITHOUT_HOSTNAME_VERIFICATION"}), + + // Standard SSL use: Encryption, certificate validation and hostname validation + VERIFY_FULL("verify-full", new String[] {"VERIFY_IDENTITY", "1", "true", "enable"}); + + private final String value; + private final String[] aliases; + + SslMode(String value, String[] aliases) { + this.value = value; + this.aliases = aliases; + } public static SslMode from(String value) { for (SslMode sslMode : values()) { - if (sslMode.name().equalsIgnoreCase(value)) { + if (sslMode.value.equalsIgnoreCase(value) || sslMode.name().equalsIgnoreCase(value)) { return sslMode; } + for (String alias : sslMode.aliases) { + if (alias.equalsIgnoreCase(value)) { + return sslMode; + } + } } throw new IllegalArgumentException( String.format("Wrong argument value '%s' for SslMode", value)); diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java index 19f109d8..59a87b5d 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java @@ -151,7 +151,7 @@ Mono handle(AuthenticationFlow flow) { initializeClientCapabilities( flow.initialHandshakePacket.getCapabilities(), flow.configuration); - if (flow.configuration.getSslConfig().getSslMode() != SslMode.DISABLED) { + if (flow.configuration.getSslConfig().getSslMode() != SslMode.DISABLE) { if ((packet.getCapabilities() & Capabilities.SSL) == 0) { sink.error( new R2dbcNonTransientResourceException( diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/CachingSha2PasswordFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/CachingSha2PasswordFlow.java index 682cc769..0fa438b4 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/CachingSha2PasswordFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/CachingSha2PasswordFlow.java @@ -104,7 +104,7 @@ public ClientMessage next( return null; case 4: - if (configuration.getSslConfig().getSslMode() != SslMode.DISABLED) { + if (configuration.getSslConfig().getSslMode() != SslMode.DISABLE) { // send clear password state = State.SEND_AUTH; return new ClearPasswordPacket(authMoreDataPacket.getSequencer(), password); diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/Sha256PasswordPluginFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/Sha256PasswordPluginFlow.java index 25fdf643..af99832b 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/Sha256PasswordPluginFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/Sha256PasswordPluginFlow.java @@ -121,7 +121,7 @@ public ClientMessage next( CharSequence password = configuration.getPassword(); if (password == null || password.toString().isEmpty() - || configuration.getSslConfig().getSslMode() != SslMode.DISABLED) { + || configuration.getSslConfig().getSslMode() != SslMode.DISABLE) { return new ClearPasswordPacket(authSwitchPacket.getSequencer(), password); } else { // retrieve public key from configuration or from server diff --git a/src/main/java/org/mariadb/r2dbc/util/SslConfig.java b/src/main/java/org/mariadb/r2dbc/util/SslConfig.java index 71c05489..3eb60517 100644 --- a/src/main/java/org/mariadb/r2dbc/util/SslConfig.java +++ b/src/main/java/org/mariadb/r2dbc/util/SslConfig.java @@ -38,7 +38,7 @@ public class SslConfig { - public static final SslConfig DISABLE_INSTANCE = new SslConfig(SslMode.DISABLED); + public static final SslConfig DISABLE_INSTANCE = new SslConfig(SslMode.DISABLE); private SslMode sslMode; private String serverSslCert; @@ -63,7 +63,7 @@ public SslConfig( this.clientSslCert = clientSslCert; this.clientSslKey = clientSslKey; this.clientSslPassword = clientSslPassword; - if (sslMode != SslMode.DISABLED) { + if (sslMode != SslMode.DISABLE) { sslContextBuilder = getSslContextBuilder(); } } @@ -79,7 +79,7 @@ public SslMode getSslMode() { private SslContextBuilder getSslContextBuilder() throws R2dbcTransientResourceException { final SslContextBuilder sslCtxBuilder = SslContextBuilder.forClient(); - if (sslMode == SslMode.ENABLE_TRUST) { + if (sslMode == SslMode.TRUST) { sslCtxBuilder.trustManager(InsecureTrustManagerFactory.INSTANCE); } else { @@ -156,7 +156,7 @@ public GenericFutureListener> getHostNa result.completeExceptionally(future.cause()); return; } - if (sslMode == SslMode.ENABLE) { + if (sslMode == SslMode.VERIFY_FULL) { try { DefaultHostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(); SSLSession session = engine.getSession(); @@ -190,6 +190,8 @@ public String toString() { + clientSslCert + ", tlsProtocol=" + tlsProtocol + + ", clientSslKey=" + + clientSslKey + '}'; } } diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java index 553df13a..e8ab49cb 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java @@ -80,7 +80,7 @@ void checkOptions() { (MariadbConnectionFactory) ConnectionFactories.get( "r2dbc:mariadb://root:pwd@localhost:3306/db?socket=ff&allowMultiQueries=true&tlsProtocol=TLSv1" - + ".2&serverSslCert=myCert&clientSslCert=myClientCert&allowPipelining=true&useServerPrepStmts" + + ".2&serverSslCert=myCert&clientSslCert=myClientCert&clientSslKey=bla&clientSslPassword=bla2&allowPipelining=true&useServerPrepStmts" + "=true&prepareCacheSize=2560&connectTimeout=PT10S&socketTimeout=PT1H&tcpKeepAlive=true" + "&tcpAbortiveClose=true&sslMode=ENABLE_TRUST" + "&connectionAttributes" @@ -94,13 +94,14 @@ void checkOptions() { Assertions.assertTrue(factory.toString().contains("allowPipelining=true")); Assertions.assertTrue(factory.toString().contains("useServerPrepStmts=true")); Assertions.assertTrue(factory.toString().contains("prepareCacheSize=2560")); - Assertions.assertTrue(factory.toString().contains("sslMode=ENABLE_TRUST")); + Assertions.assertTrue(factory.toString().contains("sslMode=TRUST")); Assertions.assertTrue(factory.toString().contains("connectionAttributes={test=2, h=4}")); Assertions.assertTrue(factory.toString().contains("pamOtherPwd=*,*")); Assertions.assertTrue(factory.toString().contains("connectTimeout=PT10S")); Assertions.assertTrue(factory.toString().contains("socketTimeout=PT1H")); Assertions.assertTrue(factory.toString().contains("tcpKeepAlive=true")); Assertions.assertTrue(factory.toString().contains("tcpAbortiveClose=true")); + Assertions.assertTrue(factory.toString().contains("clientSslKey=bla")); } @Test @@ -274,21 +275,26 @@ void sessionVariablesParsing() { @Test void confStringValue() { String connectionUrl = - "r2dbc:mariadb://admin:pass@localhost:3306/dbname?allowMultiQueries=blabla"; + "r2dbc:mariadb://admin:pass@localhost:3306/dbname?allowMultiQueries=blabla&autoCommit=1&tinyInt1isBit=0"; ConnectionFactoryOptions options = ConnectionFactoryOptions.parse(connectionUrl); MariadbConnectionConfiguration.Builder builder = MariadbConnectionConfiguration.fromOptions(options); + builder.sslMode(null); + Assertions.assertTrue(builder.toString().contains("sslMode=DISABLE")); + builder.sslMode(SslMode.TRUST); + Assertions.assertTrue(builder.toString().contains("sslMode=TRUST")); + builder.pamOtherPwd(new String[] {"fff", "ddd"}); builder.tlsProtocol((String[]) null); Assertions.assertEquals( - "Builder{rsaPublicKey=null, cachingRsaPublicKey=null, allowPublicKeyRetrieval=false, username=admin, connectTimeout=null, socketTimeout=null, tcpKeepAlive=null, tcpAbortiveClose=null, database=dbname, host=localhost, sessionVariables=null, connectionAttributes=null, password=*, port=3306, socket=null, allowMultiQueries=false, allowPipelining=true, useServerPrepStmts=false, prepareCacheSize=null, tlsProtocol=null, serverSslCert=null, clientSslCert=null, clientSslKey=null, clientSslPassword=null, sslMode=DISABLED, pamOtherPwd=}", + "Builder{rsaPublicKey=null, cachingRsaPublicKey=null, allowPublicKeyRetrieval=false, username=admin, connectTimeout=null, socketTimeout=null, tcpKeepAlive=null, tcpAbortiveClose=null, database=dbname, host=localhost, sessionVariables=null, connectionAttributes=null, password=*, port=3306, socket=null, allowMultiQueries=false, allowPipelining=true, useServerPrepStmts=false, prepareCacheSize=null, tlsProtocol=null, serverSslCert=null, clientSslCert=null, clientSslKey=null, clientSslPassword=null, sslMode=TRUST, pamOtherPwd=*,*, tinyInt1isBit=false, autoCommit=true}", builder.toString()); builder.tlsProtocol((String) null); Assertions.assertEquals( - "Builder{rsaPublicKey=null, cachingRsaPublicKey=null, allowPublicKeyRetrieval=false, username=admin, connectTimeout=null, socketTimeout=null, tcpKeepAlive=null, tcpAbortiveClose=null, database=dbname, host=localhost, sessionVariables=null, connectionAttributes=null, password=*, port=3306, socket=null, allowMultiQueries=false, allowPipelining=true, useServerPrepStmts=false, prepareCacheSize=null, tlsProtocol=null, serverSslCert=null, clientSslCert=null, clientSslKey=null, clientSslPassword=null, sslMode=DISABLED, pamOtherPwd=}", + "Builder{rsaPublicKey=null, cachingRsaPublicKey=null, allowPublicKeyRetrieval=false, username=admin, connectTimeout=null, socketTimeout=null, tcpKeepAlive=null, tcpAbortiveClose=null, database=dbname, host=localhost, sessionVariables=null, connectionAttributes=null, password=*, port=3306, socket=null, allowMultiQueries=false, allowPipelining=true, useServerPrepStmts=false, prepareCacheSize=null, tlsProtocol=null, serverSslCert=null, clientSslCert=null, clientSslKey=null, clientSslPassword=null, sslMode=TRUST, pamOtherPwd=*,*, tinyInt1isBit=false, autoCommit=true}", builder.toString()); MariadbConnectionConfiguration conf = builder.build(); Assertions.assertEquals( - "SslConfig{sslMode=DISABLED, serverSslCert=null, clientSslCert=null, tlsProtocol=null}", + "SslConfig{sslMode=TRUST, serverSslCert=null, clientSslCert=null, tlsProtocol=null, clientSslKey=null}", conf.getSslConfig().toString()); } } diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConnectionMetadataTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConnectionMetadataTest.java index 089bf6ae..5686ee09 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConnectionMetadataTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConnectionMetadataTest.java @@ -29,9 +29,7 @@ public class ConnectionMetadataTest extends BaseConnectionTest { @Test void connectionMeta() { ConnectionMetadata meta = sharedConn.getMetadata(); - assertTrue( - meta.getDatabaseProductName().equals("MariaDB") - || meta.getDatabaseProductName().equals("MySQL")); + assertTrue(meta.getDatabaseProductName().equals(isMariaDBServer() ? "MariaDB" : "MySQL")); if (isMariaDBServer()) { assertTrue(meta.getDatabaseVersion().contains("10.")); } else { diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java index 130e8b0e..98b3c296 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java @@ -689,21 +689,21 @@ void toStringTest() { } } + IsolationLevel[] levels = + new IsolationLevel[] { + IsolationLevel.READ_UNCOMMITTED, + IsolationLevel.READ_COMMITTED, + IsolationLevel.SERIALIZABLE, + IsolationLevel.REPEATABLE_READ + }; + @Test public void isolationLevel() { MariadbConnection connection = new MariadbConnectionFactory(TestConfiguration.defaultBuilder.build()).create().block(); Assertions.assertThrows( - Exception.class, - () -> connection.setTransactionIsolationLevel((IsolationLevel) null).block()); - IsolationLevel[] levels = - new IsolationLevel[] { - IsolationLevel.READ_UNCOMMITTED, - IsolationLevel.READ_COMMITTED, - IsolationLevel.SERIALIZABLE, - IsolationLevel.REPEATABLE_READ - }; + Exception.class, () -> connection.setTransactionIsolationLevel(null).block()); for (IsolationLevel level : levels) { connection.setTransactionIsolationLevel(level).block(); assertEquals(level, connection.getTransactionIsolationLevel()); @@ -714,6 +714,30 @@ public void isolationLevel() { () -> connection.setTransactionIsolationLevel(IsolationLevel.READ_UNCOMMITTED).block()); } + @Test + public void initialIsolationLevel() { + for (IsolationLevel level : levels) { + sharedConn + .createStatement("SET GLOBAL TRANSACTION ISOLATION LEVEL " + level.asSql()) + .execute() + .blockLast(); + MariadbConnection connection = + new MariadbConnectionFactory(TestConfiguration.defaultBuilder.build()).create().block(); + assertEquals(level, connection.getTransactionIsolationLevel()); + connection.close().block(); + } + + IsolationLevel defaultValue = IsolationLevel.REPEATABLE_READ; + if ("skysql".equals(System.getenv("srv")) || "skysql-ha".equals(System.getenv("srv"))) { + defaultValue = IsolationLevel.READ_COMMITTED; + } + + sharedConn + .createStatement("SET GLOBAL TRANSACTION ISOLATION LEVEL " + defaultValue.asSql()) + .execute() + .blockLast(); + } + @Test public void errorOnConnection() { BigInteger maxConn = diff --git a/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java b/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java index 78001f4c..055e71eb 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java @@ -115,11 +115,7 @@ void trustValidation() throws Exception { !"maxscale".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv"))); Assumptions.assumeTrue(haveSsl(sharedConn)); MariadbConnectionConfiguration conf = - TestConfiguration.defaultBuilder - .clone() - .port(sslPort) - .sslMode(SslMode.ENABLE_TRUST) - .build(); + TestConfiguration.defaultBuilder.clone().port(sslPort).sslMode(SslMode.TRUST).build(); MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); connection .createStatement("SHOW STATUS like 'Ssl_version'") @@ -144,7 +140,7 @@ void wrongCertificateFiles() throws Exception { TestConfiguration.defaultBuilder .clone() .port(sslPort) - .sslMode(SslMode.ENABLE_WITHOUT_HOSTNAME_VERIFICATION) + .sslMode(SslMode.VERIFY_CA) .serverSslCert("wrongFile") .build(), "Failed to find serverSslCert file. serverSslCert=wrongFile"); @@ -155,7 +151,7 @@ void wrongCertificateFiles() throws Exception { TestConfiguration.defaultBuilder .clone() .port(sslPort) - .sslMode(SslMode.ENABLE_WITHOUT_HOSTNAME_VERIFICATION) + .sslMode(SslMode.VERIFY_CA) .serverSslCert(serverSslCert) .clientSslCert("wrongFile") .clientSslKey("dd") @@ -171,7 +167,7 @@ void wrongCertificateFiles() throws Exception { TestConfiguration.defaultBuilder .clone() .port(sslPort) - .sslMode(SslMode.ENABLE_WITHOUT_HOSTNAME_VERIFICATION) + .sslMode(SslMode.VERIFY_CA) .serverSslCert(serverSslCert) .clientSslCert(clientSslCert) .clientSslKey("dd") @@ -193,7 +189,7 @@ void trustForceProtocol() throws Exception { TestConfiguration.defaultBuilder .clone() .port(sslPort) - .sslMode(SslMode.ENABLE_TRUST) + .sslMode(SslMode.TRUST) .tlsProtocol(trustProtocol) .build(); MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); @@ -215,7 +211,7 @@ void withoutHostnameValidation() throws Throwable { TestConfiguration.defaultBuilder .clone() .port(sslPort) - .sslMode(SslMode.ENABLE_WITHOUT_HOSTNAME_VERIFICATION) + .sslMode(SslMode.VERIFY_CA) .serverSslCert(serverSslCert) .build(); MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); @@ -235,7 +231,7 @@ void withoutHostnameValidation() throws Throwable { MariadbConnectionConfiguration conf2 = TestConfiguration.defaultBuilder .clone() - .sslMode(SslMode.ENABLE_WITHOUT_HOSTNAME_VERIFICATION) + .sslMode(SslMode.VERIFY_CA) .serverSslCert(serverCertString) .build(); MariadbConnection con2 = new MariadbConnectionFactory(conf2).create().block(); @@ -259,8 +255,8 @@ void fullWithoutServerCert() throws Exception { Assumptions.assumeTrue(haveSsl(sharedConn)); assertThrows( R2dbcTransientResourceException.class, - () -> TestConfiguration.defaultBuilder.clone().sslMode(SslMode.ENABLE).build(), - "Server certificate needed (option `serverSslCert`) for ssl mode ENABLE"); + () -> TestConfiguration.defaultBuilder.clone().sslMode(SslMode.VERIFY_FULL).build(), + "Server certificate needed (option `serverSslCert`) for ssl mode VERIFY_FULL"); } @Test @@ -271,7 +267,7 @@ void fullValidationFailing() throws Exception { TestConfiguration.defaultBuilder .clone() .port(sslPort) - .sslMode(SslMode.ENABLE) + .sslMode(SslMode.VERIFY_FULL) .serverSslCert(serverSslCert) .build(); if (!conf.getHost().equals("mariadb.example.com")) { @@ -308,7 +304,7 @@ void fullValidation() throws Exception { TestConfiguration.defaultBuilder .clone() .port(sslPort) - .sslMode(SslMode.ENABLE) + .sslMode(SslMode.VERIFY_FULL) .host("mariadb.example.com") .serverSslCert(serverSslCert) .build(); @@ -338,7 +334,7 @@ void fullMutualWithoutClientCerts() throws Exception { MariadbConnectionConfiguration conf = TestConfiguration.defaultBuilder .clone() - .sslMode(SslMode.ENABLE) + .sslMode(SslMode.VERIFY_FULL) .port(sslPort) .username("MUTUAL_AUTH") .password("ssltestpassword") @@ -363,7 +359,7 @@ void fullMutualAuthentication() throws Exception { MariadbConnectionConfiguration conf = TestConfiguration.defaultBuilder .clone() - .sslMode(SslMode.ENABLE) + .sslMode(SslMode.VERIFY_FULL) .port(sslPort) .username("MUTUAL_AUTH") .password("ssltestpassword") diff --git a/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java b/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java index bfe5bc66..1fd4bb00 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java @@ -249,7 +249,7 @@ public void sha256PluginTestSsl() throws Exception { .username("sha256User") .password("password") .allowPublicKeyRetrieval(true) - .sslMode(SslMode.ENABLE_TRUST) + .sslMode(SslMode.TRUST) .build(); MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); connection.close().block(); @@ -327,7 +327,7 @@ public void cachingSha256PluginTestSsl() throws Exception { .clone() .username("cachingSha256User") .password("password") - .sslMode(SslMode.ENABLE_TRUST) + .sslMode(SslMode.TRUST) .build(); MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); connection.close().block(); diff --git a/src/test/java/org/mariadb/r2dbc/unit/SslModeTest.java b/src/test/java/org/mariadb/r2dbc/unit/SslModeTest.java new file mode 100644 index 00000000..c3c1482f --- /dev/null +++ b/src/test/java/org/mariadb/r2dbc/unit/SslModeTest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2020 MariaDB Ab. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.mariadb.r2dbc.unit; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mariadb.r2dbc.SslMode; + +public class SslModeTest { + + @Test + public void parse() throws Exception { + Assertions.assertEquals(SslMode.DISABLE, SslMode.from("disable")); + Assertions.assertEquals(SslMode.DISABLE, SslMode.from("DISABLE")); + Assertions.assertEquals(SslMode.DISABLE, SslMode.from("DISABLED")); + Assertions.assertEquals(SslMode.DISABLE, SslMode.from("0")); + Assertions.assertEquals(SslMode.DISABLE, SslMode.from("false")); + + Assertions.assertThrows(IllegalArgumentException.class, () -> SslMode.from("wrong")); + + Assertions.assertEquals(SslMode.TRUST, SslMode.from("trust")); + Assertions.assertEquals(SslMode.TRUST, SslMode.from("REQUIRED")); + Assertions.assertEquals(SslMode.TRUST, SslMode.from("enable_trust")); + + Assertions.assertEquals(SslMode.VERIFY_CA, SslMode.from("verify-ca")); + Assertions.assertEquals(SslMode.VERIFY_CA, SslMode.from("VERIFY_CA")); + Assertions.assertEquals( + SslMode.VERIFY_CA, SslMode.from("ENABLE_WITHOUT_HOSTNAME_VERIFICATION")); + + Assertions.assertEquals(SslMode.VERIFY_FULL, SslMode.from("verify-full")); + Assertions.assertEquals(SslMode.VERIFY_FULL, SslMode.from("VERIFY_FULL")); + Assertions.assertEquals(SslMode.VERIFY_FULL, SslMode.from("VERIFY_IDENTITY")); + Assertions.assertEquals(SslMode.VERIFY_FULL, SslMode.from("1")); + Assertions.assertEquals(SslMode.VERIFY_FULL, SslMode.from("true")); + Assertions.assertEquals(SslMode.VERIFY_FULL, SslMode.from("enable")); + } +} From 6ad64b702b82c64d6ea375e0f53a8d0cf91baf02 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Fri, 25 Jun 2021 13:58:32 +0200 Subject: [PATCH 14/20] [misc] ssl test correction --- .travis.yml | 4 +- codecov.yml | 3 + .../java/org/mariadb/r2dbc/codec/Codecs.java | 2 +- .../r2dbc/integration/ConnectionTest.java | 10 ++- .../mariadb/r2dbc/integration/TlsTest.java | 62 ++++++++----------- .../integration/codec/DateParseTest.java | 16 +++++ .../integration/codec/TimeParseTest.java | 13 ++++ .../mariadb/r2dbc/unit/InitFinalClass.java | 12 ++++ 8 files changed, 79 insertions(+), 43 deletions(-) create mode 100644 codecov.yml create mode 100644 src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java diff --git a/.travis.yml b/.travis.yml index e70542aa..a214ab31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ os: linux +dist: focal language: java services: docker jdk: openjdk11 @@ -18,7 +19,7 @@ install: connector-test-machine/launch.bat -t "$srv" -v "$v" -d testr2 ;; linux) - source connector-test-machine/launch.sh -t "$srv" -v "$v" -d testr2 + source connector-test-machine/launch.sh -t "$srv" -v "$v" -d testr2 -n 0 -l "$local" ;; esac @@ -31,6 +32,7 @@ jobs: os: windows language: shell - env: srv=mariadb v=10.2 local=1 + dist: bionic - env: srv=mariadb v=10.3 local=1 - env: srv=mariadb v=10.4 local=1 - env: srv=mariadb v=10.5 local=1 diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..e3c1bfda --- /dev/null +++ b/codecov.yml @@ -0,0 +1,3 @@ +comment: off +ignore: + - "src/main/java/org/mariadb/r2dbc/authentication/ed25519" # ignore folders and all its contents diff --git a/src/main/java/org/mariadb/r2dbc/codec/Codecs.java b/src/main/java/org/mariadb/r2dbc/codec/Codecs.java index 6f2641fe..3befb44e 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/Codecs.java +++ b/src/main/java/org/mariadb/r2dbc/codec/Codecs.java @@ -20,7 +20,7 @@ import java.util.Map; import org.mariadb.r2dbc.codec.list.*; -public class Codecs { +public final class Codecs { public static final Codec[] LIST = new Codec[] { diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java index 98b3c296..a5c8341b 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java @@ -716,6 +716,8 @@ public void isolationLevel() { @Test public void initialIsolationLevel() { + Assumptions.assumeTrue( + !"skysql".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv"))); for (IsolationLevel level : levels) { sharedConn .createStatement("SET GLOBAL TRANSACTION ISOLATION LEVEL " + level.asSql()) @@ -727,13 +729,9 @@ public void initialIsolationLevel() { connection.close().block(); } - IsolationLevel defaultValue = IsolationLevel.REPEATABLE_READ; - if ("skysql".equals(System.getenv("srv")) || "skysql-ha".equals(System.getenv("srv"))) { - defaultValue = IsolationLevel.READ_COMMITTED; - } - sharedConn - .createStatement("SET GLOBAL TRANSACTION ISOLATION LEVEL " + defaultValue.asSql()) + .createStatement( + "SET GLOBAL TRANSACTION ISOLATION LEVEL " + IsolationLevel.REPEATABLE_READ.asSql()) .execute() .blockLast(); } diff --git a/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java b/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java index 055e71eb..2429a845 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java @@ -43,13 +43,14 @@ public class TlsTest extends BaseConnectionTest { @BeforeAll public static void before2() { - serverSslCert = System.getenv("TEST_SERVER_SSL_CERT"); - clientSslCert = System.getenv("TEST_CLIENT_SSL_CERT"); - clientSslKey = System.getenv("TEST_CLIENT_KEY"); + serverSslCert = System.getenv("TEST_DB_SERVER_CERT"); + clientSslCert = System.getenv("TEST_DB_CLIENT_CERT"); + clientSslKey = System.getenv("TEST_DB_CLIENT_KEY"); sslPort = - System.getenv("SSLPORT") == null || System.getenv("SSLPORT").isEmpty() + System.getenv("TEST_MAXSCALE_TLS_PORT") == null + || System.getenv("TEST_MAXSCALE_TLS_PORT").isEmpty() ? TestConfiguration.port - : Integer.valueOf(System.getenv("SSLPORT")); + : Integer.valueOf(System.getenv("TEST_MAXSCALE_TLS_PORT")); // try default if not present if (serverSslCert == null) { File sslDir = new File(System.getProperty("user.dir") + "/../ssl"); @@ -79,9 +80,9 @@ public static void before2() { if (useOldNotation) { create_sql = "CREATE USER 'MUTUAL_AUTH'"; grant_sql = - "grant all privileges on *.* to 'MUTUAL_AUTH' identified by 'ssltestpassword' REQUIRE X509"; + "grant all privileges on *.* to 'MUTUAL_AUTH' identified by 'MySup8%rPassw@ord' REQUIRE X509"; } else { - create_sql = "CREATE USER 'MUTUAL_AUTH' identified by 'ssltestpassword' REQUIRE X509"; + create_sql = "CREATE USER 'MUTUAL_AUTH' identified by 'MySup8%rPassw@ord' REQUIRE X509"; grant_sql = "grant all privileges on *.* to 'MUTUAL_AUTH'"; } sharedConn.createStatement(create_sql).execute().subscribe(); @@ -231,6 +232,7 @@ void withoutHostnameValidation() throws Throwable { MariadbConnectionConfiguration conf2 = TestConfiguration.defaultBuilder .clone() + .port(sslPort) .sslMode(SslMode.VERIFY_CA) .serverSslCert(serverCertString) .build(); @@ -261,8 +263,11 @@ void fullWithoutServerCert() throws Exception { @Test void fullValidationFailing() throws Exception { + Assumptions.assumeTrue( + !"skysql".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv"))); Assumptions.assumeTrue(haveSsl(sharedConn)); Assumptions.assumeTrue(serverSslCert != null); + Assumptions.assumeFalse("mariadb.example.com".equals(TestConfiguration.host)); MariadbConnectionConfiguration conf = TestConfiguration.defaultBuilder .clone() @@ -270,34 +275,20 @@ void fullValidationFailing() throws Exception { .sslMode(SslMode.VERIFY_FULL) .serverSslCert(serverSslCert) .build(); - if (!conf.getHost().equals("mariadb.example.com")) { - new MariadbConnectionFactory(conf) - .create() - .as(StepVerifier::create) - .expectErrorMatches( - throwable -> - throwable instanceof R2dbcNonTransientException - && throwable.getMessage().contains("SSL hostname verification failed ")) - .verify(); - } else { - MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); - connection - .createStatement("SHOW STATUS like 'Ssl_version'") - .execute() - .flatMap(r -> r.map((row, metadata) -> row.get(1))) - .as(StepVerifier::create) - .expectNextMatches( - val -> { - String[] values = {"TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"}; - return Arrays.stream(values).anyMatch(val::equals); - }) - .verifyComplete(); - connection.close().block(); - } + new MariadbConnectionFactory(conf) + .create() + .as(StepVerifier::create) + .expectErrorMatches( + throwable -> + throwable instanceof R2dbcNonTransientException + && throwable.getMessage().contains("SSL hostname verification failed ")) + .verify(); } @Test void fullValidation() throws Exception { + Assumptions.assumeTrue( + !"skysql".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv"))); Assumptions.assumeTrue(haveSsl(sharedConn)); Assumptions.assumeTrue(serverSslCert != null); MariadbConnectionConfiguration conf = @@ -308,6 +299,7 @@ void fullValidation() throws Exception { .host("mariadb.example.com") .serverSslCert(serverSslCert) .build(); + MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); connection .createStatement("SHOW STATUS like 'Ssl_version'") @@ -334,10 +326,10 @@ void fullMutualWithoutClientCerts() throws Exception { MariadbConnectionConfiguration conf = TestConfiguration.defaultBuilder .clone() - .sslMode(SslMode.VERIFY_FULL) + .sslMode(SslMode.TRUST) .port(sslPort) .username("MUTUAL_AUTH") - .password("ssltestpassword") + .password("MySup8%rPassw@ord") .host("mariadb.example.com") .serverSslCert(serverSslCert) .clientSslKey(clientSslKey) @@ -359,10 +351,10 @@ void fullMutualAuthentication() throws Exception { MariadbConnectionConfiguration conf = TestConfiguration.defaultBuilder .clone() - .sslMode(SslMode.VERIFY_FULL) + .sslMode(SslMode.TRUST) .port(sslPort) .username("MUTUAL_AUTH") - .password("ssltestpassword") + .password("MySup8%rPassw@ord") .host("mariadb.example.com") .serverSslCert(serverSslCert) .clientSslCert(clientSslCert) diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java index a32f602d..d3a5bcb8 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.mariadb.r2dbc.BaseConnectionTest; +import org.mariadb.r2dbc.BaseTest; import org.mariadb.r2dbc.api.MariadbConnection; import reactor.test.StepVerifier; @@ -153,6 +154,21 @@ private void booleanValue(MariadbConnection connection) { .getMessage() .equals("No decoder for type java.lang.Boolean and column type DATE")) .verify(); + + connection + .createStatement("SELECT t1 FROM DateTable WHERE 1 = ? LIMIT 1") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, BaseTest.class)))) + .as(StepVerifier::create) + .expectErrorMatches( + throwable -> + throwable instanceof R2dbcTransientResourceException + && throwable + .getMessage() + .equals("No decoder for type org.mariadb.r2dbc.BaseTest and column type DATE")) + .verify(); + } @Test diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java index 9aebdf4c..80191b90 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java @@ -78,6 +78,19 @@ private void defaultValue(MariadbConnection connection) { Optional.of(Duration.parse("PT22S")), Optional.empty()) .verifyComplete(); + connection + .createStatement("SELECT t2 FROM TimeParseTest WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0)))) + .as(StepVerifier::create) + .expectNext( + Optional.of(Duration.parse("PT-10H-1M-2.01234S")), + Optional.of(Duration.parse("PT-10.123S")), + Optional.of(Duration.parse("PT-8M")), + Optional.of(Duration.parse("PT-22S")), + Optional.empty()) + .verifyComplete(); } @Test diff --git a/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java b/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java new file mode 100644 index 00000000..4cd1270d --- /dev/null +++ b/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java @@ -0,0 +1,12 @@ +package org.mariadb.r2dbc.unit; + +import org.junit.jupiter.api.Test; +import org.mariadb.r2dbc.codec.Codecs; + +public class InitFinalClass { + + @Test + public void init() throws Exception { + Codecs codecs = new Codecs(); + } +} From 704f69e9be98e787c1fb0e4d5039428b997a1a43 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Fri, 25 Jun 2021 14:59:48 +0200 Subject: [PATCH 15/20] [R2DBC-28] mutual authentication correction when using TRUST mode --- .../org/mariadb/r2dbc/util/SslConfig.java | 45 +++++++++---------- .../r2dbc/integration/ConfigurationTest.java | 38 +++++++++++++--- .../mariadb/r2dbc/integration/TlsTest.java | 12 +++-- .../integration/codec/DateParseTest.java | 26 +++++------ .../integration/codec/TimeParseTest.java | 24 +++++----- .../mariadb/r2dbc/unit/InitFinalClass.java | 8 ++-- 6 files changed, 87 insertions(+), 66 deletions(-) diff --git a/src/main/java/org/mariadb/r2dbc/util/SslConfig.java b/src/main/java/org/mariadb/r2dbc/util/SslConfig.java index 3eb60517..7dc42d45 100644 --- a/src/main/java/org/mariadb/r2dbc/util/SslConfig.java +++ b/src/main/java/org/mariadb/r2dbc/util/SslConfig.java @@ -97,30 +97,29 @@ private SslContextBuilder getSslContextBuilder() throws R2dbcTransientResourceEx throw new R2dbcTransientResourceException( "Server certificate needed (option `serverSslCert`) for ssl mode " + sslMode, "08000"); } + } + if (clientSslCert != null && clientSslKey != null) { + InputStream certificatesStream; + try { + certificatesStream = loadCert(clientSslCert); + } catch (FileNotFoundException fileNotFoundEx) { + throw new R2dbcTransientResourceException( + "Failed to find clientSslCert file. clientSslCert=" + clientSslCert, + "08000", + fileNotFoundEx); + } - if (clientSslCert != null && clientSslKey != null) { - InputStream certificatesStream; - try { - certificatesStream = loadCert(clientSslCert); - } catch (FileNotFoundException fileNotFoundEx) { - throw new R2dbcTransientResourceException( - "Failed to find clientSslCert file. clientSslCert=" + clientSslCert, - "08000", - fileNotFoundEx); - } - - try { - InputStream privateKeyStream = new FileInputStream(clientSslKey); - sslCtxBuilder.keyManager( - certificatesStream, - privateKeyStream, - clientSslPassword == null ? null : clientSslPassword.toString()); - } catch (FileNotFoundException fileNotFoundEx) { - throw new R2dbcTransientResourceException( - "Failed to find clientSslKey file. clientSslKey=" + clientSslKey, - "08000", - fileNotFoundEx); - } + try { + InputStream privateKeyStream = new FileInputStream(clientSslKey); + sslCtxBuilder.keyManager( + certificatesStream, + privateKeyStream, + clientSslPassword == null ? null : clientSslPassword.toString()); + } catch (FileNotFoundException fileNotFoundEx) { + throw new R2dbcTransientResourceException( + "Failed to find clientSslKey file. clientSslKey=" + clientSslKey, + "08000", + fileNotFoundEx); } } diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java index e8ab49cb..dc9e65a2 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java @@ -17,6 +17,7 @@ package org.mariadb.r2dbc.integration; import io.r2dbc.spi.*; +import java.io.File; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; @@ -24,6 +25,7 @@ import java.util.HashMap; import java.util.Map; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import org.mariadb.r2dbc.*; import org.mariadb.r2dbc.api.MariadbConnection; @@ -75,22 +77,45 @@ void ensureUserInfoUrlEncoding() { } @Test - void checkOptions() { + void checkOptions() throws Exception { + + String serverSslCert = System.getenv("TEST_DB_SERVER_CERT"); + String clientSslCert = System.getenv("TEST_DB_CLIENT_CERT"); + String clientSslKey = System.getenv("TEST_DB_CLIENT_KEY"); + + // try default if not present + if (serverSslCert == null) { + File sslDir = new File(System.getProperty("user.dir") + "/../../ssl"); + if (sslDir.exists() && sslDir.isDirectory()) { + + serverSslCert = System.getProperty("user.dir") + "/../../ssl/server.crt"; + clientSslCert = System.getProperty("user.dir") + "/../../ssl/client.crt"; + clientSslKey = System.getProperty("user.dir") + "/../../ssl/client.key"; + } + } + Assumptions.assumeTrue(clientSslCert != null); MariadbConnectionFactory factory = (MariadbConnectionFactory) ConnectionFactories.get( - "r2dbc:mariadb://root:pwd@localhost:3306/db?socket=ff&allowMultiQueries=true&tlsProtocol=TLSv1" - + ".2&serverSslCert=myCert&clientSslCert=myClientCert&clientSslKey=bla&clientSslPassword=bla2&allowPipelining=true&useServerPrepStmts" + "r2dbc:mariadb://root:pwd@localhost:3306/db?socket=ff&allowMultiQueries=true" + + "&tlsProtocol=TLSv1.2" + + "&serverSslCert=" + + serverSslCert + + "&clientSslCert=" + + clientSslCert + + "&clientSslKey=" + + clientSslKey + + "&allowPipelining=true&useServerPrepStmts" + "=true&prepareCacheSize=2560&connectTimeout=PT10S&socketTimeout=PT1H&tcpKeepAlive=true" - + "&tcpAbortiveClose=true&sslMode=ENABLE_TRUST" + + "&tcpAbortiveClose=true&sslMode=TRUST" + "&connectionAttributes" + "=test=2," + "h=4&pamOtherPwd=p%40ssword,pwd"); Assertions.assertTrue(factory.toString().contains("socket='ff'")); Assertions.assertTrue(factory.toString().contains("allowMultiQueries=true")); Assertions.assertTrue(factory.toString().contains("tlsProtocol=[TLSv1.2]")); - Assertions.assertTrue(factory.toString().contains("serverSslCert=myCert")); - Assertions.assertTrue(factory.toString().contains("clientSslCert=myClientCert")); + Assertions.assertTrue(factory.toString().contains("serverSslCert=" + serverSslCert)); + Assertions.assertTrue(factory.toString().contains("clientSslCert=" + clientSslCert)); Assertions.assertTrue(factory.toString().contains("allowPipelining=true")); Assertions.assertTrue(factory.toString().contains("useServerPrepStmts=true")); Assertions.assertTrue(factory.toString().contains("prepareCacheSize=2560")); @@ -101,7 +126,6 @@ void checkOptions() { Assertions.assertTrue(factory.toString().contains("socketTimeout=PT1H")); Assertions.assertTrue(factory.toString().contains("tcpKeepAlive=true")); Assertions.assertTrue(factory.toString().contains("tcpAbortiveClose=true")); - Assertions.assertTrue(factory.toString().contains("clientSslKey=bla")); } @Test diff --git a/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java b/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java index 2429a845..e0dbc7e9 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java @@ -53,12 +53,12 @@ public static void before2() { : Integer.valueOf(System.getenv("TEST_MAXSCALE_TLS_PORT")); // try default if not present if (serverSslCert == null) { - File sslDir = new File(System.getProperty("user.dir") + "/../ssl"); + File sslDir = new File(System.getProperty("user.dir") + "/../../ssl"); if (sslDir.exists() && sslDir.isDirectory()) { - serverSslCert = System.getProperty("user.dir") + "/../ssl/server.crt"; - clientSslCert = System.getProperty("user.dir") + "/../ssl/client.crt"; - clientSslKey = System.getProperty("user.dir") + "/../ssl/client.key"; + serverSslCert = System.getProperty("user.dir") + "/../../ssl/server.crt"; + clientSslCert = System.getProperty("user.dir") + "/../../ssl/client.crt"; + clientSslKey = System.getProperty("user.dir") + "/../../ssl/client.key"; } } @@ -318,9 +318,7 @@ void fullValidation() throws Exception { @Test void fullMutualWithoutClientCerts() throws Exception { Assumptions.assumeTrue( - System.getenv("TRAVIS") != null - && !"maxscale".equals(System.getenv("srv")) - && !"skysql-ha".equals(System.getenv("srv"))); + !"maxscale".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv"))); Assumptions.assumeTrue(haveSsl(sharedConn)); Assumptions.assumeTrue(serverSslCert != null && clientSslCert != null & clientSslKey != null); MariadbConnectionConfiguration conf = diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java index d3a5bcb8..47f3b790 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java @@ -156,19 +156,19 @@ private void booleanValue(MariadbConnection connection) { .verify(); connection - .createStatement("SELECT t1 FROM DateTable WHERE 1 = ? LIMIT 1") - .bind(0, 1) - .execute() - .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, BaseTest.class)))) - .as(StepVerifier::create) - .expectErrorMatches( - throwable -> - throwable instanceof R2dbcTransientResourceException - && throwable - .getMessage() - .equals("No decoder for type org.mariadb.r2dbc.BaseTest and column type DATE")) - .verify(); - + .createStatement("SELECT t1 FROM DateTable WHERE 1 = ? LIMIT 1") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, BaseTest.class)))) + .as(StepVerifier::create) + .expectErrorMatches( + throwable -> + throwable instanceof R2dbcTransientResourceException + && throwable + .getMessage() + .equals( + "No decoder for type org.mariadb.r2dbc.BaseTest and column type DATE")) + .verify(); } @Test diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java index 80191b90..45851f1e 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java @@ -79,18 +79,18 @@ private void defaultValue(MariadbConnection connection) { Optional.empty()) .verifyComplete(); connection - .createStatement("SELECT t2 FROM TimeParseTest WHERE 1 = ?") - .bind(0, 1) - .execute() - .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0)))) - .as(StepVerifier::create) - .expectNext( - Optional.of(Duration.parse("PT-10H-1M-2.01234S")), - Optional.of(Duration.parse("PT-10.123S")), - Optional.of(Duration.parse("PT-8M")), - Optional.of(Duration.parse("PT-22S")), - Optional.empty()) - .verifyComplete(); + .createStatement("SELECT t2 FROM TimeParseTest WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0)))) + .as(StepVerifier::create) + .expectNext( + Optional.of(Duration.parse("PT-10H-1M-2.01234S")), + Optional.of(Duration.parse("PT-10.123S")), + Optional.of(Duration.parse("PT-8M")), + Optional.of(Duration.parse("PT-22S")), + Optional.empty()) + .verifyComplete(); } @Test diff --git a/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java b/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java index 4cd1270d..abf72cca 100644 --- a/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java +++ b/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java @@ -5,8 +5,8 @@ public class InitFinalClass { - @Test - public void init() throws Exception { - Codecs codecs = new Codecs(); - } + @Test + public void init() throws Exception { + Codecs codecs = new Codecs(); + } } From 22cd77c810f0569baee7231724b93d0e18ccdf5f Mon Sep 17 00:00:00 2001 From: kolzeq Date: Thu, 1 Jul 2021 17:03:23 +0200 Subject: [PATCH 16/20] [R2DBC-30] Native Password plugin error --- .../message/client/NativePasswordPacket.java | 7 +++- .../authentication/Ed25519PluginTest.java | 37 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/mariadb/r2dbc/message/client/NativePasswordPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/NativePasswordPacket.java index ede98a38..b2e6643e 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/NativePasswordPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/NativePasswordPacket.java @@ -33,11 +33,14 @@ public final class NativePasswordPacket implements ClientMessage { public NativePasswordPacket(Sequencer sequencer, CharSequence password, byte[] seed) { this.sequencer = sequencer; this.password = password; - this.seed = seed; + byte[] truncatedSeed = new byte[seed.length - 1]; + System.arraycopy(seed, 0, truncatedSeed, 0, seed.length - 1); + + this.seed = truncatedSeed; } public static byte[] encrypt(CharSequence authenticationData, byte[] seed) { - if (authenticationData == null || authenticationData.toString().isEmpty()) { + if (authenticationData == null) { return new byte[0]; } diff --git a/src/test/java/org/mariadb/r2dbc/integration/authentication/Ed25519PluginTest.java b/src/test/java/org/mariadb/r2dbc/integration/authentication/Ed25519PluginTest.java index 3f8d0107..5d7906aa 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/authentication/Ed25519PluginTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/authentication/Ed25519PluginTest.java @@ -95,4 +95,41 @@ public void verificationEd25519AuthPlugin() throws Throwable { MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); connection.close(); } + + + @Test + public void multiAuthPlugin() throws Throwable { + Assumptions.assumeTrue( + !"maxscale".equals(System.getenv("srv")) + && !"skysql".equals(System.getenv("srv")) + && !"skysql-ha".equals(System.getenv("srv"))); + Assumptions.assumeTrue(isMariaDBServer() && minVersion(10, 4, 2)); + + sharedConn.createStatement("drop user IF EXISTS mysqltest1").execute().blockLast(); + sharedConn.createStatement( + "CREATE USER mysqltest1 IDENTIFIED " + + "VIA ed25519 as password('!Passw0rd3') " + + " OR mysql_native_password as password('!Passw0rd3Works')").execute().blockLast(); + + sharedConn.createStatement("GRANT SELECT on *.* to mysqltest1").execute().blockLast(); + MariadbConnectionConfiguration conf = + TestConfiguration.defaultBuilder + .clone() + .username("mysqltest1") + .password("!Passw0rd3") + .build(); + MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); + connection.close().block(); + + conf = + TestConfiguration.defaultBuilder + .clone() + .username("mysqltest1") + .password("!Passw0rd3Works") + .build(); + connection = new MariadbConnectionFactory(conf).create().block(); + connection.close().block(); + sharedConn.createStatement("drop user mysqltest1@'%'").execute().blockLast(); + } + } From 808c48d0bd2abf3b907ea76807ce56285748c8d7 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Thu, 1 Jul 2021 17:11:01 +0200 Subject: [PATCH 17/20] [R2DBC-31] negative Duration value wrong encoding --- .../r2dbc/codec/list/DurationCodec.java | 138 ++++--- .../parameter/TimeParameterTest.java | 368 +++++++++--------- 2 files changed, 276 insertions(+), 230 deletions(-) diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/DurationCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/DurationCodec.java index 2f1c81e9..df1f2f20 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/DurationCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/DurationCodec.java @@ -30,13 +30,13 @@ public class DurationCodec implements Codec { public static final DurationCodec INSTANCE = new DurationCodec(); private static final EnumSet COMPATIBLE_TYPES = - EnumSet.of( - DataType.TIME, - DataType.DATETIME, - DataType.TIMESTAMP, - DataType.VARSTRING, - DataType.VARCHAR, - DataType.STRING); + EnumSet.of( + DataType.TIME, + DataType.DATETIME, + DataType.TIMESTAMP, + DataType.VARSTRING, + DataType.VARCHAR, + DataType.STRING); public boolean canDecode(ColumnDefinitionPacket column, Class type) { return COMPATIBLE_TYPES.contains(column.getType()) && type.isAssignableFrom(Duration.class); @@ -48,32 +48,32 @@ public boolean canEncode(Class value) { @Override public Duration decodeText( - ByteBuf buf, int length, ColumnDefinitionPacket column, Class type) { + ByteBuf buf, int length, ColumnDefinitionPacket column, Class type) { int[] parts; switch (column.getType()) { case TIMESTAMP: case DATETIME: parts = - LocalDateTimeCodec.parseTimestamp( - buf.readCharSequence(length, StandardCharsets.US_ASCII).toString()); + LocalDateTimeCodec.parseTimestamp( + buf.readCharSequence(length, StandardCharsets.US_ASCII).toString()); if (parts == null) return null; return Duration.ZERO - .plusDays(parts[2] - 1) - .plusHours(parts[3]) - .plusMinutes(parts[4]) - .plusSeconds(parts[5]) - .plusNanos(parts[6]); + .plusDays(parts[2] - 1) + .plusHours(parts[3]) + .plusMinutes(parts[4]) + .plusSeconds(parts[5]) + .plusNanos(parts[6]); default: // TIME, VARCHAR, VARSTRING, STRING: parts = LocalTimeCodec.parseTime(buf, length, column); Duration d = - Duration.ZERO - .plusHours(parts[1]) - .plusMinutes(parts[2]) - .plusSeconds(parts[3]) - .plusNanos(parts[4]); + Duration.ZERO + .plusHours(parts[1]) + .plusMinutes(parts[2]) + .plusSeconds(parts[3]) + .plusNanos(parts[4]); if (parts[0] == 1) return d.negated(); return d; } @@ -81,7 +81,7 @@ public Duration decodeText( @Override public Duration decodeBinary( - ByteBuf buf, int length, ColumnDefinitionPacket column, Class type) { + ByteBuf buf, int length, ColumnDefinitionPacket column, Class type) { long days = 0; int hours = 0; @@ -104,12 +104,12 @@ public Duration decodeBinary( } Duration duration = - Duration.ZERO - .plusDays(days) - .plusHours(hours) - .plusMinutes(minutes) - .plusSeconds(seconds) - .plusNanos(microseconds * 1000); + Duration.ZERO + .plusDays(days) + .plusHours(hours) + .plusMinutes(minutes) + .plusSeconds(seconds) + .plusNanos(microseconds * 1000); if (negate) return duration.negated(); return duration; @@ -129,21 +129,21 @@ public Duration decodeBinary( } } return Duration.ZERO - .plusDays(days - 1) - .plusHours(hours) - .plusMinutes(minutes) - .plusSeconds(seconds) - .plusNanos(microseconds * 1000); + .plusDays(days - 1) + .plusHours(hours) + .plusMinutes(minutes) + .plusSeconds(seconds) + .plusNanos(microseconds * 1000); default: // VARCHAR, VARSTRING, STRING: int[] parts = LocalTimeCodec.parseTime(buf, length, column); Duration d = - Duration.ZERO - .plusHours(parts[1]) - .plusMinutes(parts[2]) - .plusSeconds(parts[3]) - .plusNanos(parts[4]); + Duration.ZERO + .plusHours(parts[1]) + .plusMinutes(parts[2]) + .plusSeconds(parts[3]) + .plusNanos(parts[4]); if (parts[0] == 1) return d.negated(); return d; } @@ -152,38 +152,66 @@ public Duration decodeBinary( @Override public void encodeText(ByteBuf buf, Context context, Duration val) { long s = val.getSeconds(); + boolean negate = false; + if (s < 0) { + negate = true; + s = -s; + } + long microSecond = val.getNano() / 1000; buf.writeByte('\''); if (microSecond != 0) { - buf.writeCharSequence( - String.format("%d:%02d:%02d.%06d", s / 3600, (s % 3600) / 60, (s % 60), microSecond), - StandardCharsets.US_ASCII); + if (negate) { + s = s - 1; + buf.writeCharSequence( + String.format("-%d:%02d:%02d.%06d", s / 3600, (s % 3600) / 60, (s % 60), 1000000 - microSecond), + StandardCharsets.US_ASCII); + + } else { + buf.writeCharSequence( + String.format("%d:%02d:%02d.%06d", s / 3600, (s % 3600) / 60, (s % 60), microSecond), + StandardCharsets.US_ASCII); + + } } else { + String format = negate ? "-%d:%02d:%02d" : "%d:%02d:%02d"; buf.writeCharSequence( - String.format("%d:%02d:%02d", s / 3600, (s % 3600) / 60, (s % 60)), - StandardCharsets.US_ASCII); + String.format(format, s / 3600, (s % 3600) / 60, (s % 60)), + StandardCharsets.US_ASCII); } buf.writeByte('\''); } @Override public void encodeBinary(ByteBuf buf, Context context, Duration value) { - int nano = value.getNano(); - if (nano > 0) { - buf.writeByte((byte) 12); - buf.writeByte((byte) (value.isNegative() ? 1 : 0)); - buf.writeIntLE((int) value.toDays()); - buf.writeByte((byte) (value.toHours() - 24 * value.toDays())); - buf.writeByte((byte) (value.toMinutes() - 60 * value.toHours())); - buf.writeByte((byte) (value.getSeconds() - 60 * value.toMinutes())); - buf.writeIntLE(nano / 1000); + long microSecond = value.getNano() / 1000; + long s = Math.abs(value.getSeconds()); + if (microSecond > 0) { + if (value.isNegative()) { + s = s - 1; + buf.writeByte((byte) 12); + buf.writeByte((byte) (value.isNegative() ? 1 : 0)); + buf.writeIntLE((int) (s / (24 * 3600))); + buf.writeByte((int) (s % (24 * 3600)) / 3600); + buf.writeByte((int) (s % 3600) / 60); + buf.writeByte((int) (s % 60)); + buf.writeIntLE((int) (1000000 - microSecond)); + } else { + buf.writeByte((byte) 12); + buf.writeByte((byte) (value.isNegative() ? 1 : 0)); + buf.writeIntLE((int) (s / (24 * 3600))); + buf.writeByte((int) (s % (24 * 3600)) / 3600); + buf.writeByte((int) (s % 3600) / 60); + buf.writeByte((int) (s % 60)); + buf.writeIntLE((int)microSecond); + } } else { buf.writeByte((byte) 8); buf.writeByte((byte) (value.isNegative() ? 1 : 0)); - buf.writeIntLE((int) value.toDays()); - buf.writeByte((byte) (value.toHours() - 24 * value.toDays())); - buf.writeByte((byte) (value.toMinutes() - 60 * value.toHours())); - buf.writeByte((byte) (value.getSeconds() - 60 * value.toMinutes())); + buf.writeIntLE((int) (s / (24 * 3600))); + buf.writeByte((int) (s % (24 * 3600)) / 3600); + buf.writeByte((int) (s % 3600) / 60); + buf.writeByte((int) (s % 60)); } } diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeParameterTest.java index 5a661d87..075c1543 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeParameterTest.java @@ -38,9 +38,9 @@ public class TimeParameterTest extends BaseConnectionTest { @BeforeAll public static void before2() { sharedConn - .createStatement("CREATE TABLE TimeParam (t1 TIME(6), t2 TIME(6), t3 TIME(6))") - .execute() - .blockLast(); + .createStatement("CREATE TABLE TimeParam (t1 TIME(6), t2 TIME(6), t3 TIME(6))") + .execute() + .blockLast(); } @AfterAll @@ -65,12 +65,12 @@ void nullValuePrepare() { private void nullValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bindNull(0, LocalTime.class) - .bindNull(1, LocalTime.class) - .bindNull(2, LocalTime.class) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bindNull(0, LocalTime.class) + .bindNull(1, LocalTime.class) + .bindNull(2, LocalTime.class) + .execute() + .blockLast(); validate(Optional.empty(), Optional.empty(), Optional.empty()); } @@ -86,23 +86,23 @@ void bigIntValuePrepare() { private void bigIntValue(MariadbConnection connection) { Flux f = - connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, BigInteger.ONE) - .bind(1, new BigInteger("9223372036854775807")) - .bind(2, new BigInteger("-9")) - .execute(); + connection + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, BigInteger.ONE) + .bind(1, new BigInteger("9223372036854775807")) + .bind(2, new BigInteger("-9")) + .execute(); if ((isMariaDBServer() && !minVersion(10, 2, 0)) - || (!isMariaDBServer() && !minVersion(5, 7, 0))) { + || (!isMariaDBServer() && !minVersion(5, 7, 0))) { f.blockLast(); } else { f.flatMap(r -> r.getRowsUpdated()) - .as(StepVerifier::create) - .expectErrorMatches( - throwable -> - throwable instanceof R2dbcBadGrammarException - && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) - .verify(); + .as(StepVerifier::create) + .expectErrorMatches( + throwable -> + throwable instanceof R2dbcBadGrammarException + && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) + .verify(); } } @@ -118,23 +118,23 @@ void stringValuePrepare() { private void stringValue(MariadbConnection connection) { Flux f = - connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, "1") - .bind(1, "9223372036854775807") - .bind(2, "-9") - .execute(); + connection + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, "1") + .bind(1, "9223372036854775807") + .bind(2, "-9") + .execute(); if ((isMariaDBServer() && !minVersion(10, 2, 0)) - || (!isMariaDBServer() && !minVersion(5, 7, 0))) { + || (!isMariaDBServer() && !minVersion(5, 7, 0))) { f.blockLast(); } else { f.flatMap(r -> r.getRowsUpdated()) - .as(StepVerifier::create) - .expectErrorMatches( - throwable -> - throwable instanceof R2dbcBadGrammarException - && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) - .verify(); + .as(StepVerifier::create) + .expectErrorMatches( + throwable -> + throwable instanceof R2dbcBadGrammarException + && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) + .verify(); } } @@ -150,23 +150,23 @@ void decimalValuePrepare() { private void decimalValue(MariadbConnection connection) { Flux f = - connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, BigDecimal.ONE) - .bind(1, new BigDecimal("9223372036854775807")) - .bind(2, new BigDecimal("-9")) - .execute(); + connection + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, BigDecimal.ONE) + .bind(1, new BigDecimal("9223372036854775807")) + .bind(2, new BigDecimal("-9")) + .execute(); if ((isMariaDBServer() && !minVersion(10, 2, 0)) - || (!isMariaDBServer() && !minVersion(5, 7, 0))) { + || (!isMariaDBServer() && !minVersion(5, 7, 0))) { f.blockLast(); } else { f.flatMap(r -> r.getRowsUpdated()) - .as(StepVerifier::create) - .expectErrorMatches( - throwable -> - throwable instanceof R2dbcBadGrammarException - && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) - .verify(); + .as(StepVerifier::create) + .expectErrorMatches( + throwable -> + throwable instanceof R2dbcBadGrammarException + && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) + .verify(); } } @@ -182,16 +182,16 @@ void intValuePrepare() { private void intValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, 1) - .bind(1, -1) - .bind(2, 0) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, 1) + .bind(1, -1) + .bind(2, 0) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT1S")), - Optional.of(Duration.parse("PT-1S")), - Optional.of(Duration.parse("PT0M"))); + Optional.of(Duration.parse("PT1S")), + Optional.of(Duration.parse("PT-1S")), + Optional.of(Duration.parse("PT0M"))); } @Test @@ -206,16 +206,16 @@ void byteValuePrepare() { private void byteValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, (byte) 127) - .bind(1, (byte) -128) - .bind(2, (byte) 0) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, (byte) 127) + .bind(1, (byte) -128) + .bind(2, (byte) 0) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT1M27S")), - Optional.of(Duration.parse("PT-1M-28S")), - Optional.of(Duration.parse("PT0M"))); + Optional.of(Duration.parse("PT1M27S")), + Optional.of(Duration.parse("PT-1M-28S")), + Optional.of(Duration.parse("PT0M"))); } @Test @@ -230,16 +230,16 @@ void floatValuePrepare() { private void floatValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, 127f) - .bind(1, -128f) - .bind(2, 0f) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, 127f) + .bind(1, -128f) + .bind(2, 0f) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT1M27S")), - Optional.of(Duration.parse("PT-1M-28S")), - Optional.of(Duration.parse("PT0M"))); + Optional.of(Duration.parse("PT1M27S")), + Optional.of(Duration.parse("PT-1M-28S")), + Optional.of(Duration.parse("PT0M"))); } @Test @@ -254,16 +254,16 @@ void doubleValuePrepare() { private void doubleValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, 127d) - .bind(1, 128d) - .bind(2, 0d) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, 127d) + .bind(1, 128d) + .bind(2, 0d) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT1M27S")), - Optional.of(Duration.parse("PT1M28S")), - Optional.of(Duration.parse("PT0M"))); + Optional.of(Duration.parse("PT1M27S")), + Optional.of(Duration.parse("PT1M28S")), + Optional.of(Duration.parse("PT0M"))); } @Test @@ -278,16 +278,16 @@ void shortValuePrepare() { private void shortValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, Short.valueOf("1")) - .bind(1, Short.valueOf("-1")) - .bind(2, Short.valueOf("0")) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, Short.valueOf("1")) + .bind(1, Short.valueOf("-1")) + .bind(2, Short.valueOf("0")) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT1S")), - Optional.of(Duration.parse("PT-1S")), - Optional.of(Duration.parse("PT0M"))); + Optional.of(Duration.parse("PT1S")), + Optional.of(Duration.parse("PT-1S")), + Optional.of(Duration.parse("PT0M"))); } @Test @@ -302,16 +302,16 @@ void longValuePrepare() { private void longValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, Long.valueOf("1")) - .bind(1, Long.valueOf("-1")) - .bind(2, Long.valueOf("0")) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, Long.valueOf("1")) + .bind(1, Long.valueOf("-1")) + .bind(2, Long.valueOf("0")) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT1S")), - Optional.of(Duration.parse("PT-1S")), - Optional.of(Duration.parse("PT0M"))); + Optional.of(Duration.parse("PT1S")), + Optional.of(Duration.parse("PT-1S")), + Optional.of(Duration.parse("PT0M"))); } @Test @@ -326,16 +326,16 @@ void localDateTimeValuePrepare() { private void localDateTimeValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, LocalDateTime.parse("2010-01-12T05:08:09.0014")) - .bind(1, LocalDateTime.parse("2018-12-15T05:08:10.123456")) - .bind(2, LocalDateTime.parse("2025-05-12T05:08:11.123")) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, LocalDateTime.parse("2010-01-12T05:08:09.0014")) + .bind(1, LocalDateTime.parse("2018-12-15T05:08:10.123456")) + .bind(2, LocalDateTime.parse("2025-05-12T05:08:11.123")) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT5H8M9.0014S")), - Optional.of(Duration.parse("PT5H8M10.123456S")), - Optional.of(Duration.parse("PT5H8M11.123S"))); + Optional.of(Duration.parse("PT5H8M9.0014S")), + Optional.of(Duration.parse("PT5H8M10.123456S")), + Optional.of(Duration.parse("PT5H8M11.123S"))); } @Test @@ -346,69 +346,87 @@ void localDateValue() { @Test void localDateValuePrepare() { sharedConnPrepare - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, LocalDate.parse("2010-01-12")) - .bind(1, LocalDate.parse("2018-12-15")) - .bind(2, LocalDate.parse("2025-05-12")) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, LocalDate.parse("2010-01-12")) + .bind(1, LocalDate.parse("2018-12-15")) + .bind(2, LocalDate.parse("2025-05-12")) + .execute() + .blockLast(); sharedConn - .createStatement("SELECT * FROM TimeParam") - .execute() - .flatMap( - r -> - r.map( - (row, metadata) -> - Flux.just( - row.get(0, String.class), - row.get(1, String.class), - row.get(2, String.class)))) - .blockLast() - .as(StepVerifier::create) - .expectNext("00:00:00.000000", "00:00:00.000000", "00:00:00.000000") - .verifyComplete(); + .createStatement("SELECT * FROM TimeParam") + .execute() + .flatMap( + r -> + r.map( + (row, metadata) -> + Flux.just( + row.get(0, String.class), + row.get(1, String.class), + row.get(2, String.class)))) + .blockLast() + .as(StepVerifier::create) + .expectNext("00:00:00.000000", "00:00:00.000000", "00:00:00.000000") + .verifyComplete(); } private void localDateValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, LocalDate.parse("2010-01-12")) - .bind(1, LocalDate.parse("2018-12-15")) - .bind(2, LocalDate.parse("2025-05-12")) - .execute() - .flatMap(r -> r.getRowsUpdated()) - .as(StepVerifier::create) - .expectErrorMatches( - throwable -> - throwable instanceof R2dbcBadGrammarException - && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) - .verify(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, LocalDate.parse("2010-01-12")) + .bind(1, LocalDate.parse("2018-12-15")) + .bind(2, LocalDate.parse("2025-05-12")) + .execute() + .flatMap(r -> r.getRowsUpdated()) + .as(StepVerifier::create) + .expectErrorMatches( + throwable -> + throwable instanceof R2dbcBadGrammarException + && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) + .verify(); } @Test void durationValue() { durationValue(sharedConn); + durationValue2(sharedConn); } @Test void durationValuePrepare() { durationValue(sharedConnPrepare); + durationValue2(sharedConnPrepare); } private void durationValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, Duration.parse("PT5H8M9.0014S")) - .bind(1, Duration.parse("PT5H8M10S")) - .bind(2, Duration.parse("PT5H8M11.123S")) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, Duration.parse("PT5H8M9.0014S")) + .bind(1, Duration.parse("PT-5H8M10S")) + .bind(2, Duration.parse("PT5H8M11.123S")) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT5H8M9.0014S")), - Optional.of(Duration.parse("PT5H8M10S")), - Optional.of(Duration.parse("PT5H8M11.123S"))); + Optional.of(Duration.parse("PT5H8M9.0014S")), + Optional.of(Duration.parse("PT-5H8M10S")), + Optional.of(Duration.parse("PT5H8M11.123S"))); } + private void durationValue2(MariadbConnection connection) { + connection + .createStatement("TRUNCATE TABLE TimeParam").execute().blockLast(); + + connection + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, Duration.parse("PT0S")) + .bind(1, Duration.parse("PT-1.123S")) + .bind(2, Duration.parse("PT-5H8M11.123S")) + .execute() + .blockLast(); + validate( + Optional.of(Duration.parse("PT0S")), + Optional.of(Duration.parse("PT-1.123S")), + Optional.of(Duration.parse("PT-5H8M11.123S"))); + } @Test void localTimeValue() { localTimeValue(sharedConn); @@ -421,33 +439,33 @@ void localTimeValuePrepare() { private void localTimeValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, LocalTime.parse("05:08:09.0014")) - .bind(1, LocalTime.parse("05:08:10")) - .bind(2, LocalTime.parse("05:08:11.123")) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, LocalTime.parse("05:08:09.0014")) + .bind(1, LocalTime.parse("05:08:10")) + .bind(2, LocalTime.parse("05:08:11.123")) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT5H8M9.0014S")), - Optional.of(Duration.parse("PT5H8M10S")), - Optional.of(Duration.parse("PT5H8M11.123S"))); + Optional.of(Duration.parse("PT5H8M9.0014S")), + Optional.of(Duration.parse("PT5H8M10S")), + Optional.of(Duration.parse("PT5H8M11.123S"))); } private void validate(Optional t1, Optional t2, Optional t3) { sharedConn - .createStatement("SELECT * FROM TimeParam") - .execute() - .flatMap( - r -> - r.map( - (row, metadata) -> - Flux.just( - Optional.ofNullable((Duration) row.get(0)), - Optional.ofNullable(row.get(1)), - Optional.ofNullable(row.get(2))))) - .blockLast() - .as(StepVerifier::create) - .expectNext(t1, t2, t3) - .verifyComplete(); + .createStatement("SELECT * FROM TimeParam") + .execute() + .flatMap( + r -> + r.map( + (row, metadata) -> + Flux.just( + Optional.ofNullable((Duration) row.get(0)), + Optional.ofNullable(row.get(1)), + Optional.ofNullable(row.get(2))))) + .blockLast() + .as(StepVerifier::create) + .expectNext(t1, t2, t3) + .verifyComplete(); } } From 1a5bec3cd746314c7cdac54ead160347cbcef0cd Mon Sep 17 00:00:00 2001 From: kolzeq Date: Thu, 1 Jul 2021 17:19:15 +0200 Subject: [PATCH 18/20] [R2DBC-29] coverage addition * java 8 test addition --- .travis.yml | 12 +- codecov.yml | 4 +- pom.xml | 12 +- .../org/mariadb/r2dbc/MariadbConnection.java | 10 +- .../r2dbc/MariadbConnectionConfiguration.java | 4 +- .../r2dbc/MariadbConnectionFactory.java | 3 - .../java/org/mariadb/r2dbc/MariadbResult.java | 6 +- ...iadbServerParameterizedQueryStatement.java | 46 +- .../mariadb/r2dbc/api/MariadbConnection.java | 2 + .../java/org/mariadb/r2dbc/client/Client.java | 2 + .../org/mariadb/r2dbc/client/ClientBase.java | 14 +- .../org/mariadb/r2dbc/client/Context.java | 16 - .../mariadb/r2dbc/client/DecoderState.java | 69 +-- .../r2dbc/client/DecoderStateInterface.java | 6 +- .../r2dbc/client/MariadbPacketDecoder.java | 15 +- .../mariadb/r2dbc/codec/BinaryRowDecoder.java | 197 +++---- .../r2dbc/codec/list/DurationCodec.java | 89 ++- .../r2dbc/codec/list/LocalDateCodec.java | 15 +- .../r2dbc/codec/list/LocalDateTimeCodec.java | 2 +- .../r2dbc/codec/list/LocalTimeCodec.java | 3 +- .../mariadb/r2dbc/codec/list/StringCodec.java | 9 +- .../message/client/Ed25519PasswordPacket.java | 2 +- .../message/flow/AuthenticationFlow.java | 2 +- .../message/flow/CachingSha2PasswordFlow.java | 2 +- .../flow/Sha256PasswordPluginFlow.java | 65 +-- .../r2dbc/message/server/OkPacket.java | 2 +- .../r2dbc/message/server/SkipPacket.java | 4 + .../org/mariadb/r2dbc/util/BufferUtils.java | 15 +- .../r2dbc/util/ClientPrepareResult.java | 40 +- .../r2dbc/util/DefaultHostnameVerifier.java | 51 +- .../org/mariadb/r2dbc/util/PidFactory.java | 2 +- .../org/mariadb/r2dbc/util/SslConfig.java | 4 +- .../java/org/mariadb/r2dbc/util/Utility.java | 40 -- .../r2dbc/integration/ConfigurationTest.java | 8 + .../integration/ConnectionMetadataTest.java | 20 +- .../r2dbc/integration/ConnectionTest.java | 216 +++++-- .../integration/PrepareResultSetTest.java | 87 ++- .../r2dbc/integration/ResultsetTest.java | 91 +++ .../r2dbc/integration/RowMetadataTest.java | 7 +- .../mariadb/r2dbc/integration/TlsTest.java | 35 +- .../authentication/Ed25519PluginTest.java | 58 +- .../authentication/Sha256PluginTest.java | 120 +++- .../codec/BigIntegerParseTest.java | 11 + .../r2dbc/integration/codec/BitParseTest.java | 11 + .../integration/codec/BlobParseTest.java | 11 + .../integration/codec/DateParseTest.java | 11 + .../integration/codec/DateTimeParseTest.java | 48 +- .../integration/codec/DecimalParseTest.java | 11 + .../integration/codec/DoubleParseTest.java | 11 + .../integration/codec/FloatParseTest.java | 11 + .../r2dbc/integration/codec/IntParseTest.java | 11 + .../integration/codec/MediumIntParseTest.java | 11 + .../integration/codec/ShortParseTest.java | 11 + .../integration/codec/StringParseTest.java | 28 + .../integration/codec/TimeParseTest.java | 17 +- .../integration/codec/TimestampParseTest.java | 11 + .../integration/codec/TinyIntParseTest.java | 11 + .../integration/codec/YearParseTest.java | 11 + .../parameter/TimeParameterTest.java | 372 ++++++------ .../mariadb/r2dbc/unit/InitFinalClass.java | 5 + .../unit/client/HostnameVerifierTest.java | 534 ++++++++++++++++++ .../r2dbc/unit/util/BufferUtilsTest.java | 248 ++++++++ .../unit/util/ClientPrepareResultTest.java | 139 ++++- .../util/DefaultHostnameVerifierTest.java | 38 +- .../unit/util/ServerPrepareResultTest.java | 20 + 65 files changed, 2215 insertions(+), 784 deletions(-) delete mode 100644 src/main/java/org/mariadb/r2dbc/util/Utility.java create mode 100644 src/test/java/org/mariadb/r2dbc/unit/client/HostnameVerifierTest.java create mode 100644 src/test/java/org/mariadb/r2dbc/unit/util/BufferUtilsTest.java create mode 100644 src/test/java/org/mariadb/r2dbc/unit/util/ServerPrepareResultTest.java diff --git a/.travis.yml b/.travis.yml index a214ab31..7fdeb072 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,11 @@ jdk: openjdk11 addons: hosts: - mariadb.example.com + - mariadb2.example.com before_install: - git clone https://github.com/mariadb-corporation/connector-test-machine.git - +env: packet=40 install: - |- case $TRAVIS_OS_NAME in @@ -19,7 +20,7 @@ install: connector-test-machine/launch.bat -t "$srv" -v "$v" -d testr2 ;; linux) - source connector-test-machine/launch.sh -t "$srv" -v "$v" -d testr2 -n 0 -l "$local" + source connector-test-machine/launch.sh -t "$srv" -v "$v" -d testr2 -n 0 -l "$local" -p "$packet" ;; esac @@ -31,11 +32,14 @@ jobs: - env: srv=mariadb v=10.5 os: windows language: shell - - env: srv=mariadb v=10.2 local=1 + - env: srv=mariadb v=10.2 local=1 packet=20 dist: bionic - env: srv=mariadb v=10.3 local=1 - env: srv=mariadb v=10.4 local=1 - env: srv=mariadb v=10.5 local=1 + - env: srv=mariadb v=10.5 local=1 + jdk: openjdk8 + dist: bionic - env: srv=mariadb v=10.6 local=1 - env: srv=mariadb v=10.5 NO_BACKSLASH_ESCAPES=true - env: srv=mariadb v=10.6 BENCH=1 @@ -61,5 +65,5 @@ script: - if [ -z "$BENCH" ] ; then MAVEN_SKIP_RC=true MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512m" mvn test -P continuous-integration -DjobId=${TRAVIS_JOB_ID}; fi -after_success: +after_script: - bash <(curl -s https://codecov.io/bash) diff --git a/codecov.yml b/codecov.yml index e3c1bfda..218d0c37 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,3 +1,5 @@ comment: off +codecov: + token: 4e71e90c-99a8-40b8-b69c-181457ec4861 ignore: - - "src/main/java/org/mariadb/r2dbc/authentication/ed25519" # ignore folders and all its contents + - "src/main/java/org/mariadb/r2dbc/authentication/ed25519/**/*" diff --git a/pom.xml b/pom.xml index 036d873b..e748b6af 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 4.0.0 org.mariadb r2dbc-mariadb - 1.0.1 + 1.0.2-SNAPSHOT jar https://github.com/mariadb-corporation/mariadb-connector-r2dbc @@ -276,7 +276,7 @@ com.coveo fmt-maven-plugin - 2.10 + 2.9.1 @@ -319,11 +319,9 @@ jacoco-maven-plugin 0.8.5 - true - - org/mariadb/r2dbc - org/mariadb/r2dbc/** - + + **/ed25519/**/*.class + diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnection.java b/src/main/java/org/mariadb/r2dbc/MariadbConnection.java index b9cce9f1..3128f8b9 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnection.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnection.java @@ -110,6 +110,11 @@ public Mono releaseSavepoint(String name) { return this.client.releaseSavepoint(name); } + @Override + public long getThreadId() { + return this.client.getThreadId(); + } + @Override public Mono rollbackTransaction() { return this.client.rollbackTransaction(); @@ -136,10 +141,7 @@ public Mono setTransactionIsolationLevel(IsolationLevel isolationLevel) { .sendCommand(new QueryPacket(sql)) .handle(exceptionFactory::handleErrorResponse) .then() - .doOnSuccess( - ignore -> { - this.isolationLevel = newIsolation; - }); + .doOnSuccess(ignore -> this.isolationLevel = newIsolation); } @Override diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java index ca8481e7..f580f621 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java @@ -91,11 +91,11 @@ private MariadbConnectionConfiguration( this.socketTimeout = socketTimeout; this.tcpKeepAlive = tcpKeepAlive == null ? Boolean.FALSE : tcpKeepAlive; this.tcpAbortiveClose = tcpAbortiveClose == null ? Boolean.FALSE : tcpAbortiveClose; - this.database = database; + this.database = database != null && !database.isEmpty() ? database : null; this.host = host; this.connectionAttributes = connectionAttributes; this.sessionVariables = sessionVariables; - this.password = password; + this.password = password != null && !password.toString().isEmpty() ? password : null; this.port = port; this.socket = socket; this.username = username; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactory.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactory.java index 7e2cd83e..722fb03b 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactory.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactory.java @@ -170,9 +170,6 @@ private Mono getIsolationLevel(Client client) { case "READ-UNCOMMITTED": return IsolationLevel.READ_UNCOMMITTED; - case "READ-COMMITTED": - return IsolationLevel.READ_COMMITTED; - case "SERIALIZABLE": return IsolationLevel.SERIALIZABLE; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbResult.java b/src/main/java/org/mariadb/r2dbc/MariadbResult.java index eeca32f0..77a201d9 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbResult.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbResult.java @@ -141,9 +141,9 @@ public Flux map(BiFunction f) { // This is for server that doesn't permit RETURNING: rely on OK_packet LastInsertId // to retrieve the last generated ID. - if (serverMessage instanceof OkPacket - && generatedColumns != null - && !supportReturning) { + if (generatedColumns != null + && !supportReturning + && serverMessage instanceof OkPacket) { String colName = generatedColumns.length > 0 ? generatedColumns[0] : "ID"; metadataList = new ColumnDefinitionPacket[1]; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java index 8479c866..950e5e16 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java @@ -32,6 +32,7 @@ import org.mariadb.r2dbc.message.client.ExecutePacket; import org.mariadb.r2dbc.message.client.PreparePacket; import org.mariadb.r2dbc.message.server.CompletePrepareResult; +import org.mariadb.r2dbc.message.server.ErrorPacket; import org.mariadb.r2dbc.message.server.ServerMessage; import org.mariadb.r2dbc.util.Assert; import org.mariadb.r2dbc.util.ServerPrepareResult; @@ -61,19 +62,17 @@ final class MariadbServerParameterizedQueryStatement implements MariadbStatement @Override public MariadbServerParameterizedQueryStatement add() { // check valid parameters - if (this.parameters != null) { - if (prepareResult.get() != null) { - for (int i = 0; i < prepareResult.get().getNumParams(); i++) { - if (parameters.get(i) == null) { - throw new IllegalArgumentException( - String.format("Parameter at position %s is not set", i)); - } + if (prepareResult.get() != null) { + for (int i = 0; i < prepareResult.get().getNumParams(); i++) { + if (this.parameters == null || parameters.get(i) == null) { + throw new IllegalArgumentException( + String.format("Parameter at position %s is not set", i)); } } - if (batchingParameters == null) batchingParameters = new ArrayList<>(); - batchingParameters.add(parameters); - parameters = null; } + if (batchingParameters == null) batchingParameters = new ArrayList<>(); + batchingParameters.add(parameters); + parameters = null; return this; } @@ -166,10 +165,10 @@ private int getColumn(String name) { } private void validateParameters() { - if (prepareResult.get() != null && this.parameters != null) { + if (prepareResult.get() != null) { // valid parameters for (int i = 0; i < prepareResult.get().getNumParams(); i++) { - if (parameters.get(i) == null) { + if (this.parameters == null || parameters.get(i) == null) { throw new IllegalArgumentException( String.format("Parameter at position %s is not set", i)); } @@ -189,17 +188,15 @@ public Flux execute() { } if (batchingParameters == null) { - validateParameters(); - return executeSingleQuery(sql, parameters, this.generatedColumns); + return executeSingleQuery(sql, this.generatedColumns); } else { // add current set of parameters. see https://github.com/r2dbc/r2dbc-spi/issues/229 - this.add(); - + if (parameters != null) this.add(); // prepare command, if not already done if (prepareResult.get() == null) { prepareResult.set(client.getPrepareCache().get(sql)); if (prepareResult.get() == null) { - sendPrepare(sql).block(); + sendPrepare(sql, ExceptionFactory.withSql(sql)).block(); } } @@ -261,7 +258,7 @@ public MariadbServerParameterizedQueryStatement returnGeneratedValues(String... } private Flux executeSingleQuery( - String sql, Map> parameters, String[] generatedColumns) { + String sql, String[] generatedColumns) { ExceptionFactory factory = ExceptionFactory.withSql(sql); if (prepareResult.get() == null && client.getPrepareCache() != null) { @@ -286,13 +283,14 @@ private Flux executeSingleQuery( sink -> { prepareResult.get().decrementUse(client); sink.complete(); - parameters.clear(); + parameters = null; })); } else { // prepare is closing prepareResult.set(null); } } + if (this.parameters == null) this.parameters = new HashMap<>(); Flux flux; if (configuration.allowPipelining() @@ -301,7 +299,7 @@ private Flux executeSingleQuery( flux = sendPrepareAndExecute(sql, factory, parameters, generatedColumns); } else { flux = - sendPrepare(sql) + sendPrepare(sql, factory) .flatMapMany( prepareResult1 -> { prepareResult.set(prepareResult1); @@ -316,7 +314,7 @@ private Flux executeSingleQuery( prepareResult.get().decrementUse(client); } sink.complete(); - parameters.clear(); + parameters = null; })); } @@ -340,12 +338,16 @@ private Flux sendPrepareAndExecute( client.getConf())); } - private Mono sendPrepare(String sql) { + private Mono sendPrepare(String sql, ExceptionFactory factory) { Flux f = this.client .sendCommand(new PreparePacket(sql), DecoderState.PREPARE_RESPONSE, sql) .handle( (it, sink) -> { + if (it instanceof ErrorPacket) { + sink.error(factory.from((ErrorPacket) it)); + return; + } if (it instanceof CompletePrepareResult) { prepareResult.set(((CompletePrepareResult) it).getPrepare()); sink.next(prepareResult.get()); diff --git a/src/main/java/org/mariadb/r2dbc/api/MariadbConnection.java b/src/main/java/org/mariadb/r2dbc/api/MariadbConnection.java index cf940661..7b522934 100644 --- a/src/main/java/org/mariadb/r2dbc/api/MariadbConnection.java +++ b/src/main/java/org/mariadb/r2dbc/api/MariadbConnection.java @@ -67,4 +67,6 @@ public interface MariadbConnection extends Connection { @Override Mono validate(ValidationDepth depth); + + long getThreadId(); } diff --git a/src/main/java/org/mariadb/r2dbc/client/Client.java b/src/main/java/org/mariadb/r2dbc/client/Client.java index 04a57e00..18b93239 100644 --- a/src/main/java/org/mariadb/r2dbc/client/Client.java +++ b/src/main/java/org/mariadb/r2dbc/client/Client.java @@ -75,4 +75,6 @@ Mono sendSslRequest( Mono releaseSavepoint(String name); Mono createSavepoint(String name); + + long getThreadId(); } diff --git a/src/main/java/org/mariadb/r2dbc/client/ClientBase.java b/src/main/java/org/mariadb/r2dbc/client/ClientBase.java index 7e8ccfea..b17da7e9 100644 --- a/src/main/java/org/mariadb/r2dbc/client/ClientBase.java +++ b/src/main/java/org/mariadb/r2dbc/client/ClientBase.java @@ -123,6 +123,10 @@ private void handleConnectionError(Throwable throwable) { err = new R2dbcNonTransientResourceException("Connection unexpected error", "08000", throwable); logger.error("Connection unexpected error", throwable); + Channel channel = this.connection.channel(); + if (!channel.isOpen()) { + this.connection.dispose(); + } } else { err = new R2dbcNonTransientResourceException("Connection error", "08000", throwable); logger.error("Connection error", throwable); @@ -219,6 +223,9 @@ private Flux execute(Consumer> s) { abstract void executeAutoCommit(FluxSink sink, boolean autoCommit); + public long getThreadId() { + return context.getThreadId(); + } /** * Specific implementation, to avoid executing BEGIN if already in transaction * @@ -337,7 +344,6 @@ public void setContext(InitialHandshakePacket handshake) { new Context( handshake.getServerVersion(), handshake.getThreadId(), - handshake.getSeed(), handshake.getCapabilities(), handshake.getServerStatus(), handshake.isMariaDBServer()); @@ -375,8 +381,12 @@ public boolean isConnected() { private void closedServlet() { if (this.isClosed.compareAndSet(false, true)) { + Channel channel = this.connection.channel(); + if (!channel.isOpen()) { + this.connection.dispose(); + } clearWaitingListWithError( - new R2dbcNonTransientResourceException("Connection unexpectedly closed")); + ExceptionFactory.INSTANCE.createException("Connection unexpectedly closed", "08000", -1)); } else { clearWaitingListWithError(new R2dbcNonTransientResourceException("Connection closed")); diff --git a/src/main/java/org/mariadb/r2dbc/client/Context.java b/src/main/java/org/mariadb/r2dbc/client/Context.java index c55e75e5..cfc27a9f 100644 --- a/src/main/java/org/mariadb/r2dbc/client/Context.java +++ b/src/main/java/org/mariadb/r2dbc/client/Context.java @@ -20,21 +20,17 @@ public class Context { private final long threadId; private final long serverCapabilities; - private byte[] seed; private short serverStatus; - private String database = null; private ServerVersion version; public Context( String serverVersion, long threadId, - byte[] seed, long capabilities, short serverStatus, boolean mariaDBServer) { this.threadId = threadId; - this.seed = seed; this.serverCapabilities = capabilities; this.serverStatus = serverStatus; this.version = new ServerVersion(serverVersion, mariaDBServer); @@ -44,10 +40,6 @@ public long getThreadId() { return threadId; } - public byte[] getSeed() { - return seed; - } - public long getServerCapabilities() { return serverCapabilities; } @@ -60,14 +52,6 @@ public void setServerStatus(short serverStatus) { this.serverStatus = serverStatus; } - public String getDatabase() { - return database; - } - - public void setDatabase(String database) { - this.database = database; - } - public ServerVersion getVersion() { return version; } diff --git a/src/main/java/org/mariadb/r2dbc/client/DecoderState.java b/src/main/java/org/mariadb/r2dbc/client/DecoderState.java index b5527bc1..b96f28f4 100644 --- a/src/main/java/org/mariadb/r2dbc/client/DecoderState.java +++ b/src/main/java/org/mariadb/r2dbc/client/DecoderState.java @@ -37,30 +37,6 @@ public ServerMessage decode( ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { return InitialHandshakePacket.decode(sequencer, body); } - - @Override - public DecoderState next(MariadbPacketDecoder decoder) { - return FAST_AUTH_RESPONSE; - } - }, - - FAST_AUTH_RESPONSE { - public DecoderState decoder(short val, int len, long serverCapabilities) { - switch (val) { - case 0: - return OK_PACKET; - - case 254: // 0xFE - return AUTHENTICATION_SWITCH; - - case 255: // 0xFF - return ERROR; - - default: - throw new IllegalArgumentException( - String.format("Error in protocol: %s is not a supported", val)); - } - } }, OK_PACKET { @@ -82,18 +58,11 @@ public ServerMessage decode( ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { return AuthSwitchPacket.decode(sequencer, body, decoder.getContext()); } - - @Override - public DecoderState next(MariadbPacketDecoder decoder) { - return AUTHENTICATION_SWITCH_RESPONSE; - } }, AUTHENTICATION_SWITCH_RESPONSE { public DecoderState decoder(short val, int len, long serverCapabilities) { switch (val) { - case 0: - return OK_PACKET; case 1: return AUTHENTICATION_MORE_DATA; case 254: // 0xFE @@ -101,8 +70,7 @@ public DecoderState decoder(short val, int len, long serverCapabilities) { case 255: // 0xFF return ERROR; default: - throw new IllegalArgumentException( - String.format("Error in protocol: %s is not a supported", val)); + return OK_PACKET; } } }, @@ -113,11 +81,6 @@ public ServerMessage decode( ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { return AuthMoreDataPacket.decode(sequencer, body, decoder.getContext()); } - - @Override - public DecoderState next(MariadbPacketDecoder decoder) { - return AUTHENTICATION_SWITCH_RESPONSE; - } }, QUERY_RESPONSE { @@ -157,10 +120,6 @@ public DecoderState next(MariadbPacketDecoder decoder) { COLUMN_DEFINITION { - public DecoderState decoder(short val, int len, long serverCapabilities) { - return this; - } - @Override public ServerMessage decode( ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { @@ -182,9 +141,6 @@ public DecoderState next(MariadbPacketDecoder decoder) { }, EOF_INTERMEDIATE_RESPONSE { - public DecoderState decoder(short val, int len, long serverCapabilities) { - return this; - } @Override public ServerMessage decode( @@ -199,9 +155,6 @@ public DecoderState next(MariadbPacketDecoder decoder) { }, EOF_END { - public DecoderState decoder(short val, int len, long serverCapabilities) { - return this; - } @Override public ServerMessage decode( @@ -332,9 +285,6 @@ public DecoderState next(MariadbPacketDecoder decoder) { }, PREPARE_PARAMETER { - public DecoderState decoder(short val, int len, long serverCapabilities) { - return this; - } @Override public ServerMessage decode( @@ -364,10 +314,6 @@ public DecoderState next(MariadbPacketDecoder decoder) { PREPARE_COLUMN { - public DecoderState decoder(short val, int len, long serverCapabilities) { - return this; - } - @Override public ServerMessage decode( ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { @@ -404,10 +350,6 @@ public DecoderState next(MariadbPacketDecoder decoder) { PREPARE_COLUMN_EOF { - public DecoderState decoder(short val, int len, long serverCapabilities) { - return this; - } - @Override public ServerMessage decode( ByteBuf body, Sequencer sequencer, MariadbPacketDecoder decoder, CmdElement element) { @@ -423,9 +365,6 @@ public DecoderState next(MariadbPacketDecoder decoder) { }, ERROR { - public DecoderState decoder(short val, int len, long serverCapabilities) { - return this; - } @Override public ServerMessage decode( @@ -440,9 +379,6 @@ public DecoderState next(MariadbPacketDecoder decoder) { }, ERROR_AND_EXECUTE_RESPONSE { - public DecoderState decoder(short val, int len, long serverCapabilities) { - return this; - } @Override public ServerMessage decode( @@ -457,9 +393,6 @@ public DecoderState next(MariadbPacketDecoder decoder) { }, SKIP_EXECUTE { - public DecoderState decoder(short val, int len, long serverCapabilities) { - return this; - } @Override public ServerMessage decode( diff --git a/src/main/java/org/mariadb/r2dbc/client/DecoderStateInterface.java b/src/main/java/org/mariadb/r2dbc/client/DecoderStateInterface.java index f89b2411..0979fd8d 100644 --- a/src/main/java/org/mariadb/r2dbc/client/DecoderStateInterface.java +++ b/src/main/java/org/mariadb/r2dbc/client/DecoderStateInterface.java @@ -22,8 +22,12 @@ public interface DecoderStateInterface { + // default DecoderState decoder(short val, int len, long serverCapabilities) { + // throw new IllegalArgumentException("unexpected state"); + // } + default DecoderState decoder(short val, int len, long serverCapabilities) { - throw new IllegalArgumentException("unexpected state"); + return (DecoderState) this; } default ServerMessage decode( diff --git a/src/main/java/org/mariadb/r2dbc/client/MariadbPacketDecoder.java b/src/main/java/org/mariadb/r2dbc/client/MariadbPacketDecoder.java index a7082ee7..92c00e6d 100644 --- a/src/main/java/org/mariadb/r2dbc/client/MariadbPacketDecoder.java +++ b/src/main/java/org/mariadb/r2dbc/client/MariadbPacketDecoder.java @@ -27,6 +27,7 @@ import org.mariadb.r2dbc.message.server.PrepareResultPacket; import org.mariadb.r2dbc.message.server.Sequencer; import org.mariadb.r2dbc.message.server.ServerMessage; +import org.mariadb.r2dbc.util.BufferUtils; import org.mariadb.r2dbc.util.PrepareCache; import org.mariadb.r2dbc.util.ServerPrepareResult; @@ -95,16 +96,10 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List out) private void handleBuffer(ByteBuf packet, Sequencer sequencer) { if (cmdElement == null && !loadNextResponse()) { - char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); - char[] hexChars = new char[packet.readerIndex() * 2]; - for (int j = 0; j < packet.readerIndex(); j++) { - int v = packet.getByte(j) & 0xFF; - hexChars[j * 2] = HEX_ARRAY[v >>> 4]; - hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; - } throw new R2dbcNonTransientResourceException( String.format( - "unexpected message received when no command was send: 0x%s", new String(hexChars))); + "unexpected message received when no command was send: 0x%s", + BufferUtils.toString(packet))); } state = @@ -135,10 +130,6 @@ public void connectionError(Throwable err) { } } - public Client getClient() { - return client; - } - public Context getContext() { return context; } diff --git a/src/main/java/org/mariadb/r2dbc/codec/BinaryRowDecoder.java b/src/main/java/org/mariadb/r2dbc/codec/BinaryRowDecoder.java index 9990454a..195a9a5a 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/BinaryRowDecoder.java +++ b/src/main/java/org/mariadb/r2dbc/codec/BinaryRowDecoder.java @@ -87,112 +87,103 @@ public void setPosition(int newIndex) { index++; } - for (; index <= newIndex; index++) { + for (; index < newIndex; index++) { if ((nullBitmap[(index + 2) / 8] & (1 << ((index + 2) % 8))) == 0) { - if (index != newIndex) { - // skip bytes - switch (columns[index].getType()) { - case BIGINT: - case DOUBLE: - buf.skipBytes(8); - break; - - case INTEGER: - case MEDIUMINT: - case FLOAT: - buf.skipBytes(4); - break; - - case SMALLINT: - case YEAR: - buf.skipBytes(2); - break; - - case TINYINT: - buf.skipBytes(1); - break; - - default: - int type = this.buf.readUnsignedByte(); - switch (type) { - case 251: - break; - - case 252: - this.buf.skipBytes(this.buf.readUnsignedShortLE()); - break; - - case 253: - this.buf.skipBytes(this.buf.readUnsignedMediumLE()); - break; - - case 254: - this.buf.skipBytes((int) this.buf.readLongLE()); - break; - - default: - this.buf.skipBytes(type); - break; - } - break; - } - } else { - // read asked field position and length - switch (columns[index].getType()) { - case BIGINT: - case DOUBLE: - length = 8; - return; - - case INTEGER: - case MEDIUMINT: - case FLOAT: - length = 4; - return; - - case SMALLINT: - case YEAR: - length = 2; - return; - - case TINYINT: - length = 1; - return; - - default: - // field with variable length - int len = this.buf.readUnsignedByte(); - switch (len) { - case 251: - // null length field - // must never occur - // null value are set in NULL-Bitmap, not send with a null length indicator. - throw new IllegalStateException( - "null data is encoded in binary protocol but NULL-Bitmap is not set"); - - case 252: - // length is encoded on 3 bytes (0xfc header + 2 bytes indicating length) - length = this.buf.readUnsignedShortLE(); - return; - - case 253: - // length is encoded on 4 bytes (0xfd header + 3 bytes indicating length) - length = this.buf.readUnsignedMediumLE(); - return; - - case 254: - // length is encoded on 9 bytes (0xfe header + 8 bytes indicating length) - length = (int) this.buf.readLongLE(); - return; - - default: - // length is encoded on 1 bytes (is then less than 251) - length = len; - return; - } - } + // skip bytes + switch (columns[index].getType()) { + case BIGINT: + case DOUBLE: + buf.skipBytes(8); + break; + + case INTEGER: + case MEDIUMINT: + case FLOAT: + buf.skipBytes(4); + break; + + case SMALLINT: + case YEAR: + buf.skipBytes(2); + break; + + case TINYINT: + buf.skipBytes(1); + break; + + default: + int type = this.buf.readUnsignedByte(); + switch (type) { + case 251: + break; + + case 252: + this.buf.skipBytes(this.buf.readUnsignedShortLE()); + break; + + case 253: + this.buf.skipBytes(this.buf.readUnsignedMediumLE()); + break; + + case 254: + this.buf.skipBytes((int) this.buf.readLongLE()); + break; + + default: + this.buf.skipBytes(type); + break; + } + break; } } } + + // read asked field position and length + switch (columns[index].getType()) { + case BIGINT: + case DOUBLE: + length = 8; + return; + + case INTEGER: + case MEDIUMINT: + case FLOAT: + length = 4; + return; + + case SMALLINT: + case YEAR: + length = 2; + return; + + case TINYINT: + length = 1; + return; + + default: + // field with variable length + int len = this.buf.readUnsignedByte(); + switch (len) { + case 252: + // length is encoded on 3 bytes (0xfc header + 2 bytes indicating length) + length = this.buf.readUnsignedShortLE(); + return; + + case 253: + // length is encoded on 4 bytes (0xfd header + 3 bytes indicating length) + length = this.buf.readUnsignedMediumLE(); + return; + + case 254: + // length is encoded on 9 bytes (0xfe header + 8 bytes indicating length) + length = (int) this.buf.readLongLE(); + return; + + default: + // length is encoded on 1 bytes (is then less than 251) + length = len; + return; + } + } } } diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/DurationCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/DurationCodec.java index df1f2f20..b6bed688 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/DurationCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/DurationCodec.java @@ -30,13 +30,13 @@ public class DurationCodec implements Codec { public static final DurationCodec INSTANCE = new DurationCodec(); private static final EnumSet COMPATIBLE_TYPES = - EnumSet.of( - DataType.TIME, - DataType.DATETIME, - DataType.TIMESTAMP, - DataType.VARSTRING, - DataType.VARCHAR, - DataType.STRING); + EnumSet.of( + DataType.TIME, + DataType.DATETIME, + DataType.TIMESTAMP, + DataType.VARSTRING, + DataType.VARCHAR, + DataType.STRING); public boolean canDecode(ColumnDefinitionPacket column, Class type) { return COMPATIBLE_TYPES.contains(column.getType()) && type.isAssignableFrom(Duration.class); @@ -48,32 +48,32 @@ public boolean canEncode(Class value) { @Override public Duration decodeText( - ByteBuf buf, int length, ColumnDefinitionPacket column, Class type) { + ByteBuf buf, int length, ColumnDefinitionPacket column, Class type) { int[] parts; switch (column.getType()) { case TIMESTAMP: case DATETIME: parts = - LocalDateTimeCodec.parseTimestamp( - buf.readCharSequence(length, StandardCharsets.US_ASCII).toString()); + LocalDateTimeCodec.parseTimestamp( + buf.readCharSequence(length, StandardCharsets.US_ASCII).toString()); if (parts == null) return null; return Duration.ZERO - .plusDays(parts[2] - 1) - .plusHours(parts[3]) - .plusMinutes(parts[4]) - .plusSeconds(parts[5]) - .plusNanos(parts[6]); + .plusDays(parts[2] - 1) + .plusHours(parts[3]) + .plusMinutes(parts[4]) + .plusSeconds(parts[5]) + .plusNanos(parts[6]); default: // TIME, VARCHAR, VARSTRING, STRING: parts = LocalTimeCodec.parseTime(buf, length, column); Duration d = - Duration.ZERO - .plusHours(parts[1]) - .plusMinutes(parts[2]) - .plusSeconds(parts[3]) - .plusNanos(parts[4]); + Duration.ZERO + .plusHours(parts[1]) + .plusMinutes(parts[2]) + .plusSeconds(parts[3]) + .plusNanos(parts[4]); if (parts[0] == 1) return d.negated(); return d; } @@ -81,7 +81,7 @@ public Duration decodeText( @Override public Duration decodeBinary( - ByteBuf buf, int length, ColumnDefinitionPacket column, Class type) { + ByteBuf buf, int length, ColumnDefinitionPacket column, Class type) { long days = 0; int hours = 0; @@ -104,12 +104,12 @@ public Duration decodeBinary( } Duration duration = - Duration.ZERO - .plusDays(days) - .plusHours(hours) - .plusMinutes(minutes) - .plusSeconds(seconds) - .plusNanos(microseconds * 1000); + Duration.ZERO + .plusDays(days) + .plusHours(hours) + .plusMinutes(minutes) + .plusSeconds(seconds) + .plusNanos(microseconds * 1000); if (negate) return duration.negated(); return duration; @@ -129,21 +129,21 @@ public Duration decodeBinary( } } return Duration.ZERO - .plusDays(days - 1) - .plusHours(hours) - .plusMinutes(minutes) - .plusSeconds(seconds) - .plusNanos(microseconds * 1000); + .plusDays(days - 1) + .plusHours(hours) + .plusMinutes(minutes) + .plusSeconds(seconds) + .plusNanos(microseconds * 1000); default: // VARCHAR, VARSTRING, STRING: int[] parts = LocalTimeCodec.parseTime(buf, length, column); Duration d = - Duration.ZERO - .plusHours(parts[1]) - .plusMinutes(parts[2]) - .plusSeconds(parts[3]) - .plusNanos(parts[4]); + Duration.ZERO + .plusHours(parts[1]) + .plusMinutes(parts[2]) + .plusSeconds(parts[3]) + .plusNanos(parts[4]); if (parts[0] == 1) return d.negated(); return d; } @@ -164,20 +164,19 @@ public void encodeText(ByteBuf buf, Context context, Duration val) { if (negate) { s = s - 1; buf.writeCharSequence( - String.format("-%d:%02d:%02d.%06d", s / 3600, (s % 3600) / 60, (s % 60), 1000000 - microSecond), - StandardCharsets.US_ASCII); + String.format( + "-%d:%02d:%02d.%06d", s / 3600, (s % 3600) / 60, (s % 60), 1000000 - microSecond), + StandardCharsets.US_ASCII); } else { buf.writeCharSequence( - String.format("%d:%02d:%02d.%06d", s / 3600, (s % 3600) / 60, (s % 60), microSecond), - StandardCharsets.US_ASCII); - + String.format("%d:%02d:%02d.%06d", s / 3600, (s % 3600) / 60, (s % 60), microSecond), + StandardCharsets.US_ASCII); } } else { String format = negate ? "-%d:%02d:%02d" : "%d:%02d:%02d"; buf.writeCharSequence( - String.format(format, s / 3600, (s % 3600) / 60, (s % 60)), - StandardCharsets.US_ASCII); + String.format(format, s / 3600, (s % 3600) / 60, (s % 60)), StandardCharsets.US_ASCII); } buf.writeByte('\''); } @@ -203,7 +202,7 @@ public void encodeBinary(ByteBuf buf, Context context, Duration value) { buf.writeByte((int) (s % (24 * 3600)) / 3600); buf.writeByte((int) (s % 3600) / 60); buf.writeByte((int) (s % 60)); - buf.writeIntLE((int)microSecond); + buf.writeIntLE((int) microSecond); } } else { buf.writeByte((byte) 8); diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateCodec.java index f24da2de..574723ef 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateCodec.java @@ -136,14 +136,17 @@ public LocalDate decodeBinary( switch (column.getType()) { case TIMESTAMP: case DATETIME: - year = buf.readUnsignedShortLE(); - month = buf.readByte(); - dayOfMonth = buf.readByte(); + if (length > 0) { + year = buf.readUnsignedShortLE(); + month = buf.readByte(); + dayOfMonth = buf.readByte(); - if (length > 4) { - buf.skipBytes(length - 4); + if (length > 4) { + buf.skipBytes(length - 4); + } + return LocalDate.of(year, month, dayOfMonth); } - return LocalDate.of(year, month, dayOfMonth); + return null; case YEAR: if (length > 0) { diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateTimeCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateTimeCodec.java index f09e5579..3919e3fb 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateTimeCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateTimeCodec.java @@ -186,7 +186,7 @@ public LocalDateTime decodeBinary( microseconds = buf.readUnsignedIntLE(); } } - } + } else return null; break; default: diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/LocalTimeCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/LocalTimeCodec.java index a6aaa7dc..ca288904 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/LocalTimeCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/LocalTimeCodec.java @@ -161,8 +161,9 @@ public LocalTime decodeBinary( microseconds = buf.readIntLE(); } } + return LocalTime.of(hour, minutes, seconds).plusNanos(microseconds * 1000); } - return LocalTime.of(hour, minutes, seconds).plusNanos(microseconds * 1000); + return null; case TIME: boolean negate = false; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/StringCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/StringCodec.java index 5126a24d..6d3cead5 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/StringCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/StringCodec.java @@ -247,11 +247,12 @@ public String decodeBinary( microseconds = buf.readUnsignedIntLE(); } } + LocalDateTime dateTime = + LocalDateTime.of(year, month, day, hour, minutes, seconds) + .plusNanos(microseconds * 1000); + return dateTime.toLocalDate().toString() + ' ' + dateTime.toLocalTime().toString(); } - LocalDateTime dateTime = - LocalDateTime.of(year, month, day, hour, minutes, seconds) - .plusNanos(microseconds * 1000); - return dateTime.toLocalDate().toString() + ' ' + dateTime.toLocalTime().toString(); + return null; default: return buf.readCharSequence(length, StandardCharsets.UTF_8).toString(); diff --git a/src/main/java/org/mariadb/r2dbc/message/client/Ed25519PasswordPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/Ed25519PasswordPacket.java index f1e17b2f..2398307a 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/Ed25519PasswordPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/Ed25519PasswordPacket.java @@ -92,7 +92,7 @@ private static byte[] ed25519SignWithPassword(final CharSequence password, final @Override public ByteBuf encode(Context context, ByteBufAllocator allocator) { - if (password == null || password.toString().isEmpty()) return allocator.ioBuffer(0); + if (password == null) return allocator.ioBuffer(0); ByteBuf buf = allocator.ioBuffer(64); buf.writeBytes(ed25519SignWithPassword(password, seed)); return buf; diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java index 59a87b5d..bde87152 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java @@ -110,7 +110,7 @@ private static long initializeClientCapabilities( capabilities |= Capabilities.CLIENT_DEPRECATE_EOF; } - if (configuration.getDatabase() != null && !configuration.getDatabase().isEmpty()) { + if (configuration.getDatabase() != null) { capabilities |= Capabilities.CONNECT_WITH_DB; } return capabilities; diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/CachingSha2PasswordFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/CachingSha2PasswordFlow.java index 0fa438b4..a01dd4f4 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/CachingSha2PasswordFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/CachingSha2PasswordFlow.java @@ -44,7 +44,7 @@ public final class CachingSha2PasswordFlow extends Sha256PasswordPluginFlow { */ public static byte[] sha256encryptPassword(final CharSequence password, final byte[] seed) { - if (password == null || password.length() == 0) { + if (password == null) { return new byte[0]; } byte[] truncatedSeed = new byte[seed.length - 1]; diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/Sha256PasswordPluginFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/Sha256PasswordPluginFlow.java index af99832b..edbaceb2 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/Sha256PasswordPluginFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/Sha256PasswordPluginFlow.java @@ -116,46 +116,37 @@ public ClientMessage next( AuthMoreDataPacket authMoreDataPacket) throws R2dbcException { - switch (state) { - case INIT: - CharSequence password = configuration.getPassword(); - if (password == null - || password.toString().isEmpty() - || configuration.getSslConfig().getSslMode() != SslMode.DISABLE) { - return new ClearPasswordPacket(authSwitchPacket.getSequencer(), password); + if (state == State.INIT) { + CharSequence password = configuration.getPassword(); + if (password == null || configuration.getSslConfig().getSslMode() != SslMode.DISABLE) { + return new ClearPasswordPacket(authSwitchPacket.getSequencer(), password); + } else { + // retrieve public key from configuration or from server + if (configuration.getRsaPublicKey() != null && !configuration.getRsaPublicKey().isEmpty()) { + publicKey = readPublicKeyFromFile(configuration.getRsaPublicKey()); } else { - // retrieve public key from configuration or from server - if (configuration.getRsaPublicKey() != null - && !configuration.getRsaPublicKey().isEmpty()) { - publicKey = readPublicKeyFromFile(configuration.getRsaPublicKey()); - } else { - if (!configuration.allowPublicKeyRetrieval()) { - throw new R2dbcNonTransientResourceException( - "RSA public key is not available client side (option " - + "serverRsaPublicKeyFile)", - "S1009"); - } - state = State.REQUEST_SERVER_KEY; - // ask public Key Retrieval - return new RsaPublicKeyRequestPacket(authSwitchPacket.getSequencer()); + if (!configuration.allowPublicKeyRetrieval()) { + throw new R2dbcNonTransientResourceException( + "RSA public key is not available client side (option " + "serverRsaPublicKeyFile)", + "S1009"); } + state = State.REQUEST_SERVER_KEY; + // ask public Key Retrieval + return new RsaPublicKeyRequestPacket(authSwitchPacket.getSequencer()); } - return new Sha256PasswordPacket( - authSwitchPacket.getSequencer(), - configuration.getPassword(), - authSwitchPacket.getSeed(), - publicKey); - - case REQUEST_SERVER_KEY: - publicKey = readPublicKey(authMoreDataPacket); - return new Sha256PasswordPacket( - authMoreDataPacket.getSequencer(), - configuration.getPassword(), - authSwitchPacket.getSeed(), - publicKey); - - default: - throw new R2dbcNonTransientResourceException("Wrong state", "S1009"); + } + return new Sha256PasswordPacket( + authSwitchPacket.getSequencer(), + configuration.getPassword(), + authSwitchPacket.getSeed(), + publicKey); + } else { + publicKey = readPublicKey(authMoreDataPacket); + return new Sha256PasswordPacket( + authMoreDataPacket.getSequencer(), + configuration.getPassword(), + authSwitchPacket.getSeed(), + publicKey); } } diff --git a/src/main/java/org/mariadb/r2dbc/message/server/OkPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/OkPacket.java index dcaddf6c..efe81955 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/OkPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/OkPacket.java @@ -74,7 +74,7 @@ public static OkPacket decode(Sequencer sequencer, ByteBuf buf, Context context) case StateChange.SESSION_TRACK_SCHEMA: ByteBuf sessionSchemaBuf = BufferUtils.readLengthEncodedBuffer(stateInfo); String database = BufferUtils.readLengthEncodedString(sessionSchemaBuf); - context.setDatabase(database); + // context.setDatabase(database); logger.debug("Database change : now is '{}'", database); break; } diff --git a/src/main/java/org/mariadb/r2dbc/message/server/SkipPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/SkipPacket.java index 34b87e16..a91c65cc 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/SkipPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/SkipPacket.java @@ -33,6 +33,10 @@ public boolean ending() { return this.ending; } + public boolean resultSetEnd() { + return this.ending; + } + public Sequencer getSequencer() { return null; } diff --git a/src/main/java/org/mariadb/r2dbc/util/BufferUtils.java b/src/main/java/org/mariadb/r2dbc/util/BufferUtils.java index 0dc69653..86d9412a 100644 --- a/src/main/java/org/mariadb/r2dbc/util/BufferUtils.java +++ b/src/main/java/org/mariadb/r2dbc/util/BufferUtils.java @@ -22,7 +22,7 @@ import org.mariadb.r2dbc.client.Context; import org.mariadb.r2dbc.util.constants.ServerStatus; -public class BufferUtils { +public final class BufferUtils { private static final byte QUOTE = (byte) '\''; private static final byte DBL_QUOTE = (byte) '"'; @@ -240,4 +240,17 @@ public static ByteBuf write(ByteBuf buf, String str, boolean quote, Context cont } return buf; } + + public static String toString(ByteBuf packet) { + char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); + char[] hexChars = new char[packet.readableBytes() * 2]; + int j = 0; + while (packet.readableBytes() > 0) { + int v = packet.readByte() & 0xFF; + hexChars[j * 2] = HEX_ARRAY[v >>> 4]; + hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; + j++; + } + return new String(hexChars); + } } diff --git a/src/main/java/org/mariadb/r2dbc/util/ClientPrepareResult.java b/src/main/java/org/mariadb/r2dbc/util/ClientPrepareResult.java index 28a05826..f4ad3dc7 100644 --- a/src/main/java/org/mariadb/r2dbc/util/ClientPrepareResult.java +++ b/src/main/java/org/mariadb/r2dbc/util/ClientPrepareResult.java @@ -24,9 +24,7 @@ public class ClientPrepareResult implements PrepareResult { private final List queryParts; private final List paramNameList; - private final boolean rewriteType; private final int paramCount; - private boolean isQueryMultiValuesRewritable; private boolean isQueryMultipleRewritable; private boolean isReturning; private boolean supportAddingReturning; @@ -34,17 +32,13 @@ public class ClientPrepareResult implements PrepareResult { private ClientPrepareResult( List queryParts, List paramNameList, - boolean isQueryMultiValuesRewritable, boolean isQueryMultipleRewritable, - boolean rewriteType, boolean isReturning, boolean supportAddingReturning) { this.queryParts = queryParts; this.paramNameList = paramNameList; - this.isQueryMultiValuesRewritable = isQueryMultiValuesRewritable; this.isQueryMultipleRewritable = isQueryMultipleRewritable; - this.paramCount = queryParts.size() - (rewriteType ? 3 : 1); - this.rewriteType = rewriteType; + this.paramCount = queryParts.size() - 1; this.isReturning = isReturning; this.supportAddingReturning = supportAddingReturning; } @@ -58,7 +52,6 @@ private ClientPrepareResult( * @return ClientPrepareResult */ public static ClientPrepareResult parameterParts(String queryString, boolean noBackslashEscapes) { - boolean reWritablePrepare = false; boolean multipleQueriesPrepare = true; List partList = new ArrayList<>(); List paramNameList = new ArrayList<>(); @@ -123,8 +116,6 @@ public static ClientPrepareResult parameterParts(String queryString, boolean noB singleQuotes = false; } else if (state == LexState.String && !singleQuotes) { state = LexState.Normal; - } else if (state == LexState.Escape && !singleQuotes) { - state = LexState.String; } break; @@ -134,16 +125,11 @@ public static ClientPrepareResult parameterParts(String queryString, boolean noB singleQuotes = true; } else if (state == LexState.String && singleQuotes) { state = LexState.Normal; - } else if (state == LexState.Escape && singleQuotes) { - state = LexState.String; } break; case '\\': - if (noBackslashEscapes) { - break; - } - if (state == LexState.String) { + if (!noBackslashEscapes && state == LexState.String) { state = LexState.Escape; } break; @@ -315,13 +301,7 @@ public static ClientPrepareResult parameterParts(String queryString, boolean noB } return new ClientPrepareResult( - partList, - paramNameList, - reWritablePrepare, - multipleQueriesPrepare, - false, - returning, - supportAddingReturning); + partList, paramNameList, multipleQueriesPrepare, returning, supportAddingReturning); } /** @@ -386,8 +366,6 @@ public static boolean hasParameter(String queryString, boolean noBackslashEscape singleQuotes = false; } else if (state == LexState.String && !singleQuotes) { state = LexState.Normal; - } else if (state == LexState.Escape && !singleQuotes) { - state = LexState.String; } break; @@ -397,8 +375,6 @@ public static boolean hasParameter(String queryString, boolean noBackslashEscape singleQuotes = true; } else if (state == LexState.String && singleQuotes) { state = LexState.Normal; - } else if (state == LexState.Escape && singleQuotes) { - state = LexState.String; } break; @@ -451,18 +427,10 @@ public List getParamNameList() { return paramNameList; } - public boolean isQueryMultiValuesRewritable() { - return isQueryMultiValuesRewritable; - } - public boolean isQueryMultipleRewritable() { return isQueryMultipleRewritable; } - public boolean isRewriteType() { - return rewriteType; - } - public boolean isReturning() { return isReturning; } @@ -498,7 +466,7 @@ public void validateAddingReturning() { } if (!supportAddingReturning()) { - throw new IllegalStateException("Cannot add RETUNING clause to query"); + throw new IllegalStateException("Cannot add RETURNING clause to query"); } } diff --git a/src/main/java/org/mariadb/r2dbc/util/DefaultHostnameVerifier.java b/src/main/java/org/mariadb/r2dbc/util/DefaultHostnameVerifier.java index 3fdcd44b..704c25ca 100644 --- a/src/main/java/org/mariadb/r2dbc/util/DefaultHostnameVerifier.java +++ b/src/main/java/org/mariadb/r2dbc/util/DefaultHostnameVerifier.java @@ -22,6 +22,7 @@ import java.security.cert.CertificateParsingException; import java.security.cert.X509Certificate; import java.util.*; +import java.util.regex.Pattern; import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; @@ -38,6 +39,17 @@ public class DefaultHostnameVerifier implements HostnameVerifier { private static final Logger logger = Loggers.getLogger(DefaultHostnameVerifier.class); + private static final Pattern IP_V4 = + Pattern.compile( + "^(([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){1}" + + "(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){2}" + + "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"); + private static final Pattern IP_V6 = Pattern.compile("^[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7}$"); + private static final Pattern IP_V6_COMPRESSED = + Pattern.compile( + "^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)" + + "::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)$"); + /** * DNS verification : Matching is performed using the matching rules specified by [RFC2459]. If * more than one identity of a given type is present in the certificate (e.g., more than one @@ -51,7 +63,7 @@ public class DefaultHostnameVerifier implements HostnameVerifier { * @return true if matching */ private static boolean matchDns(String hostname, String tlsDnsPattern) throws SSLException { - boolean hostIsIp = Utility.isIPv4(hostname) || Utility.isIPv6(hostname); + boolean hostIsIp = isIPv4(hostname) || isIPv6(hostname); StringTokenizer hostnameSt = new StringTokenizer(hostname.toLowerCase(Locale.ROOT), "."); StringTokenizer templateSt = new StringTokenizer(tlsDnsPattern.toLowerCase(Locale.ROOT), "."); if (hostnameSt.countTokens() != templateSt.countTokens()) { @@ -142,9 +154,9 @@ private static String normaliseAddress(String hostname) { private static String normalizedHostMsg(String normalizedHost) { StringBuilder msg = new StringBuilder(); - if (Utility.isIPv4(normalizedHost)) { + if (isIPv4(normalizedHost)) { msg.append("IPv4 host \""); - } else if (Utility.isIPv6(normalizedHost)) { + } else if (isIPv6(normalizedHost)) { msg.append("IPv6 host \""); } else { msg.append("DNS host \""); @@ -153,7 +165,15 @@ private static String normalizedHostMsg(String normalizedHost) { return msg.toString(); } - private SubjectAltNames getSubjectAltNames(X509Certificate cert) + public static boolean isIPv4(final String ip) { + return IP_V4.matcher(ip).matches(); + } + + public static boolean isIPv6(final String ip) { + return IP_V6.matcher(ip).matches() || IP_V6_COMPRESSED.matcher(ip).matches(); + } + + private static SubjectAltNames getSubjectAltNames(X509Certificate cert) throws CertificateParsingException { Collection> entries = cert.getSubjectAlternativeNames(); SubjectAltNames subjectAltNames = new SubjectAltNames(); @@ -218,7 +238,8 @@ public boolean verify(String host, SSLSession session, long serverThreadId) { * @param serverThreadId server thread Identifier to identify connection in logs * @throws SSLException exception */ - public void verify(String host, X509Certificate cert, long serverThreadId) throws SSLException { + public static void verify(String host, X509Certificate cert, long serverThreadId) + throws SSLException { if (host == null) { return; // no validation if no host (possible for name pipe) } @@ -233,7 +254,7 @@ public void verify(String host, X509Certificate cert, long serverThreadId) throw // *********************************************************** // Host is IPv4 : Check corresponding entries in subject alternative names // *********************************************************** - if (Utility.isIPv4(lowerCaseHost)) { + if (isIPv4(lowerCaseHost)) { for (GeneralName entry : subjectAltNames.getGeneralNames()) { if (logger.isTraceEnabled()) { logger.trace( @@ -248,7 +269,7 @@ public void verify(String host, X509Certificate cert, long serverThreadId) throw return; } } - } else if (Utility.isIPv6(lowerCaseHost)) { + } else if (isIPv6(lowerCaseHost)) { // *********************************************************** // Host is IPv6 : Check corresponding entries in subject alternative names // *********************************************************** @@ -264,7 +285,7 @@ public void verify(String host, X509Certificate cert, long serverThreadId) throw } if (entry.extension == Extension.IP - && !Utility.isIPv4(entry.value) + && !isIPv4(entry.value) && normalisedHost.equals(normaliseAddress(entry.value))) { return; } @@ -300,7 +321,7 @@ && matchDns(lowerCaseHost, entry.value.toLowerCase(Locale.ROOT))) { if (cn == null) { if (subjectAltNames.isEmpty()) { throw new SSLException( - "CN not found in certificate principal \"{}" + "CN not found in certificate principal \"" + subjectPrincipal + "\" and certificate doesn't contain SAN"); } else { @@ -310,7 +331,7 @@ && matchDns(lowerCaseHost, entry.value.toLowerCase(Locale.ROOT))) { + "\" and " + normalizedHostMsg(lowerCaseHost) + " doesn't correspond to " - + subjectAltNames.toString()); + + subjectAltNames); } } @@ -329,7 +350,7 @@ && matchDns(lowerCaseHost, entry.value.toLowerCase(Locale.ROOT))) { + normalizedCn + "\""; if (!subjectAltNames.isEmpty()) { - errorMsg += " and " + subjectAltNames.toString(); + errorMsg += " and " + subjectAltNames; } throw new SSLException(errorMsg); } @@ -344,7 +365,7 @@ private enum Extension { IP } - private class GeneralName { + private static class GeneralName { private final String value; private final Extension extension; @@ -360,16 +381,12 @@ public String toString() { } } - private class SubjectAltNames { + private static class SubjectAltNames { private final List generalNames = new ArrayList<>(); @Override public String toString() { - if (isEmpty()) { - return "SAN[-empty-]"; - } - StringBuilder sb = new StringBuilder("SAN["); boolean first = true; diff --git a/src/main/java/org/mariadb/r2dbc/util/PidFactory.java b/src/main/java/org/mariadb/r2dbc/util/PidFactory.java index a53970f9..945c8eb6 100644 --- a/src/main/java/org/mariadb/r2dbc/util/PidFactory.java +++ b/src/main/java/org/mariadb/r2dbc/util/PidFactory.java @@ -19,7 +19,7 @@ import java.lang.reflect.Method; import java.util.function.Supplier; -public class PidFactory { +public final class PidFactory { private static Supplier instance; static { diff --git a/src/main/java/org/mariadb/r2dbc/util/SslConfig.java b/src/main/java/org/mariadb/r2dbc/util/SslConfig.java index 7dc42d45..d12dd443 100644 --- a/src/main/java/org/mariadb/r2dbc/util/SslConfig.java +++ b/src/main/java/org/mariadb/r2dbc/util/SslConfig.java @@ -63,9 +63,7 @@ public SslConfig( this.clientSslCert = clientSslCert; this.clientSslKey = clientSslKey; this.clientSslPassword = clientSslPassword; - if (sslMode != SslMode.DISABLE) { - sslContextBuilder = getSslContextBuilder(); - } + this.sslContextBuilder = getSslContextBuilder(); } public SslConfig(SslMode sslMode) { diff --git a/src/main/java/org/mariadb/r2dbc/util/Utility.java b/src/main/java/org/mariadb/r2dbc/util/Utility.java deleted file mode 100644 index f81f90e7..00000000 --- a/src/main/java/org/mariadb/r2dbc/util/Utility.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.mariadb.r2dbc.util; - -import java.util.regex.Pattern; - -public class Utility { - private static final Pattern IP_V4 = - Pattern.compile( - "^(([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){1}" - + "(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){2}" - + "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"); - private static final Pattern IP_V6 = Pattern.compile("^[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7}$"); - private static final Pattern IP_V6_COMPRESSED = - Pattern.compile( - "^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)" - + "::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)$"); - - public static boolean isIPv4(final String ip) { - return IP_V4.matcher(ip).matches(); - } - - public static boolean isIPv6(final String ip) { - return IP_V6.matcher(ip).matches() || IP_V6_COMPRESSED.matcher(ip).matches(); - } -} diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java index dc9e65a2..fd03b902 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java @@ -321,4 +321,12 @@ void confStringValue() { "SslConfig{sslMode=TRUST, serverSslCert=null, clientSslCert=null, tlsProtocol=null, clientSslKey=null}", conf.getSslConfig().toString()); } + + @Test + public void emptySessionVariable() throws Exception { + MariadbConnectionConfiguration emptySessionConf = + TestConfiguration.defaultBuilder.clone().sessionVariables(new HashMap<>()).build(); + MariadbConnection con = new MariadbConnectionFactory(emptySessionConf).create().block(); + con.close().block(); + } } diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConnectionMetadataTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConnectionMetadataTest.java index 5686ee09..2e074397 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConnectionMetadataTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConnectionMetadataTest.java @@ -36,21 +36,13 @@ void connectionMeta() { assertTrue( meta.getDatabaseVersion().contains("5.") || meta.getDatabaseVersion().contains("8.")); } - String value = System.getenv("DB"); - if (value != null) { - String type; - String version; - // testing env - if (System.getenv("TRAVIS") != null) { - type = value.substring(0, value.indexOf(":")); - version = value.substring(value.indexOf(":") + 1); - } else { - // appveyor test only mariadb - type = "MariaDB"; - version = value; + String type = System.getenv("srv"); + String version = System.getenv("v"); + if (type != null && System.getenv("TRAVIS") != null) { + if ("mariadb".equals(type) || "mysql".equals(type)) { + assertTrue(meta.getDatabaseVersion().contains(version)); + assertEquals(type.toLowerCase(), meta.getDatabaseProductName().toLowerCase()); } - assertTrue(meta.getDatabaseVersion().contains(version)); - assertEquals(type.toLowerCase(), meta.getDatabaseProductName().toLowerCase()); } } diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java index a5c8341b..9bb6787e 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java @@ -30,10 +30,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; -import org.mariadb.r2dbc.BaseConnectionTest; -import org.mariadb.r2dbc.MariadbConnectionConfiguration; -import org.mariadb.r2dbc.MariadbConnectionFactory; -import org.mariadb.r2dbc.TestConfiguration; +import org.mariadb.r2dbc.*; import org.mariadb.r2dbc.api.MariadbConnection; import org.mariadb.r2dbc.api.MariadbResult; import org.mariadb.r2dbc.api.MariadbStatement; @@ -178,7 +175,7 @@ public void run() { proxy.stop(); } }, - 1000); + 200); try { connection @@ -186,12 +183,7 @@ public void run() { "select * from information_schema.columns as c1, " + "information_schema.tables, information_schema.tables as t2") .execute() - .flatMap( - r -> - r.map( - (rows, meta) -> { - return ""; - })) + .flatMap(r -> r.map((rows, meta) -> "")) .blockLast(); Assertions.fail("must have throw exception"); } catch (Throwable t) { @@ -201,6 +193,11 @@ public void run() { || t.getMessage().contains("Connection unexpectedly closed") || t.getMessage().contains("Connection unexpected error"), "real msg:" + t.getMessage()); + connection + .validate(ValidationDepth.LOCAL) + .as(StepVerifier::create) + .expectNext(Boolean.FALSE) + .verifyComplete(); reInitLog(); } } @@ -368,21 +365,45 @@ void multipleClose() throws Exception { @Test void multipleBegin() throws Exception { MariadbConnection connection = factory.create().block(); - connection.beginTransaction().subscribe(); - connection.beginTransaction().block(); - connection.beginTransaction().block(); + multipleBegin(connection); + connection.close().block(); + + connection = + new MariadbConnectionFactory( + TestConfiguration.defaultBuilder.clone().allowPipelining(false).build()) + .create() + .block(); + multipleBegin(connection); connection.close().block(); } + void multipleBegin(MariadbConnection con) throws Exception { + con.beginTransaction().subscribe(); + con.beginTransaction().block(); + con.beginTransaction().block(); + } + @Test void multipleAutocommit() throws Exception { MariadbConnection connection = factory.create().block(); - connection.setAutoCommit(true).subscribe(); - connection.setAutoCommit(true).block(); - connection.setAutoCommit(false).block(); + multipleAutocommit(connection); + connection.close().block(); + + connection = + new MariadbConnectionFactory( + TestConfiguration.defaultBuilder.clone().allowPipelining(false).build()) + .create() + .block(); + multipleAutocommit(connection); connection.close().block(); } + void multipleAutocommit(MariadbConnection con) throws Exception { + con.setAutoCommit(true).subscribe(); + con.setAutoCommit(true).block(); + con.setAutoCommit(false).block(); + } + @Test void queryAfterClose() throws Exception { MariadbConnection connection = factory.create().block(); @@ -601,45 +622,102 @@ void rollbackTransaction() { } @Test - void commitTransaction() { - sharedConn.createStatement("DROP TABLE IF EXISTS commitTransaction").execute().blockLast(); - sharedConn - .createStatement("CREATE TABLE commitTransaction (t1 VARCHAR(256))") - .execute() - .blockLast(); - sharedConn.setAutoCommit(false).block(); - sharedConn.commitTransaction().block(); // must not do anything - sharedConn.createStatement("INSERT INTO commitTransaction VALUES ('a')").execute().blockLast(); - sharedConn.commitTransaction().block(); - sharedConn - .createStatement("SELECT * FROM commitTransaction") + void commitTransaction() throws Exception { + MariadbConnection connection = factory.create().block(); + commitTransaction(connection); + MariadbStatement stmt = connection.createStatement("DO 1"); + connection.close().block(); + assertThrows( + R2dbcNonTransientResourceException.class, + () -> stmt.execute().blockLast(), + "Connection is close. Cannot send anything"); + + connection = + new MariadbConnectionFactory( + TestConfiguration.defaultBuilder.clone().allowPipelining(false).build()) + .create() + .block(); + commitTransaction(connection); + MariadbStatement stmt2 = connection.createStatement("DO 1"); + connection.close().block(); + assertThrows( + R2dbcNonTransientResourceException.class, + () -> stmt2.execute().blockLast(), + "Connection is close. Cannot send anything"); + } + + void commitTransaction(MariadbConnection con) { + con.createStatement("DROP TABLE IF EXISTS commitTransaction").execute().blockLast(); + con.createStatement("CREATE TABLE commitTransaction (t1 VARCHAR(256))").execute().blockLast(); + con.setAutoCommit(false).subscribe(); + con.setAutoCommit(false).block(); + con.commitTransaction().block(); // must not do anything + con.createStatement("INSERT INTO commitTransaction VALUES ('a')").execute().blockLast(); + con.commitTransaction().subscribe(); + con.commitTransaction().block(); + con.createStatement("SELECT * FROM commitTransaction") .execute() .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0)))) .as(StepVerifier::create) .expectNext(Optional.of("a")) .verifyComplete(); - sharedConn.createStatement("DROP TABLE IF EXISTS commitTransaction").execute().blockLast(); - sharedConn.setAutoCommit(true).block(); + con.createStatement("DROP TABLE IF EXISTS commitTransaction").execute().blockLast(); + con.setAutoCommit(true).block(); } @Test - void useTransaction() { - sharedConn.createStatement("DROP TABLE IF EXISTS useTransaction").execute().blockLast(); - sharedConn + void useTransaction() throws Exception { + MariadbConnection connection = factory.create().block(); + useTransaction(connection); + MariadbStatement stmt = connection.createStatement("DO 1"); + connection.close().block(); + assertThrows( + R2dbcNonTransientResourceException.class, + () -> stmt.execute().blockLast(), + "Connection is close. Cannot send anything"); + + connection = + new MariadbConnectionFactory( + TestConfiguration.defaultBuilder.clone().allowPipelining(false).build()) + .create() + .block(); + useTransaction(connection); + MariadbStatement stmt2 = connection.createStatement("DO 1"); + connection.close().block(); + assertThrows( + R2dbcNonTransientResourceException.class, + () -> stmt2.execute().blockLast(), + "Connection is close. Cannot send anything"); + } + + void useTransaction(MariadbConnection conn) { + conn.createStatement("DROP TABLE IF EXISTS useTransaction").execute().blockLast(); + conn .createStatement("CREATE TABLE useTransaction (t1 VARCHAR(256))") .execute() .blockLast(); - sharedConn.beginTransaction().block(); - sharedConn.createStatement("INSERT INTO useTransaction VALUES ('a')").execute().blockLast(); - sharedConn.commitTransaction().block(); - sharedConn + conn.beginTransaction().subscribe(); + conn.beginTransaction().block(); + conn.createStatement("INSERT INTO useTransaction VALUES ('a')").execute().blockLast(); + conn.commitTransaction().block(); + conn .createStatement("SELECT * FROM useTransaction") .execute() .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0)))) .as(StepVerifier::create) .expectNext(Optional.of("a")) .verifyComplete(); - sharedConn.createStatement("DROP TABLE IF EXISTS useTransaction").execute().blockLast(); + conn.createStatement("DROP TABLE IF EXISTS useTransaction").execute().blockLast(); + } + + @Test + void wrongSavePoint() { + sharedConn.createStatement("START TRANSACTION").execute().blockLast(); + assertThrows( + Exception.class, + () -> sharedConn.rollbackTransactionToSavepoint("wrong").block(), + "SAVEPOINT wrong does not exist"); + sharedConn.rollbackTransaction().block(); } @Test @@ -714,6 +792,26 @@ public void isolationLevel() { () -> connection.setTransactionIsolationLevel(IsolationLevel.READ_UNCOMMITTED).block()); } + @Test + public void noDb() throws Throwable { + MariadbConnection connection = + new MariadbConnectionFactory( + TestConfiguration.defaultBuilder.clone().database(null).build()) + .create() + .block(); + try { + connection + .createStatement("SELECT DATABASE()") + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, String.class)))) + .as(StepVerifier::create) + .expectNext(Optional.empty()) + .verifyComplete(); + } finally { + connection.close().block(); + } + } + @Test public void initialIsolationLevel() { Assumptions.assumeTrue( @@ -744,7 +842,7 @@ public void errorOnConnection() { .execute() .flatMap(r -> r.map((row, metadata) -> row.get(0, BigInteger.class))) .blockLast(); - Assumptions.assumeTrue(maxConn.intValue() < 200); + Assumptions.assumeTrue(maxConn.intValue() < 600); R2dbcTransientResourceException expected = null; Mono[] cons = new Mono[maxConn.intValue()]; @@ -768,4 +866,42 @@ public void errorOnConnection() { Assertions.assertNotNull(expected); Assertions.assertTrue(expected.getMessage().contains("Too many connections")); } + + @Test + void killedConnection() { + Assumptions.assumeTrue( + !"maxscale".equals(System.getenv("srv")) + && !"skysql".equals(System.getenv("srv")) + && !"skysql-ha".equals(System.getenv("srv"))); + MariadbConnection connection = factory.create().block(); + long threadId = connection.getThreadId(); + + Runnable runnable = + () -> { + try { + Thread.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + sharedConn.createStatement("KILL CONNECTION " + threadId).execute().blockLast(); + }; + Thread thread = new Thread(runnable); + thread.start(); + assertThrows( + R2dbcNonTransientResourceException.class, + () -> + connection + .createStatement( + "select * from information_schema.columns as c1, " + + "information_schema.tables, " + + "information_schema.tables as t2") + .execute() + .blockLast(), + "Connection unexpectedly closed"); + connection + .validate(ValidationDepth.LOCAL) + .as(StepVerifier::create) + .expectNext(Boolean.FALSE) + .verifyComplete(); + } } diff --git a/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java b/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java index 5f23dc0f..98dda54a 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java @@ -91,6 +91,49 @@ public static void after2() { sharedConn.createStatement("DROP TABLE PrepareResultSetTest").execute().blockLast(); } + @Test + void bindWithName() { + assertThrows( + Exception.class, + () -> + sharedConnPrepare + .createStatement("INSERT INTO myTable (a) VALUES (:var1)") + .bind("var1", "test"), + "Cannot use getColumn(name) with prepared statement"); + assertThrows( + Exception.class, + () -> + sharedConnPrepare + .createStatement("INSERT INTO myTable (a) VALUES (:var1)") + .bindNull("var1", String.class), + "Cannot use getColumn(name) with prepared statement"); + } + + @Test + void validateParam() { + sharedConnPrepare + .createStatement("CREATE TEMPORARY TABLE validateParam(t0 VARCHAR(10))") + .execute() + .blockLast(); + Assertions.assertThrows( + Exception.class, + () -> + sharedConnPrepare + .createStatement("INSERT INTO validateParam (t0) VALUES (?)") + .execute() + .flatMap(r -> r.getRowsUpdated()) + .blockLast()); + assertThrows( + Exception.class, + () -> + sharedConnPrepare + .createStatement("INSERT INTO validateParam (t0) VALUES (?)") + .execute() + .flatMap(r -> r.getRowsUpdated()) + .blockLast(), + "Parameter at position 0 is not set"); + } + @Test void parameterLengthEncoded() { Assumptions.assumeTrue(maxAllowedPacket() >= 16 * 1024 * 1024); @@ -118,7 +161,24 @@ void parameterLengthEncoded() { .execute() .blockLast(); sharedConnPrepare - .createStatement("SELECT * FROM parameterLengthEncoded") + .createStatement("SELECT * FROM parameterLengthEncoded WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap( + r -> + r.map( + (row, metadata) -> { + String t0 = row.get(0, String.class); + String t1 = row.get(1, String.class); + Assertions.assertEquals(String.valueOf(arr1024), t0); + Assertions.assertEquals(String.valueOf(arr), t1); + return t0; + })) + .as(StepVerifier::create) + .expectNext(String.valueOf(arr1024)) + .verifyComplete(); + sharedConnPrepare + .createStatement("SELECT * FROM parameterLengthEncoded /* ? */") .execute() .flatMap( r -> @@ -137,7 +197,7 @@ void parameterLengthEncoded() { @Test void parameterLengthEncodedLong() { - Assumptions.assumeTrue(maxAllowedPacket() >= 20 * 1024 * 1024); + Assumptions.assumeTrue(maxAllowedPacket() >= 20 * 1024 * 1024 + 500); // out of memory on travis and 10.1 Assumptions.assumeFalse( "mariadb:10.1".equals(System.getenv("DB")) || "mysql:5.6".equals(System.getenv("DB"))); @@ -380,6 +440,29 @@ void parameterVerification() { IllegalArgumentException.class, () -> stmt.add(), "Parameter at position 0 is not set"); } + @Test + void cannotPrepare() throws Throwable { + // unexpected error "unexpected message received when no command was send: 0x48000002" + Assumptions.assumeTrue( + !"maxscale".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv"))); + MariadbConnectionConfiguration confPipeline = + TestConfiguration.defaultBuilder.clone().useServerPrepStmts(true).build(); + MariadbConnection conn = new MariadbConnectionFactory(confPipeline).create().block(); + try { + assertThrows( + Exception.class, + () -> + conn.createStatement("xa start ?, 'abcdef', 3") + .bind(0, "12") + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0)))) + .blockLast(), + "You have an error in your SQL syntax"); + } finally { + conn.close().block(); + } + } + @Test void parameterNull() { sharedConnPrepare diff --git a/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java b/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java index edc46d9c..ce9a126c 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java @@ -16,7 +16,11 @@ package org.mariadb.r2dbc.integration; +import static org.junit.jupiter.api.Assertions.assertEquals; + import io.r2dbc.spi.R2dbcTransientResourceException; +import java.math.BigInteger; +import java.sql.SQLException; import java.util.Random; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.jupiter.api.Assertions; @@ -126,6 +130,30 @@ public void returning() { .verifyComplete(); } + @Test + public void returningError() { + assertThrows( + Exception.class, + () -> sharedConn.createStatement("CREATE TABLE tt (id int)").returnGeneratedValues("id"), + "Cannot add RETURNING clause to query"); + assertThrows( + Exception.class, + () -> sharedConn.createStatement("CREATE TABLE tt (? int)").returnGeneratedValues("id"), + "Cannot add RETURNING clause to query"); + assertThrows( + Exception.class, + () -> + sharedConn.createStatement("DELETE * FROM tt RETURNING id").returnGeneratedValues("id"), + "Statement already includes RETURNING clause"); + assertThrows( + Exception.class, + () -> + sharedConn + .createStatement("DELETE * FROM tt WHERE id = ? RETURNING id") + .returnGeneratedValues("id"), + "Statement already includes RETURNING clause"); + } + @Test void readResultSet() { String[] first = new String[] {stLen(10), stLen(300), stLen(60000), stLen(1000)}; @@ -223,4 +251,67 @@ void getIndexToLow(MariadbConnection connection) { && throwable.getMessage().equals("Column index -5 must be positive")) .verify(); } + + private String generateLongText(int len) { + int leftLimit = 97; // letter 'a' + int rightLimit = 122; // letter 'z' + Random random = new Random(); + return random + .ints(leftLimit, leftLimit + 1) // rightLimit + 1) + .limit(len) + .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) + .toString(); + } + + @Test + public void skippingRes() throws SQLException { + BigInteger maxAllowedPacket = + sharedConn + .createStatement("select @@max_allowed_packet") + .execute() + .flatMap(r -> r.map((row, metadata) -> row.get(0, BigInteger.class))) + .blockLast(); + Assumptions.assumeTrue(maxAllowedPacket.intValue() > 35_000_000); + sharedConn.createStatement("DROP TABLE IF EXISTS prepare3").execute().blockLast(); + sharedConn + .createStatement( + "CREATE TABLE prepare3 (t1 LONGTEXT, t2 LONGTEXT, t3 LONGTEXT, t4 LONGTEXT, t5 varchar(10))") + .execute() + .blockLast(); + skippingRes(sharedConn); + skippingRes(sharedConnPrepare); + } + + private void skippingRes(MariadbConnection con) { + con.createStatement("TRUNCATE prepare3").execute().blockLast(); + String longText = generateLongText(20_000_000); + String mediumText = generateLongText(10_000_000); + String smallIntText = generateLongText(60_000); + + con.createStatement("INSERT INTO prepare3 values (?,?,?,?,?)") + .bind(0, longText) + .bind(1, mediumText) + .bind(2, smallIntText) + .bind(3, "expected") + .bind(4, "small") + .execute() + .blockLast(); + con.createStatement("SELECT * FROM prepare3 WHERE 1=?") + .bind(0, 1) + .execute() + .flatMap( + r -> + r.map( + (row, metadata) -> { + assertEquals("small", row.get(4)); + assertEquals("expected", row.get(3)); + assertEquals(smallIntText, row.get(2)); + assertEquals(mediumText, row.get(1)); + assertEquals(longText, row.get(0)); + return row.get(3); + })) + .as(StepVerifier::create) + .expectNext("expected") + .verifyComplete(); + } } diff --git a/src/test/java/org/mariadb/r2dbc/integration/RowMetadataTest.java b/src/test/java/org/mariadb/r2dbc/integration/RowMetadataTest.java index a1d37106..2e48d9d2 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/RowMetadataTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/RowMetadataTest.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.mariadb.r2dbc.BaseConnectionTest; +import org.mariadb.r2dbc.TestConfiguration; import org.mariadb.r2dbc.message.server.ColumnDefinitionPacket; import reactor.test.StepVerifier; @@ -97,7 +98,8 @@ void rowMeta() { ColumnDefinitionPacket t1Meta = (ColumnDefinitionPacket) colMeta.getNativeTypeMetadata(); assertEquals( - System.getProperty("TEST_DATABASE", "testr2"), t1Meta.getSchema()); + System.getProperty("TEST_DATABASE", TestConfiguration.database), + t1Meta.getSchema()); assertEquals("t1Alias", t1Meta.getColumnAlias()); assertEquals("t1", t1Meta.getColumn()); assertEquals("rowmeta", t1Meta.getTable()); @@ -132,7 +134,8 @@ void rowMeta() { ColumnDefinitionPacket t2Meta = (ColumnDefinitionPacket) colMeta.getNativeTypeMetadata(); assertEquals( - System.getProperty("TEST_DATABASE", "testr2"), t2Meta.getSchema()); + System.getProperty("TEST_DATABASE", TestConfiguration.database), + t2Meta.getSchema()); assertEquals("t2", t2Meta.getColumnAlias()); assertEquals("t2", t2Meta.getColumn()); assertEquals("rowmeta", t2Meta.getTable()); diff --git a/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java b/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java index e0dbc7e9..810d5d47 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java @@ -267,11 +267,13 @@ void fullValidationFailing() throws Exception { !"skysql".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv"))); Assumptions.assumeTrue(haveSsl(sharedConn)); Assumptions.assumeTrue(serverSslCert != null); - Assumptions.assumeFalse("mariadb.example.com".equals(TestConfiguration.host)); + Assumptions.assumeFalse( + "mariadb.example.com".equals(TestConfiguration.host) || "1".equals(System.getenv("local"))); MariadbConnectionConfiguration conf = TestConfiguration.defaultBuilder .clone() .port(sslPort) + .host("1".equals(System.getenv("local")) ? "127.0.0.1" : TestConfiguration.host) .sslMode(SslMode.VERIFY_FULL) .serverSslCert(serverSslCert) .build(); @@ -315,6 +317,37 @@ void fullValidation() throws Exception { connection.close().block(); } + @Test + void fullValidationCertError() throws Exception { + Assumptions.assumeTrue( + !"skysql".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv"))); + Assumptions.assumeTrue(haveSsl(sharedConn)); + Assumptions.assumeTrue(serverSslCert != null); + Assumptions.assumeTrue( + "mariadb.example.com".equals(TestConfiguration.host) || "1".equals(System.getenv("local"))); + + MariadbConnectionConfiguration conf = + TestConfiguration.defaultBuilder + .clone() + .port(sslPort) + .sslMode(SslMode.VERIFY_FULL) + .host("mariadb2.example.com") + .serverSslCert(serverSslCert) + .build(); + + new MariadbConnectionFactory(conf) + .create() + .as(StepVerifier::create) + .expectErrorMatches( + throwable -> + throwable instanceof R2dbcNonTransientException + && throwable + .getMessage() + .contains( + "SSL hostname verification failed : DNS host \"mariadb2.example.com\" doesn't correspond to certificate CN \"mariadb.example.com")) + .verify(); + } + @Test void fullMutualWithoutClientCerts() throws Exception { Assumptions.assumeTrue( diff --git a/src/test/java/org/mariadb/r2dbc/integration/authentication/Ed25519PluginTest.java b/src/test/java/org/mariadb/r2dbc/integration/authentication/Ed25519PluginTest.java index 5d7906aa..8da50c91 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/authentication/Ed25519PluginTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/authentication/Ed25519PluginTest.java @@ -57,9 +57,9 @@ public static void before2() { } sharedConn .createStatement( - "GRANT SELECT on `" - + TestConfiguration.database - + "`.* to verificationEd25519AuthPlugin") + String.format( + "GRANT SELECT on `%s`.* to verificationEd25519AuthPlugin", + TestConfiguration.database)) .execute() .blockLast(); sharedConn.createStatement("FLUSH PRIVILEGES").execute().blockLast(); @@ -68,15 +68,12 @@ public static void before2() { @AfterAll public static void after2() { - MariadbConnectionMetadata meta = sharedConn.getMetadata(); - if (meta.isMariaDBServer() && meta.minVersion(10, 2, 0)) { - sharedConn - .createStatement("DROP USER verificationEd25519AuthPlugin") - .execute() - .map(res -> res.getRowsUpdated()) - .onErrorReturn(Mono.empty()) - .blockLast(); - } + sharedConn + .createStatement("DROP USER IF EXISTS verificationEd25519AuthPlugin") + .execute() + .map(res -> res.getRowsUpdated()) + .onErrorReturn(Mono.empty()) + .blockLast(); } @Test @@ -96,40 +93,41 @@ public void verificationEd25519AuthPlugin() throws Throwable { connection.close(); } - @Test public void multiAuthPlugin() throws Throwable { Assumptions.assumeTrue( - !"maxscale".equals(System.getenv("srv")) - && !"skysql".equals(System.getenv("srv")) - && !"skysql-ha".equals(System.getenv("srv"))); + !"maxscale".equals(System.getenv("srv")) + && !"skysql".equals(System.getenv("srv")) + && !"skysql-ha".equals(System.getenv("srv"))); Assumptions.assumeTrue(isMariaDBServer() && minVersion(10, 4, 2)); sharedConn.createStatement("drop user IF EXISTS mysqltest1").execute().blockLast(); - sharedConn.createStatement( + sharedConn + .createStatement( "CREATE USER mysqltest1 IDENTIFIED " - + "VIA ed25519 as password('!Passw0rd3') " - + " OR mysql_native_password as password('!Passw0rd3Works')").execute().blockLast(); + + "VIA ed25519 as password('!Passw0rd3') " + + " OR mysql_native_password as password('!Passw0rd3Works')") + .execute() + .blockLast(); sharedConn.createStatement("GRANT SELECT on *.* to mysqltest1").execute().blockLast(); MariadbConnectionConfiguration conf = - TestConfiguration.defaultBuilder - .clone() - .username("mysqltest1") - .password("!Passw0rd3") - .build(); + TestConfiguration.defaultBuilder + .clone() + .username("mysqltest1") + .password("!Passw0rd3") + .build(); MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); connection.close().block(); conf = - TestConfiguration.defaultBuilder - .clone() - .username("mysqltest1") - .password("!Passw0rd3Works") - .build(); + TestConfiguration.defaultBuilder + .clone() + .username("mysqltest1") + .password("!Passw0rd3Works") + .build(); connection = new MariadbConnectionFactory(conf).create().block(); connection.close().block(); sharedConn.createStatement("drop user mysqltest1@'%'").execute().blockLast(); } - } diff --git a/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java b/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java index 1fd4bb00..102c291e 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java @@ -99,53 +99,71 @@ public static void init() throws Exception { String sqlGrant; String sqlCreateUser2; String sqlGrant2; + String sqlCreateUser3; + String sqlGrant3; + if (minVersion(8, 0, 0)) { - sqlCreateUser = - "CREATE USER 'sha256User'@'%' IDENTIFIED WITH sha256_password BY 'password'"; - sqlGrant = "GRANT ALL PRIVILEGES ON *.* TO 'sha256User'@'%'"; - sqlCreateUser2 = - "CREATE USER 'sha256User2'@'%' IDENTIFIED WITH sha256_password BY 'password'"; - sqlGrant2 = "GRANT ALL PRIVILEGES ON *.* TO 'sha256User2'@'%'"; + sqlCreateUser = "CREATE USER 'sha256User' IDENTIFIED WITH sha256_password BY 'password'"; + sqlGrant = "GRANT ALL PRIVILEGES ON *.* TO 'sha256User'"; + sqlCreateUser2 = "CREATE USER 'sha256User2' IDENTIFIED WITH sha256_password BY 'password'"; + sqlGrant2 = "GRANT ALL PRIVILEGES ON *.* TO 'sha256User2'"; + sqlCreateUser3 = "CREATE USER 'sha256User3' IDENTIFIED WITH sha256_password BY ''"; + sqlGrant3 = "GRANT ALL PRIVILEGES ON *.* TO 'sha256User3'"; } else { - sqlCreateUser = "CREATE USER 'sha256User'@'%'"; + sqlCreateUser = "CREATE USER 'sha256User'"; sqlGrant = - "GRANT ALL PRIVILEGES ON *.* TO 'sha256User'@'%' IDENTIFIED WITH " + "GRANT ALL PRIVILEGES ON *.* TO 'sha256User' IDENTIFIED WITH " + "sha256_password BY 'password'"; - sqlCreateUser2 = "CREATE USER 'sha256User2'@'%'"; + sqlCreateUser2 = "CREATE USER 'sha256User2'"; sqlGrant2 = - "GRANT ALL PRIVILEGES ON *.* TO 'sha256User2'@'%' IDENTIFIED WITH " + "GRANT ALL PRIVILEGES ON *.* TO 'sha256User2' IDENTIFIED WITH " + "sha256_password BY 'password'"; + sqlCreateUser3 = "CREATE USER 'sha256User3'"; + sqlGrant3 = + "GRANT ALL PRIVILEGES ON *.* TO 'sha256User3' IDENTIFIED WITH " + + "sha256_password BY ''"; } sharedConn.createStatement(sqlCreateUser).execute().blockLast(); sharedConn.createStatement(sqlGrant).execute().blockLast(); sharedConn.createStatement(sqlCreateUser2).execute().blockLast(); sharedConn.createStatement(sqlGrant2).execute().blockLast(); + sharedConn.createStatement(sqlCreateUser3).execute().blockLast(); + sharedConn.createStatement(sqlGrant3).execute().blockLast(); if (minVersion(8, 0, 0)) { sharedConn .createStatement( - "CREATE USER 'cachingSha256User'@'%' IDENTIFIED WITH caching_sha2_password BY 'password'") + "CREATE USER 'cachingSha256User' IDENTIFIED WITH caching_sha2_password BY 'password'") + .execute() + .blockLast(); + sharedConn + .createStatement("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User'") + .execute() + .blockLast(); + sharedConn + .createStatement( + "CREATE USER 'cachingSha256User2' IDENTIFIED WITH caching_sha2_password BY 'password'") .execute() .blockLast(); sharedConn - .createStatement("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User'@'%'") + .createStatement("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User2'") .execute() .blockLast(); sharedConn .createStatement( - "CREATE USER 'cachingSha256User2'@'%' IDENTIFIED WITH caching_sha2_password BY 'password'") + "CREATE USER 'cachingSha256User3' IDENTIFIED WITH caching_sha2_password BY 'password'") .execute() .blockLast(); sharedConn - .createStatement("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User2'@'%'") + .createStatement("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User3'") .execute() .blockLast(); sharedConn .createStatement( - "CREATE USER 'cachingSha256User3'@'%' IDENTIFIED WITH caching_sha2_password BY 'password'") + "CREATE USER 'cachingSha256User4' IDENTIFIED WITH caching_sha2_password BY ''") .execute() .blockLast(); sharedConn - .createStatement("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User3'@'%'") + .createStatement("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User4'") .execute() .blockLast(); } @@ -167,6 +185,12 @@ public static void dropAll() { .map(res -> res.getRowsUpdated()) .onErrorReturn(Mono.empty()) .blockLast(); + sharedConn + .createStatement("DROP USER sha256User3") + .execute() + .map(res -> res.getRowsUpdated()) + .onErrorReturn(Mono.empty()) + .blockLast(); sharedConn .createStatement("DROP USER cachingSha256User") .execute() @@ -185,6 +209,12 @@ public static void dropAll() { .map(res -> res.getRowsUpdated()) .onErrorReturn(Mono.empty()) .blockLast(); + sharedConn + .createStatement("DROP USER cachingSha256User4") + .execute() + .map(res -> res.getRowsUpdated()) + .onErrorReturn(Mono.empty()) + .blockLast(); } @Test @@ -203,6 +233,23 @@ public void sha256PluginTestWithServerRsaKey() throws Exception { connection.close().block(); } + @Test + public void sha256PluginTestWrongServerRsaKey() throws Exception { + Assumptions.assumeTrue(!isWindows && !isMariaDBServer() && minVersion(5, 7, 0)); + + MariadbConnectionConfiguration conf = + TestConfiguration.defaultBuilder + .clone() + .username("sha256User") + .password("password") + .rsaPublicKey("/wrongPath") + .build(); + assertThrows( + Exception.class, + () -> new MariadbConnectionFactory(conf).create().block(), + "Could not read server RSA public key from file"); + } + @Test public void sha256PluginTestWithoutServerRsaKey() throws Exception { Assumptions.assumeTrue(!isWindows && !isMariaDBServer() && minVersion(8, 0, 0)); @@ -255,6 +302,20 @@ public void sha256PluginTestSsl() throws Exception { connection.close().block(); } + @Test + public void sha256PluginTestSslNoPwd() throws Exception { + Assumptions.assumeTrue(haveSsl(sharedConn)); + MariadbConnectionConfiguration conf = + TestConfiguration.defaultBuilder + .clone() + .username("sha256User3") + .password(null) + .sslMode(SslMode.TRUST) + .build(); + MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); + connection.close().block(); + } + @Test public void cachingSha256PluginTestWithServerRsaKey() throws Exception { Assumptions.assumeTrue( @@ -284,15 +345,6 @@ public void cachingSha256PluginTestWithoutServerRsaKey() throws Exception { .build(); MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); connection.close().block(); - // - // MariadbConnectionConfiguration conf2 = - // TestConfiguration.defaultBuilder - // .clone() - // .username("cachingSha256User") - // .password("password") - // .build(); - // MariadbConnection connection2 = new MariadbConnectionFactory(conf2).create().block(); - // connection2.close().block(); } @Test @@ -334,4 +386,22 @@ public void cachingSha256PluginTestSsl() throws Exception { MariadbConnection connection3 = new MariadbConnectionFactory(conf).create().block(); connection3.close().block(); } + + @Test + public void cachingSha256PluginTestNoPwd() throws Exception { + Assumptions.assumeTrue(!isMariaDBServer() && minVersion(8, 0, 0)); + Assumptions.assumeTrue(haveSsl(sharedConn)); + + MariadbConnectionConfiguration conf = + TestConfiguration.defaultBuilder + .clone() + .username("cachingSha256User4") + .password(null) + .sslMode(SslMode.TRUST) + .build(); + MariadbConnection connection = new MariadbConnectionFactory(conf).create().block(); + connection.close().block(); + MariadbConnection connection3 = new MariadbConnectionFactory(conf).create().block(); + connection3.close().block(); + } } diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/BigIntegerParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/BigIntegerParseTest.java index 80b5874f..5e15ad05 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/BigIntegerParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/BigIntegerParseTest.java @@ -130,6 +130,17 @@ private void booleanValue(MariadbConnection connection) { .verifyComplete(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM BigIntTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void byteArrayValue() { byteArrayValue(sharedConn); diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/BitParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/BitParseTest.java index bbc82a58..e349a526 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/BitParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/BitParseTest.java @@ -398,6 +398,17 @@ private void doubleValue(MariadbConnection connection) { .verify(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM BitTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void stringValue() { stringValue(sharedConn); diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/BlobParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/BlobParseTest.java index 043ecaa4..7e6cd99e 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/BlobParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/BlobParseTest.java @@ -206,6 +206,17 @@ private void byteValue(MariadbConnection connection) { .verify(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM BlobTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void shortValue() { shortValue(sharedConn); diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java index 47f3b790..454687e3 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java @@ -171,6 +171,17 @@ private void booleanValue(MariadbConnection connection) { .verify(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM DateTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void byteArrayValue() { byteArrayValue(sharedConn); diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/DateTimeParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/DateTimeParseTest.java index d4aa731b..a217cae2 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/DateTimeParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/DateTimeParseTest.java @@ -24,6 +24,7 @@ import java.time.LocalTime; import java.util.Optional; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.mariadb.r2dbc.BaseConnectionTest; @@ -33,13 +34,14 @@ public class DateTimeParseTest extends BaseConnectionTest { @BeforeAll public static void before2() { + Assumptions.assumeTrue(isMariaDBServer()); sharedConn .createStatement("CREATE TABLE DateTimeTable (t1 DATETIME(6) NULL)") .execute() .blockLast(); sharedConn .createStatement( - "INSERT INTO DateTimeTable VALUES('2013-07-22 12:50:05.01230'), ('2035-01-31 10:45:01'), (null)") + "INSERT INTO DateTimeTable VALUES('2013-07-22 12:50:05.01230'), ('2035-01-31 10:45:01'), (null), (0), ('2021-01-01')") .execute() .blockLast(); sharedConn.createStatement("FLUSH TABLES").execute().blockLast(); @@ -50,6 +52,17 @@ public static void afterAll2() { sharedConn.createStatement("DROP TABLE DateTimeTable").execute().blockLast(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM DateTimeTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void defaultValue() { defaultValue(sharedConn); @@ -70,7 +83,9 @@ private void defaultValue(MariadbConnection connection) { .expectNext( Optional.of(LocalDateTime.parse("2013-07-22T12:50:05.01230")), Optional.of(LocalDateTime.parse("2035-01-31T10:45:01")), - Optional.empty()) + Optional.empty(), + Optional.empty(), + Optional.of(LocalDateTime.parse("2021-01-01T00:00:00"))) .verifyComplete(); } @@ -94,7 +109,9 @@ private void localDateValue(MariadbConnection connection) { .expectNext( Optional.of(LocalDate.parse("2013-07-22")), Optional.of(LocalDate.parse("2035-01-31")), - Optional.empty()) + Optional.empty(), + Optional.empty(), + Optional.of(LocalDate.parse("2021-01-01"))) .verifyComplete(); } @@ -118,7 +135,9 @@ private void localTimeValue(MariadbConnection connection) { .expectNext( Optional.of(LocalTime.parse("12:50:05.012300")), Optional.of(LocalTime.parse("10:45:01")), - Optional.empty()) + Optional.empty(), + Optional.empty(), + Optional.of(LocalTime.parse("00:00"))) .verifyComplete(); } @@ -362,7 +381,9 @@ void stringValue() { sharedConn, Optional.of("2013-07-22 12:50:05.012300"), Optional.of("2035-01-31 10:45:01.000000"), - Optional.empty()); + Optional.empty(), + Optional.of("0000-00-00 00:00:00.000000"), + Optional.of("2021-01-01 00:00:00.000000")); } @Test @@ -371,18 +392,25 @@ void stringValuePrepare() { sharedConnPrepare, Optional.of("2013-07-22 12:50:05.012300"), Optional.of("2035-01-31 10:45:01"), - Optional.empty()); + Optional.empty(), + Optional.empty(), + Optional.of("2021-01-01 00:00")); } private void stringValue( - MariadbConnection connection, Optional t1, Optional t2, Optional t3) { + MariadbConnection connection, + Optional t1, + Optional t2, + Optional t3, + Optional t4, + Optional t5) { connection .createStatement("SELECT t1 FROM DateTimeTable WHERE 1 = ?") .bind(0, 1) .execute() .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, String.class)))) .as(StepVerifier::create) - .expectNext(t1, t2, t3) + .expectNext(t1, t2, t3, t4, t5) .verifyComplete(); } @@ -461,7 +489,9 @@ private void localDateTimeValue(MariadbConnection connection) { .expectNext( Optional.of(LocalDateTime.parse("2013-07-22T12:50:05.01230")), Optional.of(LocalDateTime.parse("2035-01-31T10:45:01")), - Optional.empty()) + Optional.empty(), + Optional.empty(), + Optional.of(LocalDateTime.parse("2021-01-01T00:00:00"))) .verifyComplete(); } diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/DecimalParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/DecimalParseTest.java index b907290c..6d70f452 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/DecimalParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/DecimalParseTest.java @@ -50,6 +50,17 @@ public static void afterAll2() { sharedConn.createStatement("DROP TABLE DecimalTable").execute().blockLast(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM DecimalTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void defaultValue() { defaultValue(sharedConn); diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/DoubleParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/DoubleParseTest.java index 55f914aa..d824861d 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/DoubleParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/DoubleParseTest.java @@ -45,6 +45,17 @@ public static void afterAll2() { sharedConn.createStatement("DROP TABLE DoubleTable").execute().blockLast(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM DoubleTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void defaultValue() { defaultValue(sharedConn); diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/FloatParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/FloatParseTest.java index 5aec9de1..9eca924b 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/FloatParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/FloatParseTest.java @@ -45,6 +45,17 @@ public static void afterAll2() { sharedConn.createStatement("DROP TABLE FloatTable").execute().blockLast(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM FloatTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void defaultValue() { defaultValue(sharedConn); diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/IntParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/IntParseTest.java index 5c44de19..9e4070fe 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/IntParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/IntParseTest.java @@ -58,6 +58,17 @@ public static void afterAll2() { sharedConn.createStatement("DROP TABLE IntUnsignedTable").execute().blockLast(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM IntTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void defaultValue() { defaultValue(sharedConn); diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/MediumIntParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/MediumIntParseTest.java index 1731266b..3adee4e1 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/MediumIntParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/MediumIntParseTest.java @@ -56,6 +56,17 @@ public static void afterAll2() { sharedConn.createStatement("DROP TABLE MediumIntUnsignedTable").execute().blockLast(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM MediumIntTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void defaultValue() { defaultValue(sharedConn); diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/ShortParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/ShortParseTest.java index 04e54ebd..c3788869 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/ShortParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/ShortParseTest.java @@ -56,6 +56,17 @@ public static void afterAll2() { sharedConn.createStatement("DROP TABLE ShortUnsignedTable").execute().blockLast(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM ShortTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void defaultValue() { defaultValue(sharedConn); diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/StringParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/StringParseTest.java index 208ad7f6..6b626d40 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/StringParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/StringParseTest.java @@ -62,6 +62,26 @@ public static void afterAll2() { sharedConn.createStatement("DROP TABLE IF EXISTS localDateTimeValue").execute().blockLast(); } + @Test + void wrongType() { + wrongType(sharedConn); + } + + @Test + void wrongTypePrepare() { + wrongType(sharedConnPrepare); + } + + private void wrongType(MariadbConnection connection) { + connection + .createStatement("SELECT t1 FROM StringTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void defaultValue() { defaultValue(sharedConn); @@ -81,6 +101,14 @@ private void defaultValue(MariadbConnection connection) { .as(StepVerifier::create) .expectNext(Optional.of("some🌟"), Optional.of("1"), Optional.of("0"), Optional.empty()) .verifyComplete(); + connection + .createStatement("SELECT t1 FROM StringTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, Object.class)))) + .as(StepVerifier::create) + .expectNext(Optional.of("some🌟"), Optional.of("1"), Optional.of("0"), Optional.empty()) + .verifyComplete(); } @Test diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java index 45851f1e..8ec47764 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java @@ -41,7 +41,7 @@ public static void before2() { sharedConn .createStatement( "INSERT INTO TimeParseTest VALUES ('90:00:00.012340', '-10:01:02.012340'), ('800:00:00.123', '-00:00:10" - + ".123'), (800, -800), " + + ".123'), (800, 0), " + "(22, -22)" + ", (null, null)") .execute() @@ -54,6 +54,17 @@ public static void afterAll2() { sharedConn.createStatement("DROP TABLE TimeParseTest").execute().blockLast(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM TimeParseTest WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void defaultValue() { defaultValue(sharedConn); @@ -87,7 +98,7 @@ private void defaultValue(MariadbConnection connection) { .expectNext( Optional.of(Duration.parse("PT-10H-1M-2.01234S")), Optional.of(Duration.parse("PT-10.123S")), - Optional.of(Duration.parse("PT-8M")), + Optional.of(Duration.parse("PT0M")), Optional.of(Duration.parse("PT-22S")), Optional.empty()) .verifyComplete(); @@ -152,7 +163,7 @@ private void localTimeValue(MariadbConnection connection) { .expectNext( Optional.of(LocalTime.parse("13:58:57.987660")), Optional.of(LocalTime.parse("23:59:49.877")), - Optional.of(LocalTime.parse("23:52")), + Optional.of(LocalTime.parse("00:00")), Optional.of(LocalTime.parse("23:59:38")), Optional.empty()) .verifyComplete(); diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/TimestampParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/TimestampParseTest.java index a910afa6..82fccc6e 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/TimestampParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/TimestampParseTest.java @@ -61,6 +61,17 @@ public static void afterAll2() { sharedConn.createStatement("DROP TABLE TimestampTable2").execute().blockLast(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM TimestampTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void defaultValue() { defaultValue(sharedConn); diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/TinyIntParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/TinyIntParseTest.java index ef1a2d0f..67b6e2d9 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/TinyIntParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/TinyIntParseTest.java @@ -65,6 +65,17 @@ public static void afterAll2() { sharedConn.createStatement("DROP TABLE tinyIntTable1").execute().blockLast(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM tinyIntTable1 WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void defaultValue() { defaultValue(sharedConn); diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/YearParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/YearParseTest.java index a5aa4d38..7b9d9b2b 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/YearParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/YearParseTest.java @@ -54,6 +54,17 @@ public static void afterAll2() { sharedConn.createStatement("DROP TABLE YearTable").execute().blockLast(); } + @Test + void wrongType() { + sharedConn + .createStatement("SELECT t1 FROM YearTable WHERE 1 = ?") + .bind(0, 1) + .execute() + .flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0, this.getClass())))) + .as(StepVerifier::create) + .expectError(); + } + @Test void defaultValue() { defaultValue(sharedConn); diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeParameterTest.java index 075c1543..4d9a2979 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeParameterTest.java @@ -38,9 +38,9 @@ public class TimeParameterTest extends BaseConnectionTest { @BeforeAll public static void before2() { sharedConn - .createStatement("CREATE TABLE TimeParam (t1 TIME(6), t2 TIME(6), t3 TIME(6))") - .execute() - .blockLast(); + .createStatement("CREATE TABLE TimeParam (t1 TIME(6), t2 TIME(6), t3 TIME(6))") + .execute() + .blockLast(); } @AfterAll @@ -65,12 +65,12 @@ void nullValuePrepare() { private void nullValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bindNull(0, LocalTime.class) - .bindNull(1, LocalTime.class) - .bindNull(2, LocalTime.class) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bindNull(0, LocalTime.class) + .bindNull(1, LocalTime.class) + .bindNull(2, LocalTime.class) + .execute() + .blockLast(); validate(Optional.empty(), Optional.empty(), Optional.empty()); } @@ -86,23 +86,23 @@ void bigIntValuePrepare() { private void bigIntValue(MariadbConnection connection) { Flux f = - connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, BigInteger.ONE) - .bind(1, new BigInteger("9223372036854775807")) - .bind(2, new BigInteger("-9")) - .execute(); + connection + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, BigInteger.ONE) + .bind(1, new BigInteger("9223372036854775807")) + .bind(2, new BigInteger("-9")) + .execute(); if ((isMariaDBServer() && !minVersion(10, 2, 0)) - || (!isMariaDBServer() && !minVersion(5, 7, 0))) { + || (!isMariaDBServer() && !minVersion(5, 7, 0))) { f.blockLast(); } else { f.flatMap(r -> r.getRowsUpdated()) - .as(StepVerifier::create) - .expectErrorMatches( - throwable -> - throwable instanceof R2dbcBadGrammarException - && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) - .verify(); + .as(StepVerifier::create) + .expectErrorMatches( + throwable -> + throwable instanceof R2dbcBadGrammarException + && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) + .verify(); } } @@ -118,23 +118,23 @@ void stringValuePrepare() { private void stringValue(MariadbConnection connection) { Flux f = - connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, "1") - .bind(1, "9223372036854775807") - .bind(2, "-9") - .execute(); + connection + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, "1") + .bind(1, "9223372036854775807") + .bind(2, "-9") + .execute(); if ((isMariaDBServer() && !minVersion(10, 2, 0)) - || (!isMariaDBServer() && !minVersion(5, 7, 0))) { + || (!isMariaDBServer() && !minVersion(5, 7, 0))) { f.blockLast(); } else { f.flatMap(r -> r.getRowsUpdated()) - .as(StepVerifier::create) - .expectErrorMatches( - throwable -> - throwable instanceof R2dbcBadGrammarException - && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) - .verify(); + .as(StepVerifier::create) + .expectErrorMatches( + throwable -> + throwable instanceof R2dbcBadGrammarException + && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) + .verify(); } } @@ -150,23 +150,23 @@ void decimalValuePrepare() { private void decimalValue(MariadbConnection connection) { Flux f = - connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, BigDecimal.ONE) - .bind(1, new BigDecimal("9223372036854775807")) - .bind(2, new BigDecimal("-9")) - .execute(); + connection + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, BigDecimal.ONE) + .bind(1, new BigDecimal("9223372036854775807")) + .bind(2, new BigDecimal("-9")) + .execute(); if ((isMariaDBServer() && !minVersion(10, 2, 0)) - || (!isMariaDBServer() && !minVersion(5, 7, 0))) { + || (!isMariaDBServer() && !minVersion(5, 7, 0))) { f.blockLast(); } else { f.flatMap(r -> r.getRowsUpdated()) - .as(StepVerifier::create) - .expectErrorMatches( - throwable -> - throwable instanceof R2dbcBadGrammarException - && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) - .verify(); + .as(StepVerifier::create) + .expectErrorMatches( + throwable -> + throwable instanceof R2dbcBadGrammarException + && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) + .verify(); } } @@ -182,16 +182,16 @@ void intValuePrepare() { private void intValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, 1) - .bind(1, -1) - .bind(2, 0) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, 1) + .bind(1, -1) + .bind(2, 0) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT1S")), - Optional.of(Duration.parse("PT-1S")), - Optional.of(Duration.parse("PT0M"))); + Optional.of(Duration.parse("PT1S")), + Optional.of(Duration.parse("PT-1S")), + Optional.of(Duration.parse("PT0M"))); } @Test @@ -206,16 +206,16 @@ void byteValuePrepare() { private void byteValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, (byte) 127) - .bind(1, (byte) -128) - .bind(2, (byte) 0) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, (byte) 127) + .bind(1, (byte) -128) + .bind(2, (byte) 0) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT1M27S")), - Optional.of(Duration.parse("PT-1M-28S")), - Optional.of(Duration.parse("PT0M"))); + Optional.of(Duration.parse("PT1M27S")), + Optional.of(Duration.parse("PT-1M-28S")), + Optional.of(Duration.parse("PT0M"))); } @Test @@ -230,16 +230,16 @@ void floatValuePrepare() { private void floatValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, 127f) - .bind(1, -128f) - .bind(2, 0f) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, 127f) + .bind(1, -128f) + .bind(2, 0f) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT1M27S")), - Optional.of(Duration.parse("PT-1M-28S")), - Optional.of(Duration.parse("PT0M"))); + Optional.of(Duration.parse("PT1M27S")), + Optional.of(Duration.parse("PT-1M-28S")), + Optional.of(Duration.parse("PT0M"))); } @Test @@ -254,16 +254,16 @@ void doubleValuePrepare() { private void doubleValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, 127d) - .bind(1, 128d) - .bind(2, 0d) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, 127d) + .bind(1, 128d) + .bind(2, 0d) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT1M27S")), - Optional.of(Duration.parse("PT1M28S")), - Optional.of(Duration.parse("PT0M"))); + Optional.of(Duration.parse("PT1M27S")), + Optional.of(Duration.parse("PT1M28S")), + Optional.of(Duration.parse("PT0M"))); } @Test @@ -278,16 +278,16 @@ void shortValuePrepare() { private void shortValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, Short.valueOf("1")) - .bind(1, Short.valueOf("-1")) - .bind(2, Short.valueOf("0")) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, Short.valueOf("1")) + .bind(1, Short.valueOf("-1")) + .bind(2, Short.valueOf("0")) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT1S")), - Optional.of(Duration.parse("PT-1S")), - Optional.of(Duration.parse("PT0M"))); + Optional.of(Duration.parse("PT1S")), + Optional.of(Duration.parse("PT-1S")), + Optional.of(Duration.parse("PT0M"))); } @Test @@ -302,16 +302,16 @@ void longValuePrepare() { private void longValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, Long.valueOf("1")) - .bind(1, Long.valueOf("-1")) - .bind(2, Long.valueOf("0")) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, Long.valueOf("1")) + .bind(1, Long.valueOf("-1")) + .bind(2, Long.valueOf("0")) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT1S")), - Optional.of(Duration.parse("PT-1S")), - Optional.of(Duration.parse("PT0M"))); + Optional.of(Duration.parse("PT1S")), + Optional.of(Duration.parse("PT-1S")), + Optional.of(Duration.parse("PT0M"))); } @Test @@ -326,16 +326,16 @@ void localDateTimeValuePrepare() { private void localDateTimeValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, LocalDateTime.parse("2010-01-12T05:08:09.0014")) - .bind(1, LocalDateTime.parse("2018-12-15T05:08:10.123456")) - .bind(2, LocalDateTime.parse("2025-05-12T05:08:11.123")) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, LocalDateTime.parse("2010-01-12T05:08:09.0014")) + .bind(1, LocalDateTime.parse("2018-12-15T05:08:10.123456")) + .bind(2, LocalDateTime.parse("2025-05-12T05:08:11.123")) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT5H8M9.0014S")), - Optional.of(Duration.parse("PT5H8M10.123456S")), - Optional.of(Duration.parse("PT5H8M11.123S"))); + Optional.of(Duration.parse("PT5H8M9.0014S")), + Optional.of(Duration.parse("PT5H8M10.123456S")), + Optional.of(Duration.parse("PT5H8M11.123S"))); } @Test @@ -346,43 +346,43 @@ void localDateValue() { @Test void localDateValuePrepare() { sharedConnPrepare - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, LocalDate.parse("2010-01-12")) - .bind(1, LocalDate.parse("2018-12-15")) - .bind(2, LocalDate.parse("2025-05-12")) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, LocalDate.parse("2010-01-12")) + .bind(1, LocalDate.parse("2018-12-15")) + .bind(2, LocalDate.parse("2025-05-12")) + .execute() + .blockLast(); sharedConn - .createStatement("SELECT * FROM TimeParam") - .execute() - .flatMap( - r -> - r.map( - (row, metadata) -> - Flux.just( - row.get(0, String.class), - row.get(1, String.class), - row.get(2, String.class)))) - .blockLast() - .as(StepVerifier::create) - .expectNext("00:00:00.000000", "00:00:00.000000", "00:00:00.000000") - .verifyComplete(); + .createStatement("SELECT * FROM TimeParam") + .execute() + .flatMap( + r -> + r.map( + (row, metadata) -> + Flux.just( + row.get(0, String.class), + row.get(1, String.class), + row.get(2, String.class)))) + .blockLast() + .as(StepVerifier::create) + .expectNext("00:00:00.000000", "00:00:00.000000", "00:00:00.000000") + .verifyComplete(); } private void localDateValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, LocalDate.parse("2010-01-12")) - .bind(1, LocalDate.parse("2018-12-15")) - .bind(2, LocalDate.parse("2025-05-12")) - .execute() - .flatMap(r -> r.getRowsUpdated()) - .as(StepVerifier::create) - .expectErrorMatches( - throwable -> - throwable instanceof R2dbcBadGrammarException - && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) - .verify(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, LocalDate.parse("2010-01-12")) + .bind(1, LocalDate.parse("2018-12-15")) + .bind(2, LocalDate.parse("2025-05-12")) + .execute() + .flatMap(r -> r.getRowsUpdated()) + .as(StepVerifier::create) + .expectErrorMatches( + throwable -> + throwable instanceof R2dbcBadGrammarException + && ((R2dbcBadGrammarException) throwable).getSqlState().equals("22007")) + .verify(); } @Test @@ -399,34 +399,34 @@ void durationValuePrepare() { private void durationValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, Duration.parse("PT5H8M9.0014S")) - .bind(1, Duration.parse("PT-5H8M10S")) - .bind(2, Duration.parse("PT5H8M11.123S")) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, Duration.parse("PT5H8M9.0014S")) + .bind(1, Duration.parse("PT-5H8M10S")) + .bind(2, Duration.parse("PT5H8M11.123S")) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT5H8M9.0014S")), - Optional.of(Duration.parse("PT-5H8M10S")), - Optional.of(Duration.parse("PT5H8M11.123S"))); + Optional.of(Duration.parse("PT5H8M9.0014S")), + Optional.of(Duration.parse("PT-5H8M10S")), + Optional.of(Duration.parse("PT5H8M11.123S"))); } private void durationValue2(MariadbConnection connection) { - connection - .createStatement("TRUNCATE TABLE TimeParam").execute().blockLast(); + connection.createStatement("TRUNCATE TABLE TimeParam").execute().blockLast(); connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, Duration.parse("PT0S")) - .bind(1, Duration.parse("PT-1.123S")) - .bind(2, Duration.parse("PT-5H8M11.123S")) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, Duration.parse("PT0S")) + .bind(1, Duration.parse("PT-1.123S")) + .bind(2, Duration.parse("PT-5H8M11.123S")) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT0S")), - Optional.of(Duration.parse("PT-1.123S")), - Optional.of(Duration.parse("PT-5H8M11.123S"))); + Optional.of(Duration.parse("PT0S")), + Optional.of(Duration.parse("PT-1.123S")), + Optional.of(Duration.parse("PT-5H8M11.123S"))); } + @Test void localTimeValue() { localTimeValue(sharedConn); @@ -439,33 +439,33 @@ void localTimeValuePrepare() { private void localTimeValue(MariadbConnection connection) { connection - .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") - .bind(0, LocalTime.parse("05:08:09.0014")) - .bind(1, LocalTime.parse("05:08:10")) - .bind(2, LocalTime.parse("05:08:11.123")) - .execute() - .blockLast(); + .createStatement("INSERT INTO TimeParam VALUES (?,?,?)") + .bind(0, LocalTime.parse("05:08:09.0014")) + .bind(1, LocalTime.parse("05:08:10")) + .bind(2, LocalTime.parse("05:08:11.123")) + .execute() + .blockLast(); validate( - Optional.of(Duration.parse("PT5H8M9.0014S")), - Optional.of(Duration.parse("PT5H8M10S")), - Optional.of(Duration.parse("PT5H8M11.123S"))); + Optional.of(Duration.parse("PT5H8M9.0014S")), + Optional.of(Duration.parse("PT5H8M10S")), + Optional.of(Duration.parse("PT5H8M11.123S"))); } private void validate(Optional t1, Optional t2, Optional t3) { sharedConn - .createStatement("SELECT * FROM TimeParam") - .execute() - .flatMap( - r -> - r.map( - (row, metadata) -> - Flux.just( - Optional.ofNullable((Duration) row.get(0)), - Optional.ofNullable(row.get(1)), - Optional.ofNullable(row.get(2))))) - .blockLast() - .as(StepVerifier::create) - .expectNext(t1, t2, t3) - .verifyComplete(); + .createStatement("SELECT * FROM TimeParam") + .execute() + .flatMap( + r -> + r.map( + (row, metadata) -> + Flux.just( + Optional.ofNullable((Duration) row.get(0)), + Optional.ofNullable(row.get(1)), + Optional.ofNullable(row.get(2))))) + .blockLast() + .as(StepVerifier::create) + .expectNext(t1, t2, t3) + .verifyComplete(); } } diff --git a/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java b/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java index abf72cca..c1064a71 100644 --- a/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java +++ b/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java @@ -2,11 +2,16 @@ import org.junit.jupiter.api.Test; import org.mariadb.r2dbc.codec.Codecs; +import org.mariadb.r2dbc.util.BufferUtils; +import org.mariadb.r2dbc.util.PidFactory; public class InitFinalClass { @Test public void init() throws Exception { Codecs codecs = new Codecs(); + BufferUtils buf = new BufferUtils(); + PidFactory pid = new PidFactory(); + System.out.println(codecs.hashCode() + buf.hashCode() + pid.hashCode()); } } diff --git a/src/test/java/org/mariadb/r2dbc/unit/client/HostnameVerifierTest.java b/src/test/java/org/mariadb/r2dbc/unit/client/HostnameVerifierTest.java new file mode 100644 index 00000000..67d5b799 --- /dev/null +++ b/src/test/java/org/mariadb/r2dbc/unit/client/HostnameVerifierTest.java @@ -0,0 +1,534 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (c) 2012-2014 Monty Program Ab +// Copyright (c) 2015-2021 MariaDB Corporation Ab + +package org.mariadb.r2dbc.unit.client; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.ByteArrayInputStream; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import javax.net.ssl.SSLException; +import javax.security.auth.x500.X500Principal; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mariadb.r2dbc.util.DefaultHostnameVerifier; + +public class HostnameVerifierTest { + + private static X509Certificate getCertificate(String certString) throws CertificateException { + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + return (X509Certificate) + cf.generateCertificate(new ByteArrayInputStream(certString.getBytes())); + } + + private void verifyExceptionEqual(String host, X509Certificate cert, String exceptionMessage) { + Exception e = + Assertions.assertThrows( + SSLException.class, () -> DefaultHostnameVerifier.verify(host, cert, -1)); + Assertions.assertTrue( + e.getMessage().contains(exceptionMessage), "real message:" + e.getMessage()); + } + + // generating certificate example + // openssl genrsa -out "/home/osboxes/key" 2048 + // openssl req -new -utf8 -sha1 \ + // -key /home/osboxes/key \ + // -subj "/C=US/ST=CA/O=Acme, Inc./CN=mariadb.org" \ + // -reqexts SAN \ + // -config <(cat /etc/ssl/openssl.cnf \ + // <(printf + // "\n[SAN]\nsubjectAltName=DNS:mariadbtest.org,DNS:www.mariadbtest.org")) \ + // -out domain.csr + + @Test + public void verifyCn() throws Exception { + // CN=test.com + X509Certificate cert = + getCertificate( + "" + + "-----BEGIN CERTIFICATE-----\n" + + "MIIC+zCCAeOgAwIBAgIJANin/585wAXHMA0GCSqGSIb3DQEBBQUAMBMxETAPBgNV\n" + + "BAMMCHRlc3QuY29tMCAXDTE3MDYyMzEzNTI1NloYDzIxMTcwNTMwMTM1MjU2WjAT\n" + + "MREwDwYDVQQDDAh0ZXN0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" + + "ggEBAMQHS31pL/fMkcQBo5zZV2Hi1Jdc1vIIv65d+XeFmv+n/vv+X5Z5NKLc7i01\n" + + "SFPoTEr1HG7R6Xvl27UtGm9Z6fmgsCbCRImUCG1yPER20fAgWNhKkoGgvOM8PxZz\n" + + "AS0dWgaukBnG9EDVQQrLu+bHuHji8qysGiYQGvSBy/QLSMWjfkSjyFv8I2pT0jLi\n" + + "eghgROl3IprRcsiebC/Bv1iJ06s8BD1C9ErzmPxqHaChdzGFATm+G4opcnBxzPuN\n" + + "DVE9CaLUS4Q5SixB9TRTQ2LyryEtUOUnnDyoktrX3LzkTmr2dhT8MIgRMsNkJD5w\n" + + "CpITvLchBXCdj0lcn5NMb0Rt/AsCAwEAAaNQME4wHQYDVR0OBBYEFJMoFo+HhyIt\n" + + "WA6QZmedeN2/qBU/MB8GA1UdIwQYMBaAFJMoFo+HhyItWA6QZmedeN2/qBU/MAwG\n" + + "A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAGpBkEJ3nv1kCnqQbrU3WYmv\n" + + "zl+kNc5xVZdLWMarjvWwBE1cnDHkXzJpl5cyWcHuPyWAi40/edN7gRfpNINWfc0A\n" + + "9YWo2PVBlBdklqzsewDV3gipFHkCgBTlGXaPXjCLLNxphYwdsble1hu/XXNvNY8v\n" + + "9EPxgN0rTnBj85gme/+Hrjq2kH15jyqK5rdylOjCZELs5g8cc49M6sw/sY70GsGA\n" + + "UEjb+vAN7FxXzXzH4oqIeycnxP+/MA82iieew7nlOMlYrppM6igjP0CUzw4ys6lG\n" + + "8QdWBcm2Ybo4XFjOnC98VlQl+WBu4CiToxjGphDmsMIO3Hf5PSTRwTKxtuWn45Y=\n" + + "-----END CERTIFICATE-----\n"); + DefaultHostnameVerifier.verify("test.com", cert, -1); + verifyExceptionEqual( + "a.test.com", + cert, + "DNS host \"a.test.com\" doesn't correspond to certificate CN \"test.com\""); + verifyExceptionEqual( + "other.com", + cert, + "DNS host \"other.com\" doesn't correspond to certificate CN \"test.com\""); + } + + @Test + public void verifyNoSan() throws Exception { + // CN=*.mariadb.com + X509Certificate cert = + getCertificate( + "" + + "-----BEGIN CERTIFICATE-----\n" + + "MIIDLjCCAhYCFEWSUFTlr/qGo/jC5R1nNQdE5zmrMA0GCSqGSIb3DQEBCwUAMFIx\n" + + "CzAJBgNVBAYTAkNOMQswCQYDVQQIDAJHRDELMAkGA1UEBwwCU1oxEjAQBgNVBAoM\n" + + "CUFjbWUsSW5jLjEVMBMGA1UEAwwMQWNtZSBSb290IENBMCAXDTIxMDMzMDA5MjQ1\n" + + "OVoYDzIxMjEwMzA2MDkyNDU5WjBTMQswCQYDVQQGEwJDTjELMAkGA1UECAwCR0Qx\n" + + "CzAJBgNVBAcMAlNaMRIwEAYDVQQKDAlBY21lLEluYy4xFjAUBgNVBAMMDSoubWFy\n" + + "aWFkYi5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDdKvfR3PBZ\n" + + "7oo4bYlj+Z2F+g2s1Pnurs7KUIu04T8x1KI0tiHniBTuTKL4TinWx734VjnK4pJf\n" + + "mwtcWpuxcXY+Btj/C47HMwpZjABI4PbHcB46IVb3gg8XTEDMxZ/OLYACYe+PEwvI\n" + + "8Bdmydtn/A6IqIOd2eQTSFCX695CNczSWd3yrirZwe6xZCp2xYemW2UJkrjxRK66\n" + + "IpoYWyYVPCe4CiGBL0f6dLrWE6HUPuA3Pb68o0IFGP4NlmXv9qHm8kXejqE216Q/\n" + + "Fx4sUS/icH50zs+QtpoKYR8XQnUVeAO8lEuI09mAxII5jtWdYOA/s2oSz5e7m0i2\n" + + "xsSHvDJD0P6bAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAKE/YucmKZldC2iE330u\n" + + "CiP9EvUJfd98j96clpzdqW2V/uDylJP96QDk0iY5rIfoGAu6a9xZP9Bju8F7crLz\n" + + "Ogx/Vdq//7uOHMe/kJ3kOjzI8jsdFKGA26BT8wBNZ/UT9ll0iFjYZ1YhsaURslX5\n" + + "+uW//GG6vpcMtWIMbkkHZnM5DKeZXF1VX55jrB01kxjaqrObhqNlQl887KQ/j5HF\n" + + "iAAiLwDQu171TQmCY7iesYv84cyUqLvRoAfLzOPb62AlLwGNWKeIOFJElnMSDx3y\n" + + "LzGv9zUUe1SdqqVASKJAAhzqGyu9eLkGYIKTHU7WdrPSyAhammdeq7C7AYLpMrPc\n" + + "CAM=\n" + + "-----END CERTIFICATE-----\n"); + DefaultHostnameVerifier.verify("test.mariadb.org", cert, -1); + verifyExceptionEqual( + "test.org", + cert, + "DNS host \"test.org\" doesn't correspond to certificate CN \"*.mariadb.org\""); + } + + @Test + public void verifyNonAsciiCn() throws Exception { + // CN=😎.com = "\uD83D\uDE0E" + X509Certificate cert = + getCertificate( + "" + + "-----BEGIN CERTIFICATE-----\n" + + "MIIDWTCCAkGgAwIBAgIJAI38v686DwcOMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNV\n" + + "BAYTAlVTMQswCQYDVQQIDAJDQTETMBEGA1UECgwKQWNtZSwgSW5jLjERMA8GA1UE\n" + + "AwwI8J+Yji5jb20wIBcNMTcwNjIzMTQyNzQ2WhgPMjExNzA1MzAxNDI3NDZaMEIx\n" + + "CzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTETMBEGA1UECgwKQWNtZSwgSW5jLjER\n" + + "MA8GA1UEAwwI8J+Yji5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\n" + + "AQDEB0t9aS/3zJHEAaOc2Vdh4tSXXNbyCL+uXfl3hZr/p/77/l+WeTSi3O4tNUhT\n" + + "6ExK9Rxu0el75du1LRpvWen5oLAmwkSJlAhtcjxEdtHwIFjYSpKBoLzjPD8WcwEt\n" + + "HVoGrpAZxvRA1UEKy7vmx7h44vKsrBomEBr0gcv0C0jFo35Eo8hb/CNqU9Iy4noI\n" + + "YETpdyKa0XLInmwvwb9YidOrPAQ9QvRK85j8ah2goXcxhQE5vhuKKXJwccz7jQ1R\n" + + "PQmi1EuEOUosQfU0U0Ni8q8hLVDlJ5w8qJLa19y85E5q9nYU/DCIETLDZCQ+cAqS\n" + + "E7y3IQVwnY9JXJ+TTG9EbfwLAgMBAAGjUDBOMB0GA1UdDgQWBBSTKBaPh4ciLVgO\n" + + "kGZnnXjdv6gVPzAfBgNVHSMEGDAWgBSTKBaPh4ciLVgOkGZnnXjdv6gVPzAMBgNV\n" + + "HRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQBknxZ3ihZHmcyrV3H0pNdc+jxB\n" + + "xU0T1T1nOLVpgqh+N0m+WFyGdcZlwPcmuD2a5jFn7uIdh8qfq11T8R+OmJqrBxoo\n" + + "RSACSAgRSQjPfnN8wi4i8hFLKXOQw43UomsSuNixdGIsMWrDh02e1Q0/g/TD7S62\n" + + "JCRksTlBS/+qw+w384vEd4djq7HuT8/hs2RC6Hm9EQkipgNn9+2z40vJ/jgcuPIF\n" + + "x51XCozrD1yW9JK/YyBnjYk04iEfQLW7+pGMJOcsX7x9EGwpEg1gsDg2mM0EEIwU\n" + + "d6DHlYvpD9JkzyEScg8Supztoc2aGbGE4SHBKB1riTLBAHWqqwas4sGSgZxu\n" + + "-----END CERTIFICATE-----\n"); + DefaultHostnameVerifier.verify("😎.com", cert, -1); + verifyExceptionEqual( + "a.😎.com", cert, "DNS host \"a.😎.com\" doesn't correspond to certificate CN \"😎.com\""); + } + + @Test + public void verifySubjectAlt() throws Exception { + // CN=mariadb.org, subjectAlt=other.org,www.other.org + // openssl genrsa -out ca.key 2048 + // openssl req -new -x509 -days 36500 -key ca.key -subj "/C=CN/ST=GD/L=SZ/O=Acme, + // Inc./CN=Acme Root CA" -out ca.crt + // + // openssl req -newkey rsa:2048 -nodes -keyout server.key -subj "/C=CN/ST=GD/L=SZ/O=Acme, + // Inc./CN=*.mariadb.org" \ + // -out server.csr + // openssl x509 -req -extfile <(printf "subjectAltName=DNS:other.org,DNS:www.other.org") + // -days 36500 \ + // -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt + X509Certificate cert = + getCertificate( + "" + + "-----BEGIN CERTIFICATE-----\n" + + "MIIDUzCCAjugAwIBAgIJAPMG38xrY9DcMA0GCSqGSIb3DQEBCwUAMFMxCzAJBgNV\n" + + "BAYTAkNOMQswCQYDVQQIDAJHRDELMAkGA1UEBwwCU1oxEzARBgNVBAoMCkFjbWUs\n" + + "IEluYy4xFTATBgNVBAMMDEFjbWUgUm9vdCBDQTAgFw0xNzA2MjMxNjEyNTlaGA8y\n" + + "MTE3MDUzMDE2MTI1OVowVDELMAkGA1UEBhMCQ04xCzAJBgNVBAgMAkdEMQswCQYD\n" + + "VQQHDAJTWjETMBEGA1UECgwKQWNtZSwgSW5jLjEWMBQGA1UEAwwNKi5tYXJpYWRi\n" + + "Lm9yZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANZnnLoS2JKQNr/d\n" + + "ccRT1pNVKHykAVJHhZiIfjqqKEstjob30VZjll5exQ6iTHaS73qXG1/PfXhEl8Tc\n" + + "7R3VlE7dHxPE+FhWSCcdsJlSEpa9h0TOkJ6H4V1iD+bTwlfEesLqXCzLkaBz7hsw\n" + + "L6mzVDJ4Lucrstf2YgBEoXjzj8G+ECiz1Vx1GX1jU2yoRYk/LcGUgsbxMxZOFcKG\n" + + "JyCmjbRe7xJozhu3m/1bf8eCyHg/+Tpiw1VGwPNFe6mb2SI9pYnk9l0pjzFy5yxJ\n" + + "nFeYj5cLBZHwM5K2aHiOvvBeXvYz9RIrWI98zsXZFjzD00+Js3X/jC4nRtkHV/JC\n" + + "COvAwRUCAwEAAaMnMCUwIwYDVR0RBBwwGoIJb3RoZXIub3Jngg13d3cub3RoZXIu\n" + + "b3JnMA0GCSqGSIb3DQEBCwUAA4IBAQDEswEEw2VXv6+EKIz3ysN7kRNXs09TWiYd\n" + + "bhGIVWHK4oRMjbUkPQWNftD+VvRyW1mZPZ0Tn/kXPnUsYCuF/UFLautmIAa16/el\n" + + "WJc9EA4yM42CByW/DEUfvFVgaBoJysLNhA2O/1VC/UmC2TNjiwXAO3AOJTVgdS1/\n" + + "nj34C3SJgbtmMu/ToCILMcjkaKJPD2/1AaIioBOSxvwdseM399eVjZIhf9bQCSHU\n" + + "fDrV4El/nb5nr4j7AvHtIhbPtpJOmKCAbZRwKc+ZgrH6ZyapyZfpmNmlwZcuC4DM\n" + + "SJmVrJfl1GdaXyxsljClcXM9MDQYm9r9wcchc3dSVR+k6wz2+vbw\n" + + "-----END CERTIFICATE-----\n"); + + verifyExceptionEqual( + "mariadb.org", + cert, + "DNS host \"mariadb.org\" doesn't correspond to certificate " + + "CN \"*.mariadb.org\" and SAN[{DNS:\"other.org\"},{DNS:\"www.other.org\"}]"); + DefaultHostnameVerifier.verify("a.mariadb.org", cert, -1); + verifyExceptionEqual( + "a.other2.org", + cert, + "DNS host \"a.other2.org\" doesn't correspond to certificate " + + "CN \"*.mariadb.org\" and SAN[{DNS:\"other.org\"},{DNS:\"www.other.org\"}]"); + DefaultHostnameVerifier.verify("other.org", cert, -1); + verifyExceptionEqual( + "a.other.org", + cert, + "DNS host \"a.other.org\" doesn't correspond to certificate " + + "CN \"*.mariadb.org\" and SAN[{DNS:\"other.org\"},{DNS:\"www.other.org\"}]"); + DefaultHostnameVerifier.verify("www.other.org", cert, -1); + } + + @Test + public void verifySubjectAltOnly() throws Exception { + // subjectAlt=foo.com + X509Certificate cert = + getCertificate( + "" + + "-----BEGIN CERTIFICATE-----\n" + + "MIIESjCCAzKgAwIBAgIJAIz+EYMBU6aYMA0GCSqGSIb3DQEBBQUAMIGiMQswCQYD\n" + + "VQQGEwJDQTELMAkGA1UECBMCQkMxEjAQBgNVBAcTCVZhbmNvdXZlcjEWMBQGA1UE\n" + + "ChMNd3d3LmN1Y2JjLmNvbTEUMBIGA1UECxQLY29tbW9uc19zc2wxHTAbBgNVBAMU\n" + + "FGRlbW9faW50ZXJtZWRpYXRlX2NhMSUwIwYJKoZIhvcNAQkBFhZqdWxpdXNkYXZp\n" + + "ZXNAZ21haWwuY29tMB4XDTA2MTIxMTE2MjYxMFoXDTI4MTEwNTE2MjYxMFowgZIx\n" + + "CzAJBgNVBAYTAlVTMREwDwYDVQQIDAhNYXJ5bGFuZDEUMBIGA1UEBwwLRm9yZXN0\n" + + "IEhpbGwxFzAVBgNVBAoMDmh0dHBjb21wb25lbnRzMRowGAYDVQQLDBF0ZXN0IGNl\n" + + "cnRpZmljYXRlczElMCMGCSqGSIb3DQEJARYWanVsaXVzZGF2aWVzQGdtYWlsLmNv\n" + + "bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMhjr5aCPoyp0R1iroWA\n" + + "fnEyBMGYWoCidH96yGPFjYLowez5aYKY1IOKTY2BlYho4O84X244QrZTRl8kQbYt\n" + + "xnGh4gSCD+Z8gjZ/gMvLUlhqOb+WXPAUHMB39GRyzerA/ZtrlUqf+lKo0uWcocxe\n" + + "Rc771KN8cPH3nHZ0rV0Hx4ZAZy6U4xxObe4rtSVY07hNKXAb2odnVqgzcYiDkLV8\n" + + "ilvEmoNWMWrp8UBqkTcpEhYhCYp3cTkgJwMSuqv8BqnGd87xQU3FVZI4tbtkB+Kz\n" + + "jD9zz8QCDJAfDjZHR03KNQ5mxOgXwxwKw6lGMaiVJTxpTKqym93whYk93l3ocEe5\n" + + "5c0CAwEAAaOBkDCBjTAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM\n" + + "IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUnxR3vz86tso4gkJIFiza\n" + + "0Mteh9gwHwYDVR0jBBgwFoAUe5raj5CZTlLSrNuzA1LKh6YNPg0wEgYDVR0RBAsw\n" + + "CYIHZm9vLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEAjl78oMjzFdsMy6F1sGg/IkO8\n" + + "tF5yUgPgFYrs41yzAca7IQu6G9qtFDJz/7ehh/9HoG+oqCCIHPuIOmS7Sd0wnkyJ\n" + + "Y7Y04jVXIb3a6f6AgBkEFP1nOT0z6kjT7vkA5LJ2y3MiDcXuRNMSta5PYVnrX8aZ\n" + + "yiqVUNi40peuZ2R8mAUSBvWgD7z2qWhF8YgDb7wWaFjg53I36vWKn90ZEti3wNCw\n" + + "qAVqixM+J0qJmQStgAc53i2aTMvAQu3A3snvH/PHTBo+5UL72n9S1kZyNCsVf1Qo\n" + + "n8jKTiRriEM+fMFlcgQP284EBFzYHyCXFb9O/hMjK2+6mY9euMB1U1aFFzM/Bg==\n" + + "-----END CERTIFICATE-----\n"); + DefaultHostnameVerifier.verify("foo.com", cert, -1); + verifyExceptionEqual( + "a.foo.com", + cert, + "CN not found in certificate principal " + + "\"EMAILADDRESS=juliusdavies@gmail.com, OU=test certificates, O=httpcomponents, L=Forest Hill, " + + "ST=Maryland, C=US\" and DNS host \"a.foo.com\" doesn't correspond to SAN[{DNS:\"foo.com\"}]"); + } + + @Test + public void noCn() throws Exception { + // subjectAlt=foo.com + X509Certificate cert = + getCertificate( + "-----BEGIN CERTIFICATE-----\n" + + "MIIDazCCAlOgAwIBAgIUFxeXaoK5VSZBV1UdBhcDIB0abUAwDQYJKoZIhvcNAQEF\n" + + "BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM\n" + + "GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMTA0MTQxNjIxMTlaFw0zMTA0\n" + + "MTIxNjIxMTlaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw\n" + + "HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB\n" + + "AQUAA4IBDwAwggEKAoIBAQDRmmo+05f5oqKFidWhk6+EbCNJzxJ7fwrGV13ZfqqP\n" + + "HSyxZIcWI/bK6BCjb9BxJa/QaaThr6x7GxI6PaDqRWInpuHepqIBL2arJLq2H3ys\n" + + "2zErfA5n0rFkryYW6zQUW/TJTxz5dbagemYA4TvS5Tshm0fimtNDTcv6Vb7U3OXc\n" + + "pa42VeLgaaM+OeCQlFH4OEXzGqXwqU090D2aRp05uPJRCFhwvMI9QXG2R8zXogTx\n" + + "TAlmxm4piKmg123TLd2N1TxJHxskg4OR5guO/XaG/Zji4KCKJ7dJFHjvNztG0Nme\n" + + "dxOo/+I/AeWhLEq81fzGMg4/BYeU1cLv6wnqFi4pbyWLAgMBAAGjUzBRMB0GA1Ud\n" + + "DgQWBBTLvLm0GjjbZOg5fJYgt80FvCgxNzAfBgNVHSMEGDAWgBTLvLm0GjjbZOg5\n" + + "fJYgt80FvCgxNzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQBp\n" + + "3Z8UMM8y++04mKRZEP7y88dmmLOt64TRjJhTFoHvZsC/VZi5glt3/FnYxhlf8sfQ\n" + + "sJB+TRlVcEWBff6yJd/uUScff56Zgy2PCCL4rjgBjxgq/kf28m6tC8nHlx88qz0Y\n" + + "CZR9eEwTN8xgRvgUx5OFNewDYpkY0QAHkzAddCl5uaO6Mi0E34gSECIQ/cJ75xhQ\n" + + "K3Qy/qj1Kl7r80WJtzmhpZbpKbVZXa3NpwTWUfaD6WhNW0H/BhAnQq3XkXVWK6sW\n" + + "rLfHdWz9hQ79AiNaTc1I3YDyrnNEQBvHAFZ87Y8XIk4RaPzttLAfL/IKHuJdb85M\n" + + "cMq0UjgrIuCJoKB8kcm/\n" + + "-----END CERTIFICATE-----"); + verifyExceptionEqual( + "a.foo.com", + cert, + "CN not found in certificate principal \"O=Internet Widgits Pty Ltd, ST=Some-State, C=AU\" and certificate doesn't contain SAN"); + } + + @Test + public void verifyMultipleCn() throws Exception { + // CN=test1.org, CN=test2.org + X509Certificate cert = + getCertificate( + "" + + "-----BEGIN CERTIFICATE-----\n" + + "MIIDgzCCAmugAwIBAgIJAPqfD+J8D4gqMA0GCSqGSIb3DQEBBQUAMFcxCzAJBgNV\n" + + "BAYTAlVTMQswCQYDVQQIDAJDQTETMBEGA1UECgwKQWNtZSwgSW5jLjESMBAGA1UE\n" + + "AwwJdGVzdDEub3JnMRIwEAYDVQQDDAl0ZXN0Mi5vcmcwIBcNMTcwNjIzMTYxNDIx\n" + + "WhgPMjExNzA1MzAxNjE0MjFaMFcxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTET\n" + + "MBEGA1UECgwKQWNtZSwgSW5jLjESMBAGA1UEAwwJdGVzdDEub3JnMRIwEAYDVQQD\n" + + "DAl0ZXN0Mi5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDEB0t9\n" + + "aS/3zJHEAaOc2Vdh4tSXXNbyCL+uXfl3hZr/p/77/l+WeTSi3O4tNUhT6ExK9Rxu\n" + + "0el75du1LRpvWen5oLAmwkSJlAhtcjxEdtHwIFjYSpKBoLzjPD8WcwEtHVoGrpAZ\n" + + "xvRA1UEKy7vmx7h44vKsrBomEBr0gcv0C0jFo35Eo8hb/CNqU9Iy4noIYETpdyKa\n" + + "0XLInmwvwb9YidOrPAQ9QvRK85j8ah2goXcxhQE5vhuKKXJwccz7jQ1RPQmi1EuE\n" + + "OUosQfU0U0Ni8q8hLVDlJ5w8qJLa19y85E5q9nYU/DCIETLDZCQ+cAqSE7y3IQVw\n" + + "nY9JXJ+TTG9EbfwLAgMBAAGjUDBOMB0GA1UdDgQWBBSTKBaPh4ciLVgOkGZnnXjd\n" + + "v6gVPzAfBgNVHSMEGDAWgBSTKBaPh4ciLVgOkGZnnXjdv6gVPzAMBgNVHRMEBTAD\n" + + "AQH/MA0GCSqGSIb3DQEBBQUAA4IBAQANlc974MeEIjEG8PzjDuiCbImZU/vxmBu1\n" + + "QD4mOfTjoixx/o9w/TbtnYhlugH3Nb2biaIx+2VnQAjk6euNBdFXW1cIawstrYGn\n" + + "KKEbZgQ7rgWfqyXIUK5NgX5jqxv5iW2xQE9nFGum8ouy8t+Nwi5F5uPGlhw/POnZ\n" + + "SLdP5i67GJN/Ho2HCfYOWm8STo0S7jmxtGoLcZ/EPaM3DaqLQYTdjtNKuotw1YuF\n" + + "A94gKVaU6XS6EdDGc6oSfKAR/pqKnWAmDc0ofvYniojquzm4fUO3JgzXN/xTDPUc\n" + + "GiY3dV92GD9wZfbUWsQRzLizRzIrsvZfCn/LLeUvOQPuCCeLzIxD\n" + + "-----END CERTIFICATE-----\n"); + DefaultHostnameVerifier.verify("test1.org", cert, -1); + verifyExceptionEqual( + "test2.org", + cert, + "DNS host \"test2.org\" doesn't correspond to certificate CN \"test1.org\""); + } + + @Test + public void verifyWilcardCn() throws Exception { + // CN=*.foo.com + X509Certificate cert = + getCertificate( + "" + + "-----BEGIN CERTIFICATE-----\n" + + "MIIESDCCAzCgAwIBAgIJAIz+EYMBU6aUMA0GCSqGSIb3DQEBBQUAMIGiMQswCQYD\n" + + "VQQGEwJDQTELMAkGA1UECBMCQkMxEjAQBgNVBAcTCVZhbmNvdXZlcjEWMBQGA1UE\n" + + "ChMNd3d3LmN1Y2JjLmNvbTEUMBIGA1UECxQLY29tbW9uc19zc2wxHTAbBgNVBAMU\n" + + "FGRlbW9faW50ZXJtZWRpYXRlX2NhMSUwIwYJKoZIhvcNAQkBFhZqdWxpdXNkYXZp\n" + + "ZXNAZ21haWwuY29tMB4XDTA2MTIxMTE2MTU1NVoXDTI4MTEwNTE2MTU1NVowgaYx\n" + + "CzAJBgNVBAYTAlVTMREwDwYDVQQIEwhNYXJ5bGFuZDEUMBIGA1UEBxMLRm9yZXN0\n" + + "IEhpbGwxFzAVBgNVBAoTDmh0dHBjb21wb25lbnRzMRowGAYDVQQLExF0ZXN0IGNl\n" + + "cnRpZmljYXRlczESMBAGA1UEAxQJKi5mb28uY29tMSUwIwYJKoZIhvcNAQkBFhZq\n" + + "dWxpdXNkYXZpZXNAZ21haWwuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n" + + "CgKCAQEAyGOvloI+jKnRHWKuhYB+cTIEwZhagKJ0f3rIY8WNgujB7PlpgpjUg4pN\n" + + "jYGViGjg7zhfbjhCtlNGXyRBti3GcaHiBIIP5nyCNn+Ay8tSWGo5v5Zc8BQcwHf0\n" + + "ZHLN6sD9m2uVSp/6UqjS5ZyhzF5FzvvUo3xw8fecdnStXQfHhkBnLpTjHE5t7iu1\n" + + "JVjTuE0pcBvah2dWqDNxiIOQtXyKW8Sag1YxaunxQGqRNykSFiEJindxOSAnAxK6\n" + + "q/wGqcZ3zvFBTcVVkji1u2QH4rOMP3PPxAIMkB8ONkdHTco1DmbE6BfDHArDqUYx\n" + + "qJUlPGlMqrKb3fCFiT3eXehwR7nlzQIDAQABo3sweTAJBgNVHRMEAjAAMCwGCWCG\n" + + "SAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4E\n" + + "FgQUnxR3vz86tso4gkJIFiza0Mteh9gwHwYDVR0jBBgwFoAUe5raj5CZTlLSrNuz\n" + + "A1LKh6YNPg0wDQYJKoZIhvcNAQEFBQADggEBAH0ipG6J561UKUfgkeW7GvYwW98B\n" + + "N1ZooWX+JEEZK7+Pf/96d3Ij0rw9ACfN4bpfnCq0VUNZVSYB+GthQ2zYuz7tf/UY\n" + + "A6nxVgR/IjG69BmsBl92uFO7JTNtHztuiPqBn59pt+vNx4yPvno7zmxsfI7jv0ww\n" + + "yfs+0FNm7FwdsC1k47GBSOaGw38kuIVWqXSAbL4EX9GkryGGOKGNh0qvAENCdRSB\n" + + "G9Z6tyMbmfRY+dLSh3a9JwoEcBUso6EWYBakLbq4nG/nvYdYvG9ehrnLVwZFL82e\n" + + "l3Q/RK95bnA6cuRClGusLad0e6bjkBzx/VQ3VarDEpAkTLUGVAa0CLXtnyc=\n" + + "-----END CERTIFICATE-----\n"); + verifyExceptionEqual( + "foo.com", cert, "DNS host \"foo.com\" doesn't correspond to certificate CN \"*.foo.com\""); + DefaultHostnameVerifier.verify("www.foo.com", cert, -1); + DefaultHostnameVerifier.verify("花子.foo.com", cert, -1); + verifyExceptionEqual( + "a.b.foo.com", + cert, + "DNS host \"a.b.foo.com\" doesn't correspond to certificate CN \"*.foo.com\""); + } + + @Test + public void verifyWilcardCnOnTld() throws Exception { + // It's the CA's responsibility to not issue broad-matching certificates! + // CN=*.co.jp + X509Certificate cert = + getCertificate( + "" + + "-----BEGIN CERTIFICATE-----\n" + + "MIIERjCCAy6gAwIBAgIJAIz+EYMBU6aVMA0GCSqGSIb3DQEBBQUAMIGiMQswCQYD\n" + + "VQQGEwJDQTELMAkGA1UECBMCQkMxEjAQBgNVBAcTCVZhbmNvdXZlcjEWMBQGA1UE\n" + + "ChMNd3d3LmN1Y2JjLmNvbTEUMBIGA1UECxQLY29tbW9uc19zc2wxHTAbBgNVBAMU\n" + + "FGRlbW9faW50ZXJtZWRpYXRlX2NhMSUwIwYJKoZIhvcNAQkBFhZqdWxpdXNkYXZp\n" + + "ZXNAZ21haWwuY29tMB4XDTA2MTIxMTE2MTYzMFoXDTI4MTEwNTE2MTYzMFowgaQx\n" + + "CzAJBgNVBAYTAlVTMREwDwYDVQQIEwhNYXJ5bGFuZDEUMBIGA1UEBxMLRm9yZXN0\n" + + "IEhpbGwxFzAVBgNVBAoTDmh0dHBjb21wb25lbnRzMRowGAYDVQQLExF0ZXN0IGNl\n" + + "cnRpZmljYXRlczEQMA4GA1UEAxQHKi5jby5qcDElMCMGCSqGSIb3DQEJARYWanVs\n" + + "aXVzZGF2aWVzQGdtYWlsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n" + + "ggEBAMhjr5aCPoyp0R1iroWAfnEyBMGYWoCidH96yGPFjYLowez5aYKY1IOKTY2B\n" + + "lYho4O84X244QrZTRl8kQbYtxnGh4gSCD+Z8gjZ/gMvLUlhqOb+WXPAUHMB39GRy\n" + + "zerA/ZtrlUqf+lKo0uWcocxeRc771KN8cPH3nHZ0rV0Hx4ZAZy6U4xxObe4rtSVY\n" + + "07hNKXAb2odnVqgzcYiDkLV8ilvEmoNWMWrp8UBqkTcpEhYhCYp3cTkgJwMSuqv8\n" + + "BqnGd87xQU3FVZI4tbtkB+KzjD9zz8QCDJAfDjZHR03KNQ5mxOgXwxwKw6lGMaiV\n" + + "JTxpTKqym93whYk93l3ocEe55c0CAwEAAaN7MHkwCQYDVR0TBAIwADAsBglghkgB\n" + + "hvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYE\n" + + "FJ8Ud78/OrbKOIJCSBYs2tDLXofYMB8GA1UdIwQYMBaAFHua2o+QmU5S0qzbswNS\n" + + "yoemDT4NMA0GCSqGSIb3DQEBBQUAA4IBAQA0sWglVlMx2zNGvUqFC73XtREwii53\n" + + "CfMM6mtf2+f3k/d8KXhLNySrg8RRlN11zgmpPaLtbdTLrmG4UdAHHYr8O4y2BBmE\n" + + "1cxNfGxxechgF8HX10QV4dkyzp6Z1cfwvCeMrT5G/V1pejago0ayXx+GPLbWlNeZ\n" + + "S+Kl0m3p+QplXujtwG5fYcIpaGpiYraBLx3Tadih39QN65CnAh/zRDhLCUzKyt9l\n" + + "UGPLEUDzRHMPHLnSqT1n5UU5UDRytbjJPXzF+l/+WZIsanefWLsxnkgAuZe/oMMF\n" + + "EJMryEzOjg4Tfuc5qM0EXoPcQ/JlheaxZ40p2IyHqbsWV4MRYuFH4bkM\n" + + "-----END CERTIFICATE-----\n"); + DefaultHostnameVerifier.verify("foo.co.jp", cert, -1); + DefaultHostnameVerifier.verify("花子.co.jp", cert, -1); + } + + @Test + public void subjectAltUsesLocalDomainAndIp() throws Exception { + // /C=CN/ST=GD/L=SZ/O=Acme, Inc./CN=*.mariadb.org, + // subjectAltName=DNS:localhost.localdomain,DNS:localhost,IP:127.0.0.1 + X509Certificate cert = + getCertificate( + "" + + "-----BEGIN CERTIFICATE-----\n" + + "MIIDfDCCAmSgAwIBAgIURZJQVOWv+oaj+MLlHWc1B0TnOaowDQYJKoZIhvcNAQEL\n" + + "BQAwUjELMAkGA1UEBhMCQ04xCzAJBgNVBAgMAkdEMQswCQYDVQQHDAJTWjESMBAG\n" + + "A1UECgwJQWNtZSxJbmMuMRUwEwYDVQQDDAxBY21lIFJvb3QgQ0EwIBcNMjEwMzMw\n" + + "MDkwODAxWhgPMjEyMTAzMDYwOTA4MDFaMFMxCzAJBgNVBAYTAkNOMQswCQYDVQQI\n" + + "DAJHRDELMAkGA1UEBwwCU1oxEjAQBgNVBAoMCUFjbWUsSW5jLjEWMBQGA1UEAwwN\n" + + "Ki5tYXJpYWRiLm9yZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANAJ\n" + + "xqbqTGmwO5n3kVd6QJPRSh+0M1HIQacyM/tkE7jLw3725/KtknuwuFbPpxKyTCLC\n" + + "IoNx4yaBbmx783OPP3pokXTWiMdrVZdLltBNamNzekNFN4YhR5oN479M5cKgrk94\n" + + "Ud+ql0NN5FscrSQ0fSdJf0idJMqThro1MJVp9rp5cdCba6/lKyDbdOybe5f7rmrg\n" + + "+37J+src67+rqwVT8ZwZgLTGDf4X9OSIzyw6+PCWYWr89aurrOuOyqA3QqXVRZa/\n" + + "IxOMHIdzXMgLN6+HduwdZ+DNv1NPT2MDlRQvOnDop3NoEVKWekOTv50LbKRgWTYO\n" + + "TK/dfcsDpZmdyHv7pb8CAwEAAaNHMEUwQwYDVR0RBDwwOoIVbG9jYWxob3N0Lmxv\n" + + "Y2FsZG9tYWlugglsb2NhbGhvc3SHBH8AAAGHECABDbg5AjRoAAAAAAAABEMwDQYJ\n" + + "KoZIhvcNAQELBQADggEBAHsiJz9cpmL8BTa/o10S+pmap3iOnYYuJT0llCRLJ+Ji\n" + + "msO2niyIwqCJHMLcEABCENJt0HDOEKlnunVgc+X/6K8DnPrYhfWQbYI/dwUBoSIQ\n" + + "siK/yKW0q+S+YjCVpNMA3iMfhJ9Qe9LDO+xdCBhzplgrV8YwG+J2FUNbZfvl5cML\n" + + "TjKLWrWo9dgZyH/7mjwryRzswfUfr/lRARCyrMotaXfYmjPjwTSRc0aPGrEjs3ns\n" + + "WMtimgh7Zw3Tbxc51miz9CRy767lq/9BGTdeBLmW0EXssIJb9uO0Ht3C/Pqy0ojk\n" + + "8e1eYtofjTsqWHZ1s2LhtT0HvXdL6BnWP9GWc/zxiKM=\n" + + "-----END CERTIFICATE-----\n"); + assertEquals( + new X500Principal("CN=*.mariadb.org, O=\"Acme,Inc.\", L=SZ, ST=GD, C=CN"), + cert.getSubjectX500Principal()); + + DefaultHostnameVerifier.verify("localhost", cert, -1); + DefaultHostnameVerifier.verify("localhost.localdomain", cert, -1); + verifyExceptionEqual( + "local.host", + cert, + "DNS host \"local.host\" doesn't correspond to certificate " + + "CN \"*.mariadb.org\" and SAN[{DNS:\"localhost.localdomain\"},{DNS:\"localhost\"},{IP:\"127.0.0.1\"},{IP:\"2001:db8:3902:3468:0:0:0:443\"}]"); + + DefaultHostnameVerifier.verify("127.0.0.1", cert, -1); + verifyExceptionEqual( + "127.0.0.2", + cert, + "IPv4 host \"127.0.0.2\" doesn't correspond to certificate " + + "CN \"*.mariadb.org\" and SAN[{DNS:\"localhost.localdomain\"},{DNS:\"localhost\"},{IP:\"127.0.0.1\"},{IP:\"2001:db8:3902:3468:0:0:0:443\"}]"); + + DefaultHostnameVerifier.verify("2001:db8:3902:3468:0:0:0:443", cert, -1); + verifyExceptionEqual( + "2001:db8:1::", + cert, + "IPv6 host \"2001:db8:1::\" doesn't correspond to certificate " + + "CN \"*.mariadb.org\" and SAN[{DNS:\"localhost.localdomain\"},{DNS:\"localhost\"},{IP:\"127.0.0.1\"},{IP:\"2001:db8:3902:3468:0:0:0:443\"}]"); + } + + @Test + public void wildcardsCannotMatchIpAddresses() throws Exception { + // openssl req -x509 -nodes -days 36500 -subj '/CN=*.0.0.1' -newkey rsa:512 -out cert.pem + X509Certificate cert = + getCertificate( + "" + + "-----BEGIN CERTIFICATE-----\n" + + "MIIDVzCCAj+gAwIBAgIJAN9L/Y9e1F7dMA0GCSqGSIb3DQEBBQUAMEExCzAJBgNV\n" + + "BAYTAlVTMQswCQYDVQQIDAJDQTETMBEGA1UECgwKQWNtZSwgSW5jLjEQMA4GA1UE\n" + + "AwwHKi4wLjAuMTAgFw0xNzA2MjMxNTU3MTdaGA8yMTE3MDUzMDE1NTcxN1owQTEL\n" + + "MAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRMwEQYDVQQKDApBY21lLCBJbmMuMRAw\n" + + "DgYDVQQDDAcqLjAuMC4xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA\n" + + "xAdLfWkv98yRxAGjnNlXYeLUl1zW8gi/rl35d4Wa/6f++/5flnk0otzuLTVIU+hM\n" + + "SvUcbtHpe+XbtS0ab1np+aCwJsJEiZQIbXI8RHbR8CBY2EqSgaC84zw/FnMBLR1a\n" + + "Bq6QGcb0QNVBCsu75se4eOLyrKwaJhAa9IHL9AtIxaN+RKPIW/wjalPSMuJ6CGBE\n" + + "6XcimtFyyJ5sL8G/WInTqzwEPUL0SvOY/GodoKF3MYUBOb4biilycHHM+40NUT0J\n" + + "otRLhDlKLEH1NFNDYvKvIS1Q5SecPKiS2tfcvOROavZ2FPwwiBEyw2QkPnAKkhO8\n" + + "tyEFcJ2PSVyfk0xvRG38CwIDAQABo1AwTjAdBgNVHQ4EFgQUkygWj4eHIi1YDpBm\n" + + "Z5143b+oFT8wHwYDVR0jBBgwFoAUkygWj4eHIi1YDpBmZ5143b+oFT8wDAYDVR0T\n" + + "BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAAE4YYuS94g9EyIRvPeXcHlJsjG1n\n" + + "moSZIVgSuKjLAb31SOyY+2c534SUELED7ECEb4yKM7WmWctpF0anFZUDCczuo+zl\n" + + "uuTv1k/TE9GBWizxZgu/vX7+FAbxAgkA9Jxn2phJlks+PwnUClzVBzJ77zPNzIO8\n" + + "6s8waZr9ttnASBHVaeSKkknI+gas5KpvY+B4eRxZx0G8Fyher29yIiE44Z6RHzjI\n" + + "+EnURTvdjd2ZuY5QKvwlBQssqOHxDATg8pL6JmgnrvbYqh+FBpUN8sqwrXx6q8dz\n" + + "aUH7ncQGgwZBAUIiQaKlb0QYpcyrMlGWNri+RFt+Goz5S3BxxobwfiaBoA==\n" + + "-----END CERTIFICATE-----\n"); + verifyExceptionEqual( + "127.0.0.1", + cert, + "IPv4 host \"127.0.0.1\" doesn't correspond to " + + "certificate CN \"*.0.0.1\" : wildcards not possible for IPs"); + } + + @Test + public void subjectAltNameWithWildcard() throws Exception { + // subjectAltName=DNS:*.other.org,DNS:a*b.other2.com + X509Certificate cert = + getCertificate( + "" + + "-----BEGIN CERTIFICATE-----\n" + + "MIIDVjCCAj6gAwIBAgIJAPMG38xrY9DaMA0GCSqGSIb3DQEBCwUAMFMxCzAJBgNV\n" + + "BAYTAkNOMQswCQYDVQQIDAJHRDELMAkGA1UEBwwCU1oxEzARBgNVBAoMCkFjbWUs\n" + + "IEluYy4xFTATBgNVBAMMDEFjbWUgUm9vdCBDQTAgFw0xNzA2MjMxNjA1MTlaGA8y\n" + + "MTE3MDUzMDE2MDUxOVowVDELMAkGA1UEBhMCQ04xCzAJBgNVBAgMAkdEMQswCQYD\n" + + "VQQHDAJTWjETMBEGA1UECgwKQWNtZSwgSW5jLjEWMBQGA1UEAwwNKi5tYXJpYWRi\n" + + "Lm9yZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKqUYr7IHOuE1FD3\n" + + "4AX/23DZ/VnK3U/sZNLfdP9322pO5HP4yv3HzHNtkl+3s/jKnRBwOpGjvmeoVgro\n" + + "B8NK7Prs8tCMET9yfFXg/gSkoMAnR4g1jExB9bszTRN1+5dmLZK7xoKcRYtdKCLB\n" + + "AeGYAx6lSKFkc5sAuU8e9k9iAdD+j2w4s5UbP2QTK6N97+EMGTYjQ91ynsxzUltX\n" + + "5ueRLbg0M5WyRZpB4oH3J5T2L+NzpjU60Lhny/Kz5fCDizkwYjYBV+p9bhneklia\n" + + "ByBxGm/y+yrDm5RDRICws5UhjWEe5ztOrfLwjZGmkYgcr2iuVqR3yhXoQIrxK1OV\n" + + "8RnNJSECAwEAAaMqMCgwJgYDVR0RBB8wHYILKi5vdGhlci5vcmeCDmEqYi5vdGhl\n" + + "cjIuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQAAgqjYSzvgc+lUa/8gEpX9QJVvvDN9\n" + + "nKqsJIB8G7uSGQgjq1eA8LrklTo1X3uER2+dLfoHIvJJxzuqRF6ugDnHMW+ocITY\n" + + "yYkvb1Ok/aKo9e9sEKhndT47A9fjGoN94xhEEfVL8oc2g5gnNQ/+YHwO0vajdh2V\n" + + "CMpkFvvSClvomb91u/leWwu1C07dJWHM2OzldEmlQK9sm847YofEfXe5FZXt+Py2\n" + + "zpmwb3/djqBpSwdMgBB3us2wEiHN95EGRCT8BmTZ4gFtfdXt6uAZOd93NAoYlmpV\n" + + "Flo8jrfEOHRCrdYqXobC/YVuxk+1h+Q2Nu5mKzbc3XfpG1LGGZB98+FP\n" + + "-----END CERTIFICATE-----\n"); + + verifyExceptionEqual( + "other.org", + cert, + "DNS host \"other.org\" doesn't correspond " + + "to certificate CN \"*.mariadb.org\" and SAN[{DNS:\"*.other.org\"},{DNS:\"a*b.other2.com\"}]"); + DefaultHostnameVerifier.verify("www.other.org", cert, -1); + verifyExceptionEqual( + "other2.org", + cert, + "DNS host \"other2.org\" doesn't correspond " + + "to certificate CN \"*.mariadb.org\" and SAN[{DNS:\"*.other.org\"},{DNS:\"a*b.other2.com\"}]"); + verifyExceptionEqual( + "www.other2.org", + cert, + "DNS host \"www.other2.org\" doesn't correspond " + + "to certificate CN \"*.mariadb.org\" and SAN[{DNS:\"*.other.org\"},{DNS:\"a*b.other2.com\"}]"); + DefaultHostnameVerifier.verify("ab.other2.com", cert, -1); + DefaultHostnameVerifier.verify("axxxxb.other2.com", cert, -1); + verifyExceptionEqual( + "axxxxbc.other2.org", + cert, + "DNS host \"axxxxbc.other2.org\" doesn't " + + "correspond to certificate CN \"*.mariadb.org\" and SAN[{DNS:\"*.other.org\"},{DNS:\"a*b.other2.com\"}]"); + verifyExceptionEqual( + "caxxxxb.other2.org", + cert, + "DNS host \"caxxxxb.other2.org\" doesn't " + + "correspond to certificate CN \"*.mariadb.org\" and SAN[{DNS:\"*.other.org\"},{DNS:\"a*b.other2.com\"}]"); + verifyExceptionEqual( + "a.axxxxb.other2.org", + cert, + "DNS host \"a.axxxxb.other2.org\" doesn't " + + "correspond to certificate CN \"*.mariadb.org\" and SAN[{DNS:\"*.other.org\"},{DNS:\"a*b.other2.com\"}]"); + } +} diff --git a/src/test/java/org/mariadb/r2dbc/unit/util/BufferUtilsTest.java b/src/test/java/org/mariadb/r2dbc/unit/util/BufferUtilsTest.java new file mode 100644 index 00000000..5805e7fa --- /dev/null +++ b/src/test/java/org/mariadb/r2dbc/unit/util/BufferUtilsTest.java @@ -0,0 +1,248 @@ +package org.mariadb.r2dbc.unit.util; + +import static org.junit.jupiter.api.Assertions.*; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufAllocator; +import java.nio.charset.StandardCharsets; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mariadb.r2dbc.client.Context; +import org.mariadb.r2dbc.util.BufferUtils; +import org.mariadb.r2dbc.util.constants.ServerStatus; + +class BufferUtilsTest { + + ByteBufAllocator allocator = ByteBufAllocator.DEFAULT; + + @Test + void skipLengthEncode() { + ByteBuf buf = allocator.buffer(1000); + buf.setBytes(0, new byte[] {0, 1}); + buf.writerIndex(1000); + BufferUtils.skipLengthEncode(buf); + assertEquals(1, buf.readByte()); + + byte[] b = new byte[500]; + b[0] = (byte) 252; + b[1] = 1; + b[2] = 0; + b[3] = 2; + b[4] = 3; + buf.resetReaderIndex(); + buf.setBytes(0, b); + buf.writerIndex(1000); + + BufferUtils.skipLengthEncode(buf); + assertEquals(4, buf.readerIndex()); + + b = new byte[500]; + b[0] = (byte) 253; + b[1] = 1; + b[2] = 0; + b[3] = 0; + b[4] = 1; + buf.resetReaderIndex(); + buf.setBytes(0, b); + buf.writerIndex(1000); + + BufferUtils.skipLengthEncode(buf); + assertEquals(5, buf.readerIndex()); + + b = new byte[500]; + b[0] = (byte) 254; + b[1] = 1; + b[2] = 0; + b[3] = 0; + b[4] = 0; + b[5] = 0; + b[6] = 0; + b[7] = 0; + b[8] = 0; + b[9] = 1; + buf.resetReaderIndex(); + buf.setBytes(0, b); + buf.writerIndex(1000); + + BufferUtils.skipLengthEncode(buf); + assertEquals(10, buf.readerIndex()); + } + + @Test + void readLengthEncodedInt() { + ByteBuf buf = allocator.buffer(1000); + buf.setBytes(0, new byte[] {0, 1}); + buf.writerIndex(1000); + BufferUtils.skipLengthEncode(buf); + assertEquals(1, buf.readByte()); + + byte[] b = new byte[500]; + b[0] = (byte) 252; + b[1] = 1; + b[2] = 0; + b[3] = 2; + b[4] = 3; + buf.resetReaderIndex(); + buf.setBytes(0, b); + buf.writerIndex(1000); + + assertEquals(1, BufferUtils.readLengthEncodedInt(buf)); + + b = new byte[500]; + b[0] = (byte) 253; + b[1] = 1; + b[2] = 0; + b[3] = 0; + b[4] = 1; + buf.resetReaderIndex(); + buf.setBytes(0, b); + buf.writerIndex(1000); + + assertEquals(1, BufferUtils.readLengthEncodedInt(buf)); + + b = new byte[500]; + b[0] = (byte) 254; + b[1] = 1; + b[2] = 0; + b[3] = 0; + b[4] = 0; + b[5] = 0; + b[6] = 0; + b[7] = 0; + b[8] = 0; + b[9] = 1; + buf.resetReaderIndex(); + buf.setBytes(0, b); + buf.writerIndex(1000); + + assertEquals(1, BufferUtils.readLengthEncodedInt(buf)); + + b = new byte[500]; + b[0] = (byte) 251; + + buf.resetReaderIndex(); + buf.setBytes(0, b); + buf.writerIndex(1000); + + assertEquals(-1, BufferUtils.readLengthEncodedInt(buf)); + } + + @Test + void readLengthEncodedString() { + ByteBuf buf = allocator.buffer(1000); + buf.setBytes(0, new byte[] {0, 1}); + buf.writerIndex(1000); + BufferUtils.skipLengthEncode(buf); + assertEquals(1, buf.readByte()); + + byte[] b = new byte[500]; + b[0] = (byte) 251; + buf.resetReaderIndex(); + buf.setBytes(0, b); + buf.writerIndex(1000); + assertNull(BufferUtils.readLengthEncodedString(buf)); + + b = new byte[500]; + b[0] = (byte) 2; + b[1] = (byte) 65; + b[2] = (byte) 66; + buf.resetReaderIndex(); + buf.setBytes(0, b); + buf.writerIndex(1000); + assertEquals("AB", BufferUtils.readLengthEncodedString(buf)); + } + + @Test + void readLengthEncodedBuffer() { + ByteBuf buf = allocator.buffer(1000); + buf.setBytes(0, new byte[] {0, 1}); + buf.writerIndex(1000); + BufferUtils.skipLengthEncode(buf); + assertEquals(1, buf.readByte()); + + byte[] b = new byte[500]; + b[0] = (byte) 251; + buf.resetReaderIndex(); + buf.setBytes(0, b); + buf.writerIndex(1000); + assertNull(BufferUtils.readLengthEncodedBuffer(buf)); + + b = new byte[500]; + b[0] = (byte) 2; + b[1] = (byte) 65; + b[2] = (byte) 66; + buf.resetReaderIndex(); + buf.setBytes(0, b); + buf.writerIndex(1000); + ByteBuf bb = BufferUtils.readLengthEncodedBuffer(buf); + byte[] res = new byte[2]; + bb.getBytes(0, res); + assertArrayEquals("AB".getBytes(StandardCharsets.UTF_8), res); + } + + @Test + void write() { + Context ctxNoBackSlash = + new Context("10.5.5-mariadb", 1, 1, ServerStatus.NO_BACKSLASH_ESCAPES, true); + Context ctx = new Context("10.5.5-mariadb", 1, 1, (short) 0, true); + + ByteBuf buf = allocator.buffer(1000); + buf.writerIndex(0); + BufferUtils.write(buf, "A'\"\0\\€'\"\0\\", false, ctxNoBackSlash); + byte[] res = new byte[buf.writerIndex()]; + buf.getBytes(0, res); + assertArrayEquals("A''\"\0\\€''\"\0\\".getBytes(StandardCharsets.UTF_8), res); + + buf.writerIndex(0); + BufferUtils.write(buf, "A'\"\0\\€'\"\0\\", false, ctx); + res = new byte[buf.writerIndex()]; + buf.getBytes(0, res); + assertArrayEquals("A\\'\\\"\\\0\\\\€\\'\\\"\\\0\\\\".getBytes(StandardCharsets.UTF_8), res); + + final byte[] utf8Wrong2bytes = new byte[] {0x08, (byte) 0xFF, (byte) 0x6F, (byte) 0x6F}; + final byte[] utf8Wrong3bytes = + new byte[] {0x07, (byte) 0x0a, (byte) 0xff, (byte) 0x6F, (byte) 0x6F}; + final byte[] utf8Wrong4bytes = + new byte[] {0x10, (byte) 0x20, (byte) 0x0a, (byte) 0xff, (byte) 0x6F, (byte) 0x6F}; + final byte[] utf8Wrong4bytes2 = new byte[] {-16, (byte) -97, (byte) -103}; + + buf.writerIndex(0); + BufferUtils.write(buf, new String(utf8Wrong2bytes, StandardCharsets.UTF_8), false, ctx); + res = new byte[buf.writerIndex()]; + buf.getBytes(0, res); + assertArrayEquals(new byte[] {8, -17, -65, -67, 111, 111}, res); + + buf.writerIndex(0); + BufferUtils.write(buf, new String(utf8Wrong3bytes, StandardCharsets.UTF_8), false, ctx); + res = new byte[buf.writerIndex()]; + buf.getBytes(0, res); + assertArrayEquals(new byte[] {7, 10, -17, -65, -67, 111, 111}, res); + + buf.writerIndex(0); + BufferUtils.write(buf, new String(utf8Wrong4bytes, StandardCharsets.UTF_8), false, ctx); + res = new byte[buf.writerIndex()]; + buf.getBytes(0, res); + assertArrayEquals(new byte[] {16, 32, 10, -17, -65, -67, 111, 111}, res); + + buf.writerIndex(0); + BufferUtils.write(buf, new String(utf8Wrong4bytes2, StandardCharsets.UTF_8), false, ctx); + res = new byte[buf.writerIndex()]; + buf.getBytes(0, res); + assertArrayEquals(new byte[] {-17, -65, -67}, res); + } + + @Test + void toStringBuf() { + ByteBuf buf = allocator.buffer(1000); + buf.setBytes( + 0, + new byte[] { + 0x6d, 0x00, 0x00, 0x00, 0x0a, 0x35, 0x2e, 0x35, 0x2e, 0x35, 0x2d, 0x31, 0x30, 0x2e, 0x36, + 0x2e + }); + buf.readerIndex(0); + System.out.println(buf.readerIndex()); + buf.writerIndex(16); + Assertions.assertEquals("6D0000000A352E352E352D31302E362E", BufferUtils.toString(buf)); + } +} diff --git a/src/test/java/org/mariadb/r2dbc/unit/util/ClientPrepareResultTest.java b/src/test/java/org/mariadb/r2dbc/unit/util/ClientPrepareResultTest.java index 79d7550c..2e45a5e8 100644 --- a/src/test/java/org/mariadb/r2dbc/unit/util/ClientPrepareResultTest.java +++ b/src/test/java/org/mariadb/r2dbc/unit/util/ClientPrepareResultTest.java @@ -38,38 +38,112 @@ private void checkParsing( Assertions.assertEquals(partsMulti[i], new String(res.getQueryParts().get(i))); } Assertions.assertEquals(allowMultiqueries, res.isQueryMultipleRewritable()); + + res = ClientPrepareResult.parameterParts(sql, true); + Assertions.assertEquals(paramNumber, res.getParamCount()); + Assertions.assertEquals(returning, res.isReturning()); + Assertions.assertEquals(supportReturningAddition, res.supportAddingReturning()); + + for (int i = 0; i < partsMulti.length; i++) { + Assertions.assertEquals(partsMulti[i], new String(res.getQueryParts().get(i))); + } + Assertions.assertEquals(allowMultiqueries, res.isQueryMultipleRewritable()); + } + + private void checkParsing( + String sql, + int paramNumber, + int paramNumberBackSlash, + boolean allowMultiqueries, + boolean returning, + boolean supportReturningAddition, + String[] partsMulti, + String[] partsMultiBackSlash) { + ClientPrepareResult res = ClientPrepareResult.parameterParts(sql, false); + Assertions.assertEquals(paramNumber, res.getParamCount()); + Assertions.assertEquals(returning, res.isReturning()); + Assertions.assertEquals(supportReturningAddition, res.supportAddingReturning()); + + for (int i = 0; i < partsMulti.length; i++) { + Assertions.assertEquals(partsMulti[i], new String(res.getQueryParts().get(i))); + } + Assertions.assertEquals(allowMultiqueries, res.isQueryMultipleRewritable()); + + res = ClientPrepareResult.parameterParts(sql, true); + Assertions.assertEquals(paramNumberBackSlash, res.getParamCount()); + Assertions.assertEquals(returning, res.isReturning()); + Assertions.assertEquals(supportReturningAddition, res.supportAddingReturning()); + + for (int i = 0; i < partsMultiBackSlash.length; i++) { + Assertions.assertEquals(partsMultiBackSlash[i], new String(res.getQueryParts().get(i))); + } } @Test public void stringEscapeParsing() throws Exception { checkParsing( - "select '\\'' as a, ? as b, \"\\\"\" as c, ? as d", + "select '\\'\"`/*#' as a, ? as \\b, \"\\\"'returningInsertDeleteUpdate\" as c, ? as d", 2, + 1, true, false, false, - new String[] {"select '\\'' as a, ", " as b, \"\\\"\" as c, ", " as d"}); + new String[] { + "select '\\'\"`/*#' as a, ", + " as \\b, \"\\\"'returningInsertDeleteUpdate\" as c, ", + " as d" + }, + new String[] { + "select '\\'\"`/*#' as a, ? as \\b, \"\\\"'returningInsertDeleteUpdate\" as c, ", " as d" + }); } @Test public void testRewritableWithConstantParameter() throws Exception { checkParsing( - "INSERT INTO TABLE(col1,col2,col3,col4, col5) VALUES (9, ?, 5, ?, 8) ON DUPLICATE KEY UPDATE col2=col2+10", + "INSERT INTO TABLE_INSERT(col1,col2,col3,col4, col5) VALUES (9, ?, 5, ?, 8) ON DUPLICATE KEY UPDATE col2=col2+10", 2, true, false, true, new String[] { - "INSERT INTO TABLE(col1,col2,col3,col4, col5) VALUES (9, ", + "INSERT INTO TABLE_INSERT(col1,col2,col3,col4, col5) VALUES (9, ", ", 5, ", ", 8) ON DUPLICATE KEY UPDATE col2=col2+10" }); } + @Test + public void testNamedParam() throws Exception { + checkParsing( + "SELECT * FROM TABLE WHERE 1 = :firstParam AND 3 = ':para' and 2 = :secondParam", + 2, + true, + false, + false, + new String[] {"SELECT * FROM TABLE WHERE 1 = ", " AND 3 = ':para' and 2 = ", ""}); + } + + @Test + public void stringEscapeParsing2() throws Exception { + checkParsing( + "SELECT '\\\\test' /*test* #/ ;`*/", + 0, + true, + false, + false, + new String[] {"SELECT '\\\\test' /*test* #/ ;`*/"}); + } + + @Test + public void stringEscapeParsing3() throws Exception { + checkParsing("DO '\\\"', \"\\'\"", 0, true, false, false, new String[] {"DO '\\\"', \"\\'\""}); + } + @Test public void testComment() throws Exception { checkParsing( - "/* insert Select INSERT INTO tt VALUES (?,?,?,?) */" + "/* insert Select INSERT INTO tt VALUES (?,?,?,?) insert update delete select returning */" + " INSERT into " + "/* insert Select INSERT INTO tt VALUES (?,?,?,?) */" + " tt VALUES " @@ -81,7 +155,7 @@ public void testComment() throws Exception { false, true, new String[] { - "/* insert Select INSERT INTO tt VALUES (?,?,?,?) */" + "/* insert Select INSERT INTO tt VALUES (?,?,?,?) insert update delete select returning */" + " INSERT into " + "/* insert Select INSERT INTO tt VALUES (?,?,?,?) */" + " tt VALUES " @@ -135,6 +209,39 @@ public void testUpdate() throws Exception { new String[] {"UPDATE MultiTestt4 SET test = ", " WHERE test = ", ""}); } + @Test + public void testUpdate2() throws Exception { + checkParsing( + "UPDATE UpdateMultiTestt4UPDATE() SET test = ? WHERE test = ?", + 2, + true, + false, + true, + new String[] {"UPDATE UpdateMultiTestt4UPDATE() SET test = ", " WHERE test = ", ""}); + } + + @Test + public void testDelete() throws Exception { + checkParsing( + "DELETE FROM MultiTestt4 WHERE test = ?", + 1, + true, + false, + true, + new String[] {"DELETE FROM MultiTestt4 WHERE test = ", ""}); + } + + @Test + public void testDelete2() throws Exception { + checkParsing( + "DELETE FROM DELETEMultiTestt4DELETE WHERE test = ?", + 1, + true, + false, + true, + new String[] {"DELETE FROM DELETEMultiTestt4DELETE WHERE test = ", ""}); + } + @Test public void testInsertSelect() throws Exception { checkParsing( @@ -236,10 +343,12 @@ public void testEscapeInString() throws Exception { checkParsing( "INSERT INTO tt (tt) VALUES (?, '\\'?', \"\\\"?\") --fin", 1, + 2, false, false, true, - new String[] {"INSERT INTO tt (tt) VALUES (", ", '\\'?', \"\\\"?\") --fin"}); + new String[] {"INSERT INTO tt (tt) VALUES (", ", '\\'?', \"\\\"?\") --fin"}, + new String[] {"INSERT INTO tt (tt) VALUES (", ", '\\'", "', \"\\\"?\") --fin"}); } @Test @@ -364,12 +473,25 @@ public void testValuesForPartition() throws Exception { }); } + @Test + public void testEolskip() throws Exception { + checkParsing( + "CREATE TABLE tt \n # test \n(ID INT)", + 0, + true, + false, + false, + new String[] {"CREATE TABLE tt \n # test \n(ID INT)"}); + } + @Test public void hasParameter() { Assertions.assertTrue(ClientPrepareResult.hasParameter("SELECT ?", false)); + Assertions.assertFalse(ClientPrepareResult.hasParameter("SELECT \n / /* /* / # ? */", false)); Assertions.assertTrue(ClientPrepareResult.hasParameter("SELECT :param", false)); Assertions.assertFalse(ClientPrepareResult.hasParameter("SELECT ':param''", false)); - Assertions.assertFalse(ClientPrepareResult.hasParameter("SELECT '?'", false)); + Assertions.assertFalse(ClientPrepareResult.hasParameter("SELECT '?\\''", false)); + Assertions.assertFalse(ClientPrepareResult.hasParameter("SELECT \"\\\"?\"", false)); Assertions.assertFalse(ClientPrepareResult.hasParameter("SELECT \"?\"", false)); Assertions.assertFalse(ClientPrepareResult.hasParameter("SELECT \"\\?\"", false)); Assertions.assertFalse(ClientPrepareResult.hasParameter("SELECT `?`", false)); @@ -377,5 +499,6 @@ public void hasParameter() { Assertions.assertFalse(ClientPrepareResult.hasParameter("SELECT //?\n '?'", false)); Assertions.assertFalse(ClientPrepareResult.hasParameter("SELECT #? \n '?'", false)); Assertions.assertFalse(ClientPrepareResult.hasParameter("SELECT --? \n '?'", false)); + Assertions.assertFalse(ClientPrepareResult.hasParameter("SELECT '`\\n' from `gg`", true)); } } diff --git a/src/test/java/org/mariadb/r2dbc/unit/util/DefaultHostnameVerifierTest.java b/src/test/java/org/mariadb/r2dbc/unit/util/DefaultHostnameVerifierTest.java index e43c0398..6f45dab3 100644 --- a/src/test/java/org/mariadb/r2dbc/unit/util/DefaultHostnameVerifierTest.java +++ b/src/test/java/org/mariadb/r2dbc/unit/util/DefaultHostnameVerifierTest.java @@ -28,8 +28,6 @@ public class DefaultHostnameVerifierTest { - private final DefaultHostnameVerifier verifier = new DefaultHostnameVerifier(); - private static X509Certificate getCertificate(String certString) throws CertificateException { CertificateFactory cf = CertificateFactory.getInstance("X.509"); return (X509Certificate) @@ -38,7 +36,7 @@ private static X509Certificate getCertificate(String certString) throws Certific private void verifyExceptionEqual(String host, X509Certificate cert, String exceptionMessage) { try { - verifier.verify(host, cert, -1); + DefaultHostnameVerifier.verify(host, cert, -1); Assertions.fail("must have failed"); } catch (SSLException exception) { Assertions.assertEquals(exceptionMessage, exception.getMessage()); @@ -80,7 +78,7 @@ public void verifyCn() throws Exception { + "UEjb+vAN7FxXzXzH4oqIeycnxP+/MA82iieew7nlOMlYrppM6igjP0CUzw4ys6lG\n" + "8QdWBcm2Ybo4XFjOnC98VlQl+WBu4CiToxjGphDmsMIO3Hf5PSTRwTKxtuWn45Y=\n" + "-----END CERTIFICATE-----\n"); - verifier.verify("test.com", cert, -1); + DefaultHostnameVerifier.verify("test.com", cert, -1); verifyExceptionEqual( "a.test.com", cert, @@ -117,7 +115,7 @@ public void verifyNonAsciiCn() throws Exception { + "x51XCozrD1yW9JK/YyBnjYk04iEfQLW7+pGMJOcsX7x9EGwpEg1gsDg2mM0EEIwU\n" + "d6DHlYvpD9JkzyEScg8Supztoc2aGbGE4SHBKB1riTLBAHWqqwas4sGSgZxu\n" + "-----END CERTIFICATE-----\n"); - verifier.verify("😎.com", cert, -1); + DefaultHostnameVerifier.verify("😎.com", cert, -1); verifyExceptionEqual( "a.😎.com", cert, @@ -166,19 +164,19 @@ public void verifySubjectAlt() throws Exception { cert, "DNS host \"mariadb.org\" doesn't correspond to certificate " + "CN \"*.mariadb.org\" and SAN[{DNS:\"other.org\"},{DNS:\"www.other.org\"}]"); - verifier.verify("a.mariadb.org", cert, -1); + DefaultHostnameVerifier.verify("a.mariadb.org", cert, -1); verifyExceptionEqual( "a.other2.org", cert, "DNS host \"a.other2.org\" doesn't correspond to certificate " + "CN \"*.mariadb.org\" and SAN[{DNS:\"other.org\"},{DNS:\"www.other.org\"}]"); - verifier.verify("other.org", cert, -1); + DefaultHostnameVerifier.verify("other.org", cert, -1); verifyExceptionEqual( "a.other.org", cert, "DNS host \"a.other.org\" doesn't correspond to certificate " + "CN \"*.mariadb.org\" and SAN[{DNS:\"other.org\"},{DNS:\"www.other.org\"}]"); - verifier.verify("www.other.org", cert, -1); + DefaultHostnameVerifier.verify("www.other.org", cert, -1); } @Test @@ -212,7 +210,7 @@ public void verifySubjectAltOnly() throws Exception { + "qAVqixM+J0qJmQStgAc53i2aTMvAQu3A3snvH/PHTBo+5UL72n9S1kZyNCsVf1Qo\n" + "n8jKTiRriEM+fMFlcgQP284EBFzYHyCXFb9O/hMjK2+6mY9euMB1U1aFFzM/Bg==\n" + "-----END CERTIFICATE-----\n"); - verifier.verify("foo.com", cert, -1); + DefaultHostnameVerifier.verify("foo.com", cert, -1); verifyExceptionEqual( "a.foo.com", cert, @@ -248,7 +246,7 @@ public void verifyMultipleCn() throws Exception { + "A94gKVaU6XS6EdDGc6oSfKAR/pqKnWAmDc0ofvYniojquzm4fUO3JgzXN/xTDPUc\n" + "GiY3dV92GD9wZfbUWsQRzLizRzIrsvZfCn/LLeUvOQPuCCeLzIxD\n" + "-----END CERTIFICATE-----\n"); - verifier.verify("test1.org", cert, -1); + DefaultHostnameVerifier.verify("test1.org", cert, -1); verifyExceptionEqual( "test2.org", cert, @@ -290,8 +288,8 @@ public void verifyWilcardCn() throws Exception { "foo.com", cert, "DNS host \"foo.com\" doesn't correspond to certificate " + "CN \"*.foo.com\""); - verifier.verify("www.foo.com", cert, -1); - verifier.verify("花子.foo.com", cert, -1); + DefaultHostnameVerifier.verify("www.foo.com", cert, -1); + DefaultHostnameVerifier.verify("花子.foo.com", cert, -1); verifyExceptionEqual( "a.b.foo.com", cert, @@ -330,8 +328,8 @@ public void verifyWilcardCnOnTld() throws Exception { + "UGPLEUDzRHMPHLnSqT1n5UU5UDRytbjJPXzF+l/+WZIsanefWLsxnkgAuZe/oMMF\n" + "EJMryEzOjg4Tfuc5qM0EXoPcQ/JlheaxZ40p2IyHqbsWV4MRYuFH4bkM\n" + "-----END CERTIFICATE-----\n"); - verifier.verify("foo.co.jp", cert, -1); - verifier.verify("花子.co.jp", cert, -1); + DefaultHostnameVerifier.verify("foo.co.jp", cert, -1); + DefaultHostnameVerifier.verify("花子.co.jp", cert, -1); } @Test @@ -366,15 +364,15 @@ public void subjectAltUsesLocalDomainAndIp() throws Exception { new X500Principal("CN=*.mariadb.org, O=\"Acme, Inc.\", L=SZ, ST=GD, C=CN"), cert.getSubjectX500Principal()); - verifier.verify("localhost", cert, -1); - verifier.verify("localhost.localdomain", cert, -1); + DefaultHostnameVerifier.verify("localhost", cert, -1); + DefaultHostnameVerifier.verify("localhost.localdomain", cert, -1); verifyExceptionEqual( "local.host", cert, "DNS host \"local.host\" doesn't correspond to certificate " + "CN \"*.mariadb.org\" and SAN[{DNS:\"localhost.localdomain\"},{DNS:\"localhost\"},{IP:\"127.0.0.1\"}]"); - verifier.verify("127.0.0.1", cert, -1); + DefaultHostnameVerifier.verify("127.0.0.1", cert, -1); verifyExceptionEqual( "127.0.0.2", cert, @@ -447,7 +445,7 @@ public void subjectAltNameWithWildcard() throws Exception { cert, "DNS host \"other.org\" doesn't correspond " + "to certificate CN \"*.mariadb.org\" and SAN[{DNS:\"*.other.org\"},{DNS:\"a*b.other2.com\"}]"); - verifier.verify("www.other.org", cert, -1); + DefaultHostnameVerifier.verify("www.other.org", cert, -1); verifyExceptionEqual( "other2.org", cert, @@ -458,8 +456,8 @@ public void subjectAltNameWithWildcard() throws Exception { cert, "DNS host \"www.other2.org\" doesn't correspond " + "to certificate CN \"*.mariadb.org\" and SAN[{DNS:\"*.other.org\"},{DNS:\"a*b.other2.com\"}]"); - verifier.verify("ab.other2.com", cert, -1); - verifier.verify("axxxxb.other2.com", cert, -1); + DefaultHostnameVerifier.verify("ab.other2.com", cert, -1); + DefaultHostnameVerifier.verify("axxxxb.other2.com", cert, -1); verifyExceptionEqual( "axxxxbc.other2.org", cert, diff --git a/src/test/java/org/mariadb/r2dbc/unit/util/ServerPrepareResultTest.java b/src/test/java/org/mariadb/r2dbc/unit/util/ServerPrepareResultTest.java new file mode 100644 index 00000000..cb24a609 --- /dev/null +++ b/src/test/java/org/mariadb/r2dbc/unit/util/ServerPrepareResultTest.java @@ -0,0 +1,20 @@ +package org.mariadb.r2dbc.unit.util; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mariadb.r2dbc.message.server.ColumnDefinitionPacket; +import org.mariadb.r2dbc.util.ServerPrepareResult; + +public class ServerPrepareResultTest { + @Test + public void equalsTest() throws Exception { + ServerPrepareResult prepare = new ServerPrepareResult(1, 2, new ColumnDefinitionPacket[0]); + Assertions.assertEquals(prepare, prepare); + Assertions.assertEquals(prepare, new ServerPrepareResult(1, 2, new ColumnDefinitionPacket[0])); + Assertions.assertNotEquals( + prepare, new ServerPrepareResult(2, 2, new ColumnDefinitionPacket[0])); + Assertions.assertEquals(32, prepare.hashCode()); + Assertions.assertFalse(prepare.equals(null)); + Assertions.assertFalse(prepare.equals("dd")); + } +} From bbdb24fe9c763d6a27d613b72479ea089b350ff4 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Thu, 1 Jul 2021 18:20:30 +0200 Subject: [PATCH 19/20] [misc] ensure timeout test are not stalling --- README.md | 5 +- .../r2dbc/integration/ConnectionTest.java | 105 ++++++++++-------- .../r2dbc/integration/ResultsetTest.java | 54 +++++---- 3 files changed, 97 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index e3c3b4f2..2745b944 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![Maven Central][maven-image]][maven-url] [![Test Build][travis-image]][travis-url] [![License][license-image]][license-url] - +[![codecov][codecov-image]][codecov-url] **Non-blocking MariaDB and MySQL client.** @@ -107,6 +107,7 @@ Basic example: | **`prepareCacheSize`** | if useServerPrepStmts = true, cache the prepared informations in a LRU cache to avoid re-preparation of command. Next use of that command, only prepared identifier and parameters (if any) will be sent to server. This mainly permit for server to avoid reparsing query. |*int* |256 | | **`pamOtherPwd`** | Permit to provide additional password for PAM authentication with multiple authentication step. If multiple passwords, value must be URL encoded.|*string* | | | **`autocommit`** | Set default autocommit value on connection initialization" |*boolean* | true | +| **`tinyInt1isBit`** | Convert Bit(1)/TINYINT(1) default to boolean type |*boolean* | true | ## Roadmap @@ -127,3 +128,5 @@ To file an issue or follow the development, see [JIRA](https://jira.mariadb.org/ [maven-url]:https://maven-badges.herokuapp.com/maven-central/org.mariadb/r2dbc-mariadb [license-image]:https://img.shields.io/badge/License-Apache%202.0-blue.svg [license-url]:https://opensource.org/licenses/Apache-2.0 +[codecov-image]:https://codecov.io/gh/mariadb-corporation/mariadb-connector-r2dbc/branch/master/graph/badge.svg?token=8fIhax7q23 +[codecov-url]:https://codecov.io/gh/mariadb-corporation/mariadb-connector-r2dbc diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java index 9bb6787e..d20360c2 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java @@ -90,7 +90,7 @@ void connectionError() throws Exception { && !"skysql".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv"))); - disableLog(); + //disableLog(); MariadbConnection connection = createProxyCon(); try { proxy.stop(); @@ -105,7 +105,7 @@ void connectionError() throws Exception { "real msg:" + t.getMessage()); } finally { Thread.sleep(100); - reInitLog(); + //reInitLog(); } } @@ -116,7 +116,7 @@ void multipleCommandStack() throws Exception { && !"skysql".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv"))); - disableLog(); + //disableLog(); MariadbConnection connection = createProxyCon(); Runnable runnable = () -> proxy.stop(); Thread th = new Thread(runnable); @@ -141,7 +141,7 @@ void multipleCommandStack() throws Exception { "real msg:" + t.getCause().getMessage()); } finally { Thread.sleep(100); - reInitLog(); + //reInitLog(); proxy.forceClose(); } } @@ -152,11 +152,11 @@ void connectionWithoutErrorOnClose() throws Exception { !"maxscale".equals(System.getenv("srv")) && !"skysql".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv"))); - disableLog(); + //disableLog(); MariadbConnection connection = createProxyCon(); proxy.stop(); connection.close().block(); - reInitLog(); + //reInitLog(); } @Test @@ -165,7 +165,7 @@ void connectionDuringError() throws Exception { !"maxscale".equals(System.getenv("srv")) && !"skysql".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv"))); - disableLog(); + //disableLog(); MariadbConnection connection = createProxyCon(); new Timer() .schedule( @@ -177,29 +177,31 @@ public void run() { }, 200); - try { - connection - .createStatement( - "select * from information_schema.columns as c1, " - + "information_schema.tables, information_schema.tables as t2") - .execute() - .flatMap(r -> r.map((rows, meta) -> "")) - .blockLast(); - Assertions.fail("must have throw exception"); - } catch (Throwable t) { - Assertions.assertEquals(R2dbcNonTransientResourceException.class, t.getClass()); - Assertions.assertTrue( - t.getMessage().contains("Connection is close. Cannot send anything") - || t.getMessage().contains("Connection unexpectedly closed") - || t.getMessage().contains("Connection unexpected error"), - "real msg:" + t.getMessage()); - connection - .validate(ValidationDepth.LOCAL) - .as(StepVerifier::create) - .expectNext(Boolean.FALSE) - .verifyComplete(); - reInitLog(); - } + assertTimeout(Duration.ofSeconds(2), () -> { + try { + connection + .createStatement( + "select * from information_schema.columns as c1, " + + "information_schema.tables, information_schema.tables as t2") + .execute() + .flatMap(r -> r.map((rows, meta) -> "")) + .blockLast(); + Assertions.fail("must have throw exception"); + } catch (Throwable t) { + Assertions.assertEquals(R2dbcNonTransientResourceException.class, t.getClass()); + Assertions.assertTrue( + t.getMessage().contains("Connection is close. Cannot send anything") + || t.getMessage().contains("Connection unexpectedly closed") + || t.getMessage().contains("Connection unexpected error"), + "real msg:" + t.getMessage()); + connection + .validate(ValidationDepth.LOCAL) + .as(StepVerifier::create) + .expectNext(Boolean.FALSE) + .verifyComplete(); + //reInitLog(); + } + }); } @Test @@ -452,7 +454,7 @@ void multiThreading() throws Throwable { @Test void multiThreadingSameConnection() throws Throwable { - disableLog(); + //disableLog(); try { AtomicInteger completed = new AtomicInteger(0); ThreadPoolExecutor scheduler = @@ -469,7 +471,7 @@ void multiThreadingSameConnection() throws Throwable { Assertions.assertEquals(100, completed.get()); } finally { Thread.sleep(100); - reInitLog(); + //reInitLog(); } } @@ -517,8 +519,8 @@ void sessionVariables() throws Exception { (row, metadata) -> { Assertions.assertEquals(row.get(0, BigInteger.class).intValue(), 2147483); Assertions.assertEquals(row.get(1, BigInteger.class).intValue(), 60); - Assertions.assertFalse(row.get(0, BigInteger.class).equals(res[0])); - Assertions.assertFalse(row.get(1, BigInteger.class).equals(res[1])); + Assertions.assertNotEquals(row.get(0, BigInteger.class).intValue(), res[0].intValue()); + Assertions.assertNotEquals(row.get(1, BigInteger.class).intValue(), res[1].intValue()); return 0; })) .blockLast(); @@ -835,7 +837,7 @@ public void initialIsolationLevel() { } @Test - public void errorOnConnection() { + public void errorOnConnection() throws Throwable { BigInteger maxConn = sharedConn .createStatement("select @@max_connections") @@ -865,6 +867,7 @@ public void errorOnConnection() { } Assertions.assertNotNull(expected); Assertions.assertTrue(expected.getMessage().contains("Too many connections")); + Thread.sleep(1000); } @Test @@ -887,17 +890,31 @@ void killedConnection() { }; Thread thread = new Thread(runnable); thread.start(); - assertThrows( - R2dbcNonTransientResourceException.class, - () -> - connection + assertTimeout(Duration.ofSeconds(2), () -> { + try { + connection .createStatement( - "select * from information_schema.columns as c1, " - + "information_schema.tables, " - + "information_schema.tables as t2") + "select * from information_schema.columns as c1, " + + "information_schema.tables, information_schema.tables as t2") .execute() - .blockLast(), - "Connection unexpectedly closed"); + .flatMap(r -> r.map((rows, meta) -> "")) + .blockLast(); + Assertions.fail("must have throw exception"); + } catch (Throwable t) { + Assertions.assertEquals(R2dbcNonTransientResourceException.class, t.getClass()); + Assertions.assertTrue( + t.getMessage().contains("Connection is close. Cannot send anything") + || t.getMessage().contains("Connection unexpectedly closed") + || t.getMessage().contains("Connection unexpected error"), + "real msg:" + t.getMessage()); + connection + .validate(ValidationDepth.LOCAL) + .as(StepVerifier::create) + .expectNext(Boolean.FALSE) + .verifyComplete(); + //reInitLog(); + } + }); connection .validate(ValidationDepth.LOCAL) .as(StepVerifier::create) diff --git a/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java b/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java index ce9a126c..8531beca 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java @@ -23,9 +23,8 @@ import java.sql.SQLException; import java.util.Random; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Assumptions; -import org.junit.jupiter.api.Test; + +import org.junit.jupiter.api.*; import org.mariadb.r2dbc.BaseConnectionTest; import org.mariadb.r2dbc.api.MariadbConnection; import org.mariadb.r2dbc.api.MariadbStatement; @@ -34,6 +33,23 @@ public class ResultsetTest extends BaseConnectionTest { private static String vals = "azertyuiopqsdfghjklmwxcvbn"; + @BeforeAll + public static void before2() { + dropAll(); + sharedConn + .createStatement( + "CREATE TABLE prepare3 (t1 LONGTEXT, t2 LONGTEXT, t3 LONGTEXT, t4 LONGTEXT, t5 varchar(10))") + .execute() + .blockLast(); + } + + @AfterAll + public static void dropAll() { + sharedConn.createStatement("DROP TABLE prepare3").execute().blockLast(); + } + + + @Test void multipleResultSet() { sharedConn @@ -255,12 +271,13 @@ void getIndexToLow(MariadbConnection connection) { private String generateLongText(int len) { int leftLimit = 97; // letter 'a' int rightLimit = 122; // letter 'z' - Random random = new Random(); - return random - .ints(leftLimit, leftLimit + 1) // rightLimit + 1) - .limit(len) - .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) - .toString(); + StringBuilder sb = new StringBuilder(len); + Random random = new Random(); + + for (int i = 0; i < len; i++) { + sb.appendCodePoint(leftLimit + random.nextInt(rightLimit - leftLimit)); + } + return sb.toString(); } @Test @@ -272,22 +289,15 @@ public void skippingRes() throws SQLException { .flatMap(r -> r.map((row, metadata) -> row.get(0, BigInteger.class))) .blockLast(); Assumptions.assumeTrue(maxAllowedPacket.intValue() > 35_000_000); - sharedConn.createStatement("DROP TABLE IF EXISTS prepare3").execute().blockLast(); - sharedConn - .createStatement( - "CREATE TABLE prepare3 (t1 LONGTEXT, t2 LONGTEXT, t3 LONGTEXT, t4 LONGTEXT, t5 varchar(10))") - .execute() - .blockLast(); - skippingRes(sharedConn); - skippingRes(sharedConnPrepare); + String longText = generateLongText(20_000_000); + String mediumText = generateLongText(10_000_000); + String smallIntText = generateLongText(60_000); + skippingRes(sharedConn, longText, mediumText, smallIntText); + skippingRes(sharedConnPrepare, longText, mediumText, smallIntText); } - private void skippingRes(MariadbConnection con) { + private void skippingRes(MariadbConnection con, String longText, String mediumText, String smallIntText) { con.createStatement("TRUNCATE prepare3").execute().blockLast(); - String longText = generateLongText(20_000_000); - String mediumText = generateLongText(10_000_000); - String smallIntText = generateLongText(60_000); - con.createStatement("INSERT INTO prepare3 values (?,?,?,?,?)") .bind(0, longText) .bind(1, mediumText) From 4fa0d528b5b4a628730a1268605633fca74dde65 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Fri, 2 Jul 2021 11:23:33 +0200 Subject: [PATCH 20/20] [misc] update copyright --- CHANGELOG.md | 12 ++++++++++++ README.md | 2 +- intellij-style.xml | 15 ++------------- pom.xml | 17 +++-------------- .../java/org/mariadb/r2dbc/Common.java | 17 ++--------------- .../java/org/mariadb/r2dbc/Select_1.java | 17 ++--------------- .../org/mariadb/r2dbc/Select_10000_Rows.java | 17 ++--------------- .../org/mariadb/r2dbc/Select_1000_params.java | 17 ++--------------- .../java/org/mariadb/r2dbc/Select_1_user.java | 17 ++--------------- src/benchmark/resources/logback-test.xml | 15 ++------------- .../org/mariadb/r2dbc/ExceptionFactory.java | 17 ++--------------- .../java/org/mariadb/r2dbc/MariadbBatch.java | 17 ++--------------- ...riadbClientParameterizedQueryStatement.java | 17 ++--------------- .../mariadb/r2dbc/MariadbColumnMetadata.java | 17 ++--------------- .../org/mariadb/r2dbc/MariadbConnection.java | 17 ++--------------- .../r2dbc/MariadbConnectionConfiguration.java | 17 ++--------------- .../r2dbc/MariadbConnectionFactory.java | 17 ++--------------- .../MariadbConnectionFactoryMetadata.java | 17 ++--------------- .../MariadbConnectionFactoryProvider.java | 17 ++--------------- .../r2dbc/MariadbConnectionMetadata.java | 17 ++--------------- .../java/org/mariadb/r2dbc/MariadbResult.java | 17 ++--------------- .../java/org/mariadb/r2dbc/MariadbRow.java | 17 ++--------------- .../org/mariadb/r2dbc/MariadbRowMetadata.java | 17 ++--------------- ...riadbServerParameterizedQueryStatement.java | 17 ++--------------- .../r2dbc/MariadbSimpleQueryStatement.java | 17 ++--------------- src/main/java/org/mariadb/r2dbc/SslMode.java | 17 ++--------------- .../org/mariadb/r2dbc/api/MariadbBatch.java | 17 ++--------------- .../mariadb/r2dbc/api/MariadbConnection.java | 17 ++--------------- .../r2dbc/api/MariadbConnectionMetadata.java | 17 ++--------------- .../org/mariadb/r2dbc/api/MariadbResult.java | 17 ++--------------- .../mariadb/r2dbc/api/MariadbStatement.java | 17 ++--------------- .../authentication/AuthenticationPlugin.java | 17 ++--------------- .../r2dbc/authentication/ed25519/Utils.java | 17 ++--------------- .../authentication/ed25519/math/Constants.java | 17 ++--------------- .../authentication/ed25519/math/Curve.java | 17 ++--------------- .../authentication/ed25519/math/Encoding.java | 17 ++--------------- .../authentication/ed25519/math/Field.java | 17 ++--------------- .../ed25519/math/FieldElement.java | 17 ++--------------- .../ed25519/math/GroupElement.java | 17 ++--------------- .../math/ed25519/Ed25519FieldElement.java | 17 ++--------------- .../ed25519/Ed25519LittleEndianEncoding.java | 17 ++--------------- .../ed25519/math/ed25519/ScalarOps.java | 17 ++--------------- .../ed25519/spec/EdDSANamedCurveSpec.java | 17 ++--------------- .../ed25519/spec/EdDSANamedCurveTable.java | 17 ++--------------- .../ed25519/spec/EdDSAParameterSpec.java | 17 ++--------------- .../java/org/mariadb/r2dbc/client/Client.java | 17 ++--------------- .../org/mariadb/r2dbc/client/ClientBase.java | 17 ++--------------- .../org/mariadb/r2dbc/client/ClientImpl.java | 17 ++--------------- .../r2dbc/client/ClientPipelineImpl.java | 17 ++--------------- .../org/mariadb/r2dbc/client/CmdElement.java | 17 ++--------------- .../java/org/mariadb/r2dbc/client/Context.java | 17 ++--------------- .../org/mariadb/r2dbc/client/DecoderState.java | 17 ++--------------- .../r2dbc/client/DecoderStateInterface.java | 17 ++--------------- .../r2dbc/client/MariadbPacketDecoder.java | 17 ++--------------- .../r2dbc/client/MariadbPacketEncoder.java | 17 ++--------------- .../mariadb/r2dbc/client/ServerVersion.java | 17 ++--------------- .../mariadb/r2dbc/codec/BinaryRowDecoder.java | 17 ++--------------- .../java/org/mariadb/r2dbc/codec/Codec.java | 17 ++--------------- .../java/org/mariadb/r2dbc/codec/Codecs.java | 17 ++--------------- .../java/org/mariadb/r2dbc/codec/DataType.java | 17 ++--------------- .../org/mariadb/r2dbc/codec/Parameter.java | 17 ++--------------- .../org/mariadb/r2dbc/codec/RowDecoder.java | 17 ++--------------- .../mariadb/r2dbc/codec/TextRowDecoder.java | 17 ++--------------- .../r2dbc/codec/list/BigDecimalCodec.java | 17 ++--------------- .../r2dbc/codec/list/BigIntegerCodec.java | 17 ++--------------- .../mariadb/r2dbc/codec/list/BitSetCodec.java | 17 ++--------------- .../mariadb/r2dbc/codec/list/BlobCodec.java | 17 ++--------------- .../mariadb/r2dbc/codec/list/BooleanCodec.java | 17 ++--------------- .../r2dbc/codec/list/ByteArrayCodec.java | 17 ++--------------- .../mariadb/r2dbc/codec/list/ByteCodec.java | 17 ++--------------- .../mariadb/r2dbc/codec/list/ClobCodec.java | 17 ++--------------- .../mariadb/r2dbc/codec/list/DoubleCodec.java | 17 ++--------------- .../r2dbc/codec/list/DurationCodec.java | 17 ++--------------- .../mariadb/r2dbc/codec/list/FloatCodec.java | 17 ++--------------- .../org/mariadb/r2dbc/codec/list/IntCodec.java | 17 ++--------------- .../r2dbc/codec/list/LocalDateCodec.java | 17 ++--------------- .../r2dbc/codec/list/LocalDateTimeCodec.java | 17 ++--------------- .../r2dbc/codec/list/LocalTimeCodec.java | 17 ++--------------- .../mariadb/r2dbc/codec/list/LongCodec.java | 17 ++--------------- .../mariadb/r2dbc/codec/list/ShortCodec.java | 17 ++--------------- .../mariadb/r2dbc/codec/list/StreamCodec.java | 17 ++--------------- .../mariadb/r2dbc/codec/list/StringCodec.java | 17 ++--------------- .../message/client/AuthMoreRawPacket.java | 17 ++--------------- .../message/client/ClearPasswordPacket.java | 17 ++--------------- .../r2dbc/message/client/ClientMessage.java | 17 ++--------------- .../message/client/ClosePreparePacket.java | 17 ++--------------- .../message/client/Ed25519PasswordPacket.java | 17 ++--------------- .../r2dbc/message/client/ExecutePacket.java | 17 ++--------------- .../message/client/HandshakeResponse.java | 17 ++--------------- .../message/client/NativePasswordPacket.java | 17 ++--------------- .../r2dbc/message/client/PingPacket.java | 17 ++--------------- .../r2dbc/message/client/PreparePacket.java | 17 ++--------------- .../r2dbc/message/client/QueryPacket.java | 17 ++--------------- .../client/QueryWithParametersPacket.java | 17 ++--------------- .../r2dbc/message/client/QuitPacket.java | 17 ++--------------- .../client/RsaPublicKeyRequestPacket.java | 17 ++--------------- .../message/client/Sha256PasswordPacket.java | 17 ++--------------- .../client/Sha2PublicKeyRequestPacket.java | 17 ++--------------- .../r2dbc/message/client/SslRequestPacket.java | 17 ++--------------- .../r2dbc/message/flow/AuthenticationFlow.java | 17 ++--------------- .../flow/AuthenticationFlowPluginLoader.java | 17 ++--------------- .../message/flow/CachingSha2PasswordFlow.java | 17 ++--------------- .../message/flow/ClearPasswordPluginFlow.java | 17 ++--------------- .../flow/Ed25519PasswordPluginFlow.java | 17 ++--------------- .../message/flow/NativePasswordPluginFlow.java | 17 ++--------------- .../r2dbc/message/flow/PamPluginFlow.java | 17 ++--------------- .../message/flow/Sha256PasswordPluginFlow.java | 17 ++--------------- .../message/server/AuthMoreDataPacket.java | 17 ++--------------- .../r2dbc/message/server/AuthSwitchPacket.java | 17 ++--------------- .../message/server/ColumnCountPacket.java | 17 ++--------------- .../message/server/ColumnDefinitionPacket.java | 17 ++--------------- .../message/server/CompletePrepareResult.java | 17 ++--------------- .../r2dbc/message/server/EofPacket.java | 17 ++--------------- .../r2dbc/message/server/ErrorPacket.java | 17 ++--------------- .../message/server/InitialHandshakePacket.java | 17 ++--------------- .../mariadb/r2dbc/message/server/OkPacket.java | 17 ++--------------- .../message/server/PrepareResultPacket.java | 17 ++--------------- .../r2dbc/message/server/RowPacket.java | 17 ++--------------- .../r2dbc/message/server/Sequencer.java | 17 ++--------------- .../r2dbc/message/server/ServerMessage.java | 17 ++--------------- .../r2dbc/message/server/SkipPacket.java | 17 ++--------------- .../java/org/mariadb/r2dbc/util/Assert.java | 17 ++--------------- .../org/mariadb/r2dbc/util/BufferUtils.java | 17 ++--------------- .../r2dbc/util/ClientPrepareResult.java | 17 ++--------------- .../r2dbc/util/DefaultHostnameVerifier.java | 17 ++--------------- .../org/mariadb/r2dbc/util/PidFactory.java | 17 ++--------------- .../org/mariadb/r2dbc/util/PrepareCache.java | 17 ++--------------- .../org/mariadb/r2dbc/util/PrepareResult.java | 17 ++--------------- .../r2dbc/util/ServerPrepareResult.java | 17 ++--------------- .../java/org/mariadb/r2dbc/util/SslConfig.java | 17 ++--------------- .../r2dbc/util/constants/Capabilities.java | 17 ++--------------- .../r2dbc/util/constants/ColumnFlags.java | 17 ++--------------- .../r2dbc/util/constants/ServerStatus.java | 17 ++--------------- .../r2dbc/util/constants/StateChange.java | 17 ++--------------- .../io.r2dbc.spi.ConnectionFactoryProvider | 17 ++--------------- ...b.r2dbc.authentication.AuthenticationPlugin | 17 ++--------------- src/main/resources/project.properties | 18 +++--------------- .../org/mariadb/r2dbc/BaseConnectionTest.java | 17 ++--------------- src/test/java/org/mariadb/r2dbc/BaseTest.java | 17 ++--------------- .../org/mariadb/r2dbc/TestConfiguration.java | 17 ++--------------- .../mariadb/r2dbc/integration/BatchTest.java | 17 ++--------------- .../r2dbc/integration/BigResultSetTest.java | 17 ++--------------- .../r2dbc/integration/ConfigurationTest.java | 17 ++--------------- .../integration/ConnectionMetadataTest.java | 17 ++--------------- .../r2dbc/integration/ConnectionTest.java | 17 ++--------------- .../mariadb/r2dbc/integration/ErrorTest.java | 17 ++--------------- .../mariadb/r2dbc/integration/LoggingTest.java | 17 ++--------------- .../r2dbc/integration/MultiQueriesTest.java | 17 ++--------------- .../r2dbc/integration/NoPipelineTest.java | 17 ++--------------- .../integration/PrepareResultSetTest.java | 17 ++--------------- .../r2dbc/integration/ResultsetTest.java | 17 ++--------------- .../r2dbc/integration/RowMetadataTest.java | 17 ++--------------- .../integration/StatementBatchingTest.java | 17 ++--------------- .../r2dbc/integration/StatementTest.java | 17 ++--------------- .../org/mariadb/r2dbc/integration/TlsTest.java | 17 ++--------------- .../r2dbc/integration/TransactionTest.java | 17 ++--------------- .../authentication/Ed25519PluginTest.java | 17 ++--------------- .../authentication/PamPluginTest.java | 17 ++--------------- .../authentication/Sha256PluginTest.java | 17 ++--------------- .../integration/codec/BigIntegerParseTest.java | 17 ++--------------- .../r2dbc/integration/codec/BitParseTest.java | 17 ++--------------- .../r2dbc/integration/codec/BlobParseTest.java | 17 ++--------------- .../r2dbc/integration/codec/DateParseTest.java | 17 ++--------------- .../integration/codec/DateTimeParseTest.java | 17 ++--------------- .../integration/codec/DecimalParseTest.java | 17 ++--------------- .../integration/codec/DoubleParseTest.java | 17 ++--------------- .../integration/codec/FloatParseTest.java | 17 ++--------------- .../r2dbc/integration/codec/IntParseTest.java | 17 ++--------------- .../integration/codec/MediumIntParseTest.java | 17 ++--------------- .../integration/codec/ShortParseTest.java | 17 ++--------------- .../integration/codec/StringParseTest.java | 17 ++--------------- .../r2dbc/integration/codec/TimeParseTest.java | 17 ++--------------- .../integration/codec/TimestampParseTest.java | 17 ++--------------- .../integration/codec/TinyIntParseTest.java | 17 ++--------------- .../r2dbc/integration/codec/YearParseTest.java | 17 ++--------------- .../parameter/BigIntegerParameterTest.java | 17 ++--------------- .../parameter/BitParameterTest.java | 17 ++--------------- .../parameter/BlobParameterTest.java | 17 ++--------------- .../parameter/DateParameterTest.java | 17 ++--------------- .../parameter/DateTimeParameterTest.java | 17 ++--------------- .../parameter/DecimalParameterTest.java | 17 ++--------------- .../parameter/FloatParameterTest.java | 17 ++--------------- .../parameter/IntParameterTest.java | 17 ++--------------- .../parameter/MediumIntParameterTest.java | 17 ++--------------- .../parameter/ShortParameterTest.java | 17 ++--------------- .../parameter/StringParameterTest.java | 17 ++--------------- .../parameter/TimeParameterTest.java | 17 ++--------------- .../parameter/TimeStampParameterTest.java | 17 ++--------------- .../parameter/TinyIntParameterTest.java | 17 ++--------------- .../java/org/mariadb/r2dbc/tools/TcpProxy.java | 3 +++ .../mariadb/r2dbc/tools/TcpProxySocket.java | 3 +++ .../org/mariadb/r2dbc/unit/InitFinalClass.java | 3 +++ .../org/mariadb/r2dbc/unit/SslModeTest.java | 17 ++--------------- .../unit/client/HostnameVerifierTest.java | 4 ++-- .../r2dbc/unit/client/ServerVersionTest.java | 17 ++--------------- .../r2dbc/unit/util/BufferUtilsTest.java | 3 +++ .../unit/util/ClientPrepareResultTest.java | 17 ++--------------- .../unit/util/DefaultHostnameVerifierTest.java | 17 ++--------------- .../unit/util/ServerPrepareResultTest.java | 3 +++ src/test/resources/logback-test.xml | 16 ++-------------- 200 files changed, 416 insertions(+), 2877 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 084a6e85..2920f76e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,16 @@ # Change Log +## [1.0.2](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/tree/1.0.2) (02 Jul 2021) +[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/compare/1.0.1...1.0.2) + +Corrections: +* [R2DBC-24] columns of type Bit(1)/TINYINT(1) now convert as Boolean (new option `tinyInt1isBit`) +* [R2DBC-25] Statement::add correction after specification precision +* [R2DBC-26] handle error like 'too many connection" on socket creation +* [R2DBC-27] Options not parsed from connection string +* [R2DBC-28] mutual authentication not done when using ssl TRUST option +* [R2DBC-29] improve coverage to reaching 90% +* [R2DBC-30] Native Password plugin error + ## [1.0.1](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/tree/1.0.1) (09 Mar 2021) [Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/compare/1.0.0...1.0.1) diff --git a/README.md b/README.md index 2745b944..6a3bb91f 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ The MariaDB Connector is available through maven using : org.mariadb r2dbc-mariadb - 1.0.0 + 1.0.2 ``` diff --git a/intellij-style.xml b/intellij-style.xml index b78928d8..cff4d36b 100644 --- a/intellij-style.xml +++ b/intellij-style.xml @@ -1,17 +1,6 @@ diff --git a/pom.xml b/pom.xml index e748b6af..916a3421 100644 --- a/pom.xml +++ b/pom.xml @@ -1,17 +1,6 @@ 4.0.0 org.mariadb r2dbc-mariadb - 1.0.2-SNAPSHOT + 1.0.2 jar https://github.com/mariadb-corporation/mariadb-connector-r2dbc diff --git a/src/benchmark/java/org/mariadb/r2dbc/Common.java b/src/benchmark/java/org/mariadb/r2dbc/Common.java index eb62d78a..b179f50e 100644 --- a/src/benchmark/java/org/mariadb/r2dbc/Common.java +++ b/src/benchmark/java/org/mariadb/r2dbc/Common.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/benchmark/java/org/mariadb/r2dbc/Select_1.java b/src/benchmark/java/org/mariadb/r2dbc/Select_1.java index f4df013c..323c1474 100644 --- a/src/benchmark/java/org/mariadb/r2dbc/Select_1.java +++ b/src/benchmark/java/org/mariadb/r2dbc/Select_1.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/benchmark/java/org/mariadb/r2dbc/Select_10000_Rows.java b/src/benchmark/java/org/mariadb/r2dbc/Select_10000_Rows.java index a7d3c759..18816429 100644 --- a/src/benchmark/java/org/mariadb/r2dbc/Select_10000_Rows.java +++ b/src/benchmark/java/org/mariadb/r2dbc/Select_10000_Rows.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/benchmark/java/org/mariadb/r2dbc/Select_1000_params.java b/src/benchmark/java/org/mariadb/r2dbc/Select_1000_params.java index 63e69ac0..41e71bd8 100644 --- a/src/benchmark/java/org/mariadb/r2dbc/Select_1000_params.java +++ b/src/benchmark/java/org/mariadb/r2dbc/Select_1000_params.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/benchmark/java/org/mariadb/r2dbc/Select_1_user.java b/src/benchmark/java/org/mariadb/r2dbc/Select_1_user.java index d7a73120..a1a89fda 100644 --- a/src/benchmark/java/org/mariadb/r2dbc/Select_1_user.java +++ b/src/benchmark/java/org/mariadb/r2dbc/Select_1_user.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/benchmark/resources/logback-test.xml b/src/benchmark/resources/logback-test.xml index 4b5b5c55..d86430e7 100644 --- a/src/benchmark/resources/logback-test.xml +++ b/src/benchmark/resources/logback-test.xml @@ -1,18 +1,7 @@ diff --git a/src/main/java/org/mariadb/r2dbc/ExceptionFactory.java b/src/main/java/org/mariadb/r2dbc/ExceptionFactory.java index dac49c9e..6ce8f75b 100644 --- a/src/main/java/org/mariadb/r2dbc/ExceptionFactory.java +++ b/src/main/java/org/mariadb/r2dbc/ExceptionFactory.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbBatch.java b/src/main/java/org/mariadb/r2dbc/MariadbBatch.java index 4cd168ac..8c3a119d 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbBatch.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbBatch.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java index ea119d76..fd305df0 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbClientParameterizedQueryStatement.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbColumnMetadata.java b/src/main/java/org/mariadb/r2dbc/MariadbColumnMetadata.java index d7f2a47c..d946364f 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbColumnMetadata.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbColumnMetadata.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnection.java b/src/main/java/org/mariadb/r2dbc/MariadbConnection.java index 3128f8b9..d94cb001 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnection.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnection.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java index f580f621..bd06b9bd 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionConfiguration.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactory.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactory.java index 722fb03b..a2c02f31 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactory.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactory.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryMetadata.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryMetadata.java index 3fb1a86f..9793bcb0 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryMetadata.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryMetadata.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java index c3a908da..57c66514 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionFactoryProvider.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbConnectionMetadata.java b/src/main/java/org/mariadb/r2dbc/MariadbConnectionMetadata.java index a6213062..13c34216 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbConnectionMetadata.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbConnectionMetadata.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbResult.java b/src/main/java/org/mariadb/r2dbc/MariadbResult.java index 77a201d9..4a2721c6 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbResult.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbResult.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbRow.java b/src/main/java/org/mariadb/r2dbc/MariadbRow.java index d581eff7..57641ab5 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbRow.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbRow.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbRowMetadata.java b/src/main/java/org/mariadb/r2dbc/MariadbRowMetadata.java index 06e5e4d8..676653a9 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbRowMetadata.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbRowMetadata.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java index 950e5e16..09c9b739 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbServerParameterizedQueryStatement.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/MariadbSimpleQueryStatement.java b/src/main/java/org/mariadb/r2dbc/MariadbSimpleQueryStatement.java index 2277bd2a..1a4c652a 100644 --- a/src/main/java/org/mariadb/r2dbc/MariadbSimpleQueryStatement.java +++ b/src/main/java/org/mariadb/r2dbc/MariadbSimpleQueryStatement.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/SslMode.java b/src/main/java/org/mariadb/r2dbc/SslMode.java index 8bf444ee..9aba3c2e 100644 --- a/src/main/java/org/mariadb/r2dbc/SslMode.java +++ b/src/main/java/org/mariadb/r2dbc/SslMode.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/main/java/org/mariadb/r2dbc/api/MariadbBatch.java b/src/main/java/org/mariadb/r2dbc/api/MariadbBatch.java index 71f9ba90..d92a28a5 100644 --- a/src/main/java/org/mariadb/r2dbc/api/MariadbBatch.java +++ b/src/main/java/org/mariadb/r2dbc/api/MariadbBatch.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.api; diff --git a/src/main/java/org/mariadb/r2dbc/api/MariadbConnection.java b/src/main/java/org/mariadb/r2dbc/api/MariadbConnection.java index 7b522934..86a3f305 100644 --- a/src/main/java/org/mariadb/r2dbc/api/MariadbConnection.java +++ b/src/main/java/org/mariadb/r2dbc/api/MariadbConnection.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.api; diff --git a/src/main/java/org/mariadb/r2dbc/api/MariadbConnectionMetadata.java b/src/main/java/org/mariadb/r2dbc/api/MariadbConnectionMetadata.java index 46fea9d2..672c5815 100644 --- a/src/main/java/org/mariadb/r2dbc/api/MariadbConnectionMetadata.java +++ b/src/main/java/org/mariadb/r2dbc/api/MariadbConnectionMetadata.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.api; diff --git a/src/main/java/org/mariadb/r2dbc/api/MariadbResult.java b/src/main/java/org/mariadb/r2dbc/api/MariadbResult.java index 07a90a18..4328c1d1 100644 --- a/src/main/java/org/mariadb/r2dbc/api/MariadbResult.java +++ b/src/main/java/org/mariadb/r2dbc/api/MariadbResult.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.api; diff --git a/src/main/java/org/mariadb/r2dbc/api/MariadbStatement.java b/src/main/java/org/mariadb/r2dbc/api/MariadbStatement.java index 9b69285a..598540b1 100644 --- a/src/main/java/org/mariadb/r2dbc/api/MariadbStatement.java +++ b/src/main/java/org/mariadb/r2dbc/api/MariadbStatement.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.api; diff --git a/src/main/java/org/mariadb/r2dbc/authentication/AuthenticationPlugin.java b/src/main/java/org/mariadb/r2dbc/authentication/AuthenticationPlugin.java index e4699c5d..4f34c326 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/AuthenticationPlugin.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/AuthenticationPlugin.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication; diff --git a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/Utils.java b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/Utils.java index 0f72ae8b..ecd52ef5 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/Utils.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/Utils.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication.ed25519; /** diff --git a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Constants.java b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Constants.java index 0cb84438..8821d0ae 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Constants.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Constants.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication.ed25519.math; import org.mariadb.r2dbc.authentication.ed25519.Utils; diff --git a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Curve.java b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Curve.java index ee38439b..4087535a 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Curve.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Curve.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication.ed25519.math; import java.io.Serializable; diff --git a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Encoding.java b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Encoding.java index 1ecced71..3e41b883 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Encoding.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Encoding.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication.ed25519.math; /** diff --git a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Field.java b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Field.java index 23058568..4795b11e 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Field.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/Field.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication.ed25519.math; import java.io.Serializable; diff --git a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/FieldElement.java b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/FieldElement.java index f5768586..70a66675 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/FieldElement.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/FieldElement.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication.ed25519.math; import java.io.Serializable; diff --git a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/GroupElement.java b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/GroupElement.java index 9894fedf..9310c95f 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/GroupElement.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/GroupElement.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication.ed25519.math; import java.io.Serializable; diff --git a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/ed25519/Ed25519FieldElement.java b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/ed25519/Ed25519FieldElement.java index 541c9eb9..278c50a3 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/ed25519/Ed25519FieldElement.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/ed25519/Ed25519FieldElement.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication.ed25519.math.ed25519; import java.util.Arrays; diff --git a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/ed25519/Ed25519LittleEndianEncoding.java b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/ed25519/Ed25519LittleEndianEncoding.java index 0e7e0fb7..c2dec2de 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/ed25519/Ed25519LittleEndianEncoding.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/ed25519/Ed25519LittleEndianEncoding.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication.ed25519.math.ed25519; import org.mariadb.r2dbc.authentication.ed25519.math.Encoding; diff --git a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/ed25519/ScalarOps.java b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/ed25519/ScalarOps.java index ff5e9a14..9fc48722 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/ed25519/ScalarOps.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/math/ed25519/ScalarOps.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication.ed25519.math.ed25519; import static org.mariadb.r2dbc.authentication.ed25519.math.ed25519.Ed25519LittleEndianEncoding.load_3; diff --git a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/spec/EdDSANamedCurveSpec.java b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/spec/EdDSANamedCurveSpec.java index fc409a70..cda76c5c 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/spec/EdDSANamedCurveSpec.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/spec/EdDSANamedCurveSpec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication.ed25519.spec; import org.mariadb.r2dbc.authentication.ed25519.math.Curve; diff --git a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/spec/EdDSANamedCurveTable.java b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/spec/EdDSANamedCurveTable.java index 7ef6dff6..e5df7fe6 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/spec/EdDSANamedCurveTable.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/spec/EdDSANamedCurveTable.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication.ed25519.spec; import java.util.Hashtable; diff --git a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/spec/EdDSAParameterSpec.java b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/spec/EdDSAParameterSpec.java index bf0428ae..2659f27f 100644 --- a/src/main/java/org/mariadb/r2dbc/authentication/ed25519/spec/EdDSAParameterSpec.java +++ b/src/main/java/org/mariadb/r2dbc/authentication/ed25519/spec/EdDSAParameterSpec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.authentication.ed25519.spec; import java.io.Serializable; diff --git a/src/main/java/org/mariadb/r2dbc/client/Client.java b/src/main/java/org/mariadb/r2dbc/client/Client.java index 18b93239..26681dff 100644 --- a/src/main/java/org/mariadb/r2dbc/client/Client.java +++ b/src/main/java/org/mariadb/r2dbc/client/Client.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.client; diff --git a/src/main/java/org/mariadb/r2dbc/client/ClientBase.java b/src/main/java/org/mariadb/r2dbc/client/ClientBase.java index b17da7e9..ee335aaa 100644 --- a/src/main/java/org/mariadb/r2dbc/client/ClientBase.java +++ b/src/main/java/org/mariadb/r2dbc/client/ClientBase.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.client; diff --git a/src/main/java/org/mariadb/r2dbc/client/ClientImpl.java b/src/main/java/org/mariadb/r2dbc/client/ClientImpl.java index 9464644b..e8898a92 100644 --- a/src/main/java/org/mariadb/r2dbc/client/ClientImpl.java +++ b/src/main/java/org/mariadb/r2dbc/client/ClientImpl.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.client; diff --git a/src/main/java/org/mariadb/r2dbc/client/ClientPipelineImpl.java b/src/main/java/org/mariadb/r2dbc/client/ClientPipelineImpl.java index 27f57066..46713d0f 100644 --- a/src/main/java/org/mariadb/r2dbc/client/ClientPipelineImpl.java +++ b/src/main/java/org/mariadb/r2dbc/client/ClientPipelineImpl.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.client; diff --git a/src/main/java/org/mariadb/r2dbc/client/CmdElement.java b/src/main/java/org/mariadb/r2dbc/client/CmdElement.java index 579a76e6..75d3fd9b 100644 --- a/src/main/java/org/mariadb/r2dbc/client/CmdElement.java +++ b/src/main/java/org/mariadb/r2dbc/client/CmdElement.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.client; diff --git a/src/main/java/org/mariadb/r2dbc/client/Context.java b/src/main/java/org/mariadb/r2dbc/client/Context.java index cfc27a9f..420fd6aa 100644 --- a/src/main/java/org/mariadb/r2dbc/client/Context.java +++ b/src/main/java/org/mariadb/r2dbc/client/Context.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.client; diff --git a/src/main/java/org/mariadb/r2dbc/client/DecoderState.java b/src/main/java/org/mariadb/r2dbc/client/DecoderState.java index b96f28f4..05ae26d8 100644 --- a/src/main/java/org/mariadb/r2dbc/client/DecoderState.java +++ b/src/main/java/org/mariadb/r2dbc/client/DecoderState.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.client; diff --git a/src/main/java/org/mariadb/r2dbc/client/DecoderStateInterface.java b/src/main/java/org/mariadb/r2dbc/client/DecoderStateInterface.java index 0979fd8d..c226e624 100644 --- a/src/main/java/org/mariadb/r2dbc/client/DecoderStateInterface.java +++ b/src/main/java/org/mariadb/r2dbc/client/DecoderStateInterface.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.client; diff --git a/src/main/java/org/mariadb/r2dbc/client/MariadbPacketDecoder.java b/src/main/java/org/mariadb/r2dbc/client/MariadbPacketDecoder.java index 92c00e6d..4941428f 100644 --- a/src/main/java/org/mariadb/r2dbc/client/MariadbPacketDecoder.java +++ b/src/main/java/org/mariadb/r2dbc/client/MariadbPacketDecoder.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.client; diff --git a/src/main/java/org/mariadb/r2dbc/client/MariadbPacketEncoder.java b/src/main/java/org/mariadb/r2dbc/client/MariadbPacketEncoder.java index 722b8842..c3f9b1f1 100644 --- a/src/main/java/org/mariadb/r2dbc/client/MariadbPacketEncoder.java +++ b/src/main/java/org/mariadb/r2dbc/client/MariadbPacketEncoder.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.client; diff --git a/src/main/java/org/mariadb/r2dbc/client/ServerVersion.java b/src/main/java/org/mariadb/r2dbc/client/ServerVersion.java index 9efdbd77..10372ff6 100644 --- a/src/main/java/org/mariadb/r2dbc/client/ServerVersion.java +++ b/src/main/java/org/mariadb/r2dbc/client/ServerVersion.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.client; diff --git a/src/main/java/org/mariadb/r2dbc/codec/BinaryRowDecoder.java b/src/main/java/org/mariadb/r2dbc/codec/BinaryRowDecoder.java index 195a9a5a..7e8be833 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/BinaryRowDecoder.java +++ b/src/main/java/org/mariadb/r2dbc/codec/BinaryRowDecoder.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec; diff --git a/src/main/java/org/mariadb/r2dbc/codec/Codec.java b/src/main/java/org/mariadb/r2dbc/codec/Codec.java index 9bb3f8b1..5ff3bc4a 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/Codec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/Codec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec; diff --git a/src/main/java/org/mariadb/r2dbc/codec/Codecs.java b/src/main/java/org/mariadb/r2dbc/codec/Codecs.java index 3befb44e..08fa5a2d 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/Codecs.java +++ b/src/main/java/org/mariadb/r2dbc/codec/Codecs.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec; diff --git a/src/main/java/org/mariadb/r2dbc/codec/DataType.java b/src/main/java/org/mariadb/r2dbc/codec/DataType.java index 652f4b5a..f0b2fcae 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/DataType.java +++ b/src/main/java/org/mariadb/r2dbc/codec/DataType.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec; diff --git a/src/main/java/org/mariadb/r2dbc/codec/Parameter.java b/src/main/java/org/mariadb/r2dbc/codec/Parameter.java index fd49385f..3039fc9e 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/Parameter.java +++ b/src/main/java/org/mariadb/r2dbc/codec/Parameter.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec; diff --git a/src/main/java/org/mariadb/r2dbc/codec/RowDecoder.java b/src/main/java/org/mariadb/r2dbc/codec/RowDecoder.java index 3bdf48d3..f040392c 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/RowDecoder.java +++ b/src/main/java/org/mariadb/r2dbc/codec/RowDecoder.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec; diff --git a/src/main/java/org/mariadb/r2dbc/codec/TextRowDecoder.java b/src/main/java/org/mariadb/r2dbc/codec/TextRowDecoder.java index 10c3d417..55239f16 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/TextRowDecoder.java +++ b/src/main/java/org/mariadb/r2dbc/codec/TextRowDecoder.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/BigDecimalCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/BigDecimalCodec.java index e92b0268..0ce27c1d 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/BigDecimalCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/BigDecimalCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/BigIntegerCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/BigIntegerCodec.java index d2680437..dc0a765b 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/BigIntegerCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/BigIntegerCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/BitSetCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/BitSetCodec.java index e2145ca9..9830695f 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/BitSetCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/BitSetCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/BlobCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/BlobCodec.java index a37af3a0..61cd51a9 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/BlobCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/BlobCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/BooleanCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/BooleanCodec.java index 824809a3..0a6b03cd 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/BooleanCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/BooleanCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/ByteArrayCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/ByteArrayCodec.java index b81896fd..43d5f26e 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/ByteArrayCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/ByteArrayCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/ByteCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/ByteCodec.java index 17c07dd2..d57ec54b 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/ByteCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/ByteCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/ClobCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/ClobCodec.java index 89c45ee6..9217cb50 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/ClobCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/ClobCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/DoubleCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/DoubleCodec.java index 99371c93..5533499e 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/DoubleCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/DoubleCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/DurationCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/DurationCodec.java index b6bed688..936c6142 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/DurationCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/DurationCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/FloatCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/FloatCodec.java index c5ab747b..943a4947 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/FloatCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/FloatCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/IntCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/IntCodec.java index 136855ae..b53bb583 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/IntCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/IntCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateCodec.java index 574723ef..f505aa01 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateTimeCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateTimeCodec.java index 3919e3fb..387a403f 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateTimeCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/LocalDateTimeCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/LocalTimeCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/LocalTimeCodec.java index ca288904..42194855 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/LocalTimeCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/LocalTimeCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/LongCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/LongCodec.java index bfc1a7aa..f36597a5 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/LongCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/LongCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/ShortCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/ShortCodec.java index bf1c9065..1de2788e 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/ShortCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/ShortCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/StreamCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/StreamCodec.java index 0555e579..36c66e66 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/StreamCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/StreamCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/codec/list/StringCodec.java b/src/main/java/org/mariadb/r2dbc/codec/list/StringCodec.java index 6d3cead5..be4fbc2b 100644 --- a/src/main/java/org/mariadb/r2dbc/codec/list/StringCodec.java +++ b/src/main/java/org/mariadb/r2dbc/codec/list/StringCodec.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.codec.list; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/AuthMoreRawPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/AuthMoreRawPacket.java index 18d41455..21fbdf80 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/AuthMoreRawPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/AuthMoreRawPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/ClearPasswordPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/ClearPasswordPacket.java index c4696588..f9203d12 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/ClearPasswordPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/ClearPasswordPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/ClientMessage.java b/src/main/java/org/mariadb/r2dbc/message/client/ClientMessage.java index 14acf7b8..e5a3201a 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/ClientMessage.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/ClientMessage.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/ClosePreparePacket.java b/src/main/java/org/mariadb/r2dbc/message/client/ClosePreparePacket.java index 12557517..3fba0344 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/ClosePreparePacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/ClosePreparePacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/Ed25519PasswordPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/Ed25519PasswordPacket.java index 2398307a..0e31b73d 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/Ed25519PasswordPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/Ed25519PasswordPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/ExecutePacket.java b/src/main/java/org/mariadb/r2dbc/message/client/ExecutePacket.java index db0d4872..24f1dece 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/ExecutePacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/ExecutePacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/HandshakeResponse.java b/src/main/java/org/mariadb/r2dbc/message/client/HandshakeResponse.java index 1405dbde..e50fc30d 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/HandshakeResponse.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/HandshakeResponse.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/NativePasswordPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/NativePasswordPacket.java index b2e6643e..89e709e3 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/NativePasswordPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/NativePasswordPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/PingPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/PingPacket.java index 7b3a9361..6f819860 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/PingPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/PingPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/PreparePacket.java b/src/main/java/org/mariadb/r2dbc/message/client/PreparePacket.java index aaf2f5fc..f66336c0 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/PreparePacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/PreparePacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/QueryPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/QueryPacket.java index a7ecdda8..aaebb51c 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/QueryPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/QueryPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/QueryWithParametersPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/QueryWithParametersPacket.java index a7753b9b..33d4090d 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/QueryWithParametersPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/QueryWithParametersPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/QuitPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/QuitPacket.java index 5a2a45f9..a3005ea8 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/QuitPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/QuitPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/RsaPublicKeyRequestPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/RsaPublicKeyRequestPacket.java index bc92d484..59590fb3 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/RsaPublicKeyRequestPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/RsaPublicKeyRequestPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/Sha256PasswordPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/Sha256PasswordPacket.java index f23d60a9..fa1d0952 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/Sha256PasswordPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/Sha256PasswordPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/Sha2PublicKeyRequestPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/Sha2PublicKeyRequestPacket.java index b21bf85d..91590847 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/Sha2PublicKeyRequestPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/Sha2PublicKeyRequestPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/client/SslRequestPacket.java b/src/main/java/org/mariadb/r2dbc/message/client/SslRequestPacket.java index cb585912..e88acc2a 100644 --- a/src/main/java/org/mariadb/r2dbc/message/client/SslRequestPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/client/SslRequestPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.client; diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java index bde87152..2cf2fafd 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlow.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.flow; diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlowPluginLoader.java b/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlowPluginLoader.java index 7c40c4fd..1f79e02f 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlowPluginLoader.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/AuthenticationFlowPluginLoader.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.flow; diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/CachingSha2PasswordFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/CachingSha2PasswordFlow.java index a01dd4f4..ce53f601 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/CachingSha2PasswordFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/CachingSha2PasswordFlow.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.flow; diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/ClearPasswordPluginFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/ClearPasswordPluginFlow.java index b310f966..3a96db8b 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/ClearPasswordPluginFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/ClearPasswordPluginFlow.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.flow; diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/Ed25519PasswordPluginFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/Ed25519PasswordPluginFlow.java index 7d590280..f8503b39 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/Ed25519PasswordPluginFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/Ed25519PasswordPluginFlow.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.flow; diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/NativePasswordPluginFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/NativePasswordPluginFlow.java index 99271bd2..e82c7663 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/NativePasswordPluginFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/NativePasswordPluginFlow.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.flow; diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/PamPluginFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/PamPluginFlow.java index da671861..ca6b05b6 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/PamPluginFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/PamPluginFlow.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.flow; diff --git a/src/main/java/org/mariadb/r2dbc/message/flow/Sha256PasswordPluginFlow.java b/src/main/java/org/mariadb/r2dbc/message/flow/Sha256PasswordPluginFlow.java index edbaceb2..b62157e7 100644 --- a/src/main/java/org/mariadb/r2dbc/message/flow/Sha256PasswordPluginFlow.java +++ b/src/main/java/org/mariadb/r2dbc/message/flow/Sha256PasswordPluginFlow.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.flow; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/AuthMoreDataPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/AuthMoreDataPacket.java index 405e0e6c..b8e96459 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/AuthMoreDataPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/AuthMoreDataPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/AuthSwitchPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/AuthSwitchPacket.java index f475508d..87f87dc7 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/AuthSwitchPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/AuthSwitchPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/ColumnCountPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/ColumnCountPacket.java index 331ffdf2..013292fb 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/ColumnCountPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/ColumnCountPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/ColumnDefinitionPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/ColumnDefinitionPacket.java index 1eb7610c..78dcf0b7 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/ColumnDefinitionPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/ColumnDefinitionPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/CompletePrepareResult.java b/src/main/java/org/mariadb/r2dbc/message/server/CompletePrepareResult.java index 03c8973e..546c08c1 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/CompletePrepareResult.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/CompletePrepareResult.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/EofPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/EofPacket.java index b53e2790..debeac3e 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/EofPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/EofPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/ErrorPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/ErrorPacket.java index 8d516947..b3320de7 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/ErrorPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/ErrorPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/InitialHandshakePacket.java b/src/main/java/org/mariadb/r2dbc/message/server/InitialHandshakePacket.java index 21c021e0..a4056739 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/InitialHandshakePacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/InitialHandshakePacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/OkPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/OkPacket.java index efe81955..e572453f 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/OkPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/OkPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/PrepareResultPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/PrepareResultPacket.java index bd5b7495..041e8ac3 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/PrepareResultPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/PrepareResultPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/RowPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/RowPacket.java index 181d2f2b..b905b555 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/RowPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/RowPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/Sequencer.java b/src/main/java/org/mariadb/r2dbc/message/server/Sequencer.java index 7699b2d0..2f993247 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/Sequencer.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/Sequencer.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/ServerMessage.java b/src/main/java/org/mariadb/r2dbc/message/server/ServerMessage.java index 388b0951..1586a6b6 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/ServerMessage.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/ServerMessage.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/message/server/SkipPacket.java b/src/main/java/org/mariadb/r2dbc/message/server/SkipPacket.java index a91c65cc..69482689 100644 --- a/src/main/java/org/mariadb/r2dbc/message/server/SkipPacket.java +++ b/src/main/java/org/mariadb/r2dbc/message/server/SkipPacket.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.message.server; diff --git a/src/main/java/org/mariadb/r2dbc/util/Assert.java b/src/main/java/org/mariadb/r2dbc/util/Assert.java index 32697c74..cd28fa33 100644 --- a/src/main/java/org/mariadb/r2dbc/util/Assert.java +++ b/src/main/java/org/mariadb/r2dbc/util/Assert.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.util; diff --git a/src/main/java/org/mariadb/r2dbc/util/BufferUtils.java b/src/main/java/org/mariadb/r2dbc/util/BufferUtils.java index 86d9412a..cc5428bd 100644 --- a/src/main/java/org/mariadb/r2dbc/util/BufferUtils.java +++ b/src/main/java/org/mariadb/r2dbc/util/BufferUtils.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.util; diff --git a/src/main/java/org/mariadb/r2dbc/util/ClientPrepareResult.java b/src/main/java/org/mariadb/r2dbc/util/ClientPrepareResult.java index f4ad3dc7..564b2d21 100644 --- a/src/main/java/org/mariadb/r2dbc/util/ClientPrepareResult.java +++ b/src/main/java/org/mariadb/r2dbc/util/ClientPrepareResult.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.util; diff --git a/src/main/java/org/mariadb/r2dbc/util/DefaultHostnameVerifier.java b/src/main/java/org/mariadb/r2dbc/util/DefaultHostnameVerifier.java index 704c25ca..4c07b204 100644 --- a/src/main/java/org/mariadb/r2dbc/util/DefaultHostnameVerifier.java +++ b/src/main/java/org/mariadb/r2dbc/util/DefaultHostnameVerifier.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.util; diff --git a/src/main/java/org/mariadb/r2dbc/util/PidFactory.java b/src/main/java/org/mariadb/r2dbc/util/PidFactory.java index 945c8eb6..597d6d1c 100644 --- a/src/main/java/org/mariadb/r2dbc/util/PidFactory.java +++ b/src/main/java/org/mariadb/r2dbc/util/PidFactory.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.util; diff --git a/src/main/java/org/mariadb/r2dbc/util/PrepareCache.java b/src/main/java/org/mariadb/r2dbc/util/PrepareCache.java index e6a1fb21..a72335a4 100644 --- a/src/main/java/org/mariadb/r2dbc/util/PrepareCache.java +++ b/src/main/java/org/mariadb/r2dbc/util/PrepareCache.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.util; diff --git a/src/main/java/org/mariadb/r2dbc/util/PrepareResult.java b/src/main/java/org/mariadb/r2dbc/util/PrepareResult.java index 4d41ee78..cb608501 100644 --- a/src/main/java/org/mariadb/r2dbc/util/PrepareResult.java +++ b/src/main/java/org/mariadb/r2dbc/util/PrepareResult.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.util; diff --git a/src/main/java/org/mariadb/r2dbc/util/ServerPrepareResult.java b/src/main/java/org/mariadb/r2dbc/util/ServerPrepareResult.java index 7eccc346..6d24dfab 100644 --- a/src/main/java/org/mariadb/r2dbc/util/ServerPrepareResult.java +++ b/src/main/java/org/mariadb/r2dbc/util/ServerPrepareResult.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.util; diff --git a/src/main/java/org/mariadb/r2dbc/util/SslConfig.java b/src/main/java/org/mariadb/r2dbc/util/SslConfig.java index d12dd443..0bc2bd2d 100644 --- a/src/main/java/org/mariadb/r2dbc/util/SslConfig.java +++ b/src/main/java/org/mariadb/r2dbc/util/SslConfig.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.util; diff --git a/src/main/java/org/mariadb/r2dbc/util/constants/Capabilities.java b/src/main/java/org/mariadb/r2dbc/util/constants/Capabilities.java index ba57dd62..7486b48e 100644 --- a/src/main/java/org/mariadb/r2dbc/util/constants/Capabilities.java +++ b/src/main/java/org/mariadb/r2dbc/util/constants/Capabilities.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.util.constants; diff --git a/src/main/java/org/mariadb/r2dbc/util/constants/ColumnFlags.java b/src/main/java/org/mariadb/r2dbc/util/constants/ColumnFlags.java index c2361ac3..6e67476e 100644 --- a/src/main/java/org/mariadb/r2dbc/util/constants/ColumnFlags.java +++ b/src/main/java/org/mariadb/r2dbc/util/constants/ColumnFlags.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.util.constants; diff --git a/src/main/java/org/mariadb/r2dbc/util/constants/ServerStatus.java b/src/main/java/org/mariadb/r2dbc/util/constants/ServerStatus.java index 6ad5f191..33b1b8a5 100644 --- a/src/main/java/org/mariadb/r2dbc/util/constants/ServerStatus.java +++ b/src/main/java/org/mariadb/r2dbc/util/constants/ServerStatus.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.util.constants; diff --git a/src/main/java/org/mariadb/r2dbc/util/constants/StateChange.java b/src/main/java/org/mariadb/r2dbc/util/constants/StateChange.java index 7f69df69..346e0b48 100644 --- a/src/main/java/org/mariadb/r2dbc/util/constants/StateChange.java +++ b/src/main/java/org/mariadb/r2dbc/util/constants/StateChange.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.util.constants; diff --git a/src/main/resources/META-INF/services/io.r2dbc.spi.ConnectionFactoryProvider b/src/main/resources/META-INF/services/io.r2dbc.spi.ConnectionFactoryProvider index c6ed5e7d..380540cc 100644 --- a/src/main/resources/META-INF/services/io.r2dbc.spi.ConnectionFactoryProvider +++ b/src/main/resources/META-INF/services/io.r2dbc.spi.ConnectionFactoryProvider @@ -1,17 +1,4 @@ -# -# Copyright 2020 MariaDB Ab. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2020-2021 MariaDB Corporation Ab org.mariadb.r2dbc.MariadbConnectionFactoryProvider \ No newline at end of file diff --git a/src/main/resources/META-INF/services/org.mariadb.r2dbc.authentication.AuthenticationPlugin b/src/main/resources/META-INF/services/org.mariadb.r2dbc.authentication.AuthenticationPlugin index 0c7c1cad..05df7fb9 100644 --- a/src/main/resources/META-INF/services/org.mariadb.r2dbc.authentication.AuthenticationPlugin +++ b/src/main/resources/META-INF/services/org.mariadb.r2dbc.authentication.AuthenticationPlugin @@ -1,18 +1,5 @@ -# -# Copyright 2020 MariaDB Ab. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2020-2021 MariaDB Corporation Ab org.mariadb.r2dbc.message.flow.NativePasswordPluginFlow org.mariadb.r2dbc.message.flow.ClearPasswordPluginFlow diff --git a/src/main/resources/project.properties b/src/main/resources/project.properties index c598e325..cb8a0178 100644 --- a/src/main/resources/project.properties +++ b/src/main/resources/project.properties @@ -1,16 +1,4 @@ -# -# Copyright 2020 MariaDB Ab. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2020-2021 MariaDB Corporation Ab + version=${project.version} \ No newline at end of file diff --git a/src/test/java/org/mariadb/r2dbc/BaseConnectionTest.java b/src/test/java/org/mariadb/r2dbc/BaseConnectionTest.java index 24ee0abb..3c176062 100644 --- a/src/test/java/org/mariadb/r2dbc/BaseConnectionTest.java +++ b/src/test/java/org/mariadb/r2dbc/BaseConnectionTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/test/java/org/mariadb/r2dbc/BaseTest.java b/src/test/java/org/mariadb/r2dbc/BaseTest.java index d3e9dc06..d29efb80 100644 --- a/src/test/java/org/mariadb/r2dbc/BaseTest.java +++ b/src/test/java/org/mariadb/r2dbc/BaseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/test/java/org/mariadb/r2dbc/TestConfiguration.java b/src/test/java/org/mariadb/r2dbc/TestConfiguration.java index f22d224c..4bb60033 100644 --- a/src/test/java/org/mariadb/r2dbc/TestConfiguration.java +++ b/src/test/java/org/mariadb/r2dbc/TestConfiguration.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc; diff --git a/src/test/java/org/mariadb/r2dbc/integration/BatchTest.java b/src/test/java/org/mariadb/r2dbc/integration/BatchTest.java index 97389b23..096f35d5 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/BatchTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/BatchTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/BigResultSetTest.java b/src/test/java/org/mariadb/r2dbc/integration/BigResultSetTest.java index 35c6e365..5516e54d 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/BigResultSetTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/BigResultSetTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java index fd03b902..24de73d9 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConfigurationTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConnectionMetadataTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConnectionMetadataTest.java index 2e074397..75522cad 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConnectionMetadataTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConnectionMetadataTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java index d20360c2..024c73ab 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ConnectionTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/ErrorTest.java b/src/test/java/org/mariadb/r2dbc/integration/ErrorTest.java index 874af8ef..bdc4cb98 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ErrorTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ErrorTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/LoggingTest.java b/src/test/java/org/mariadb/r2dbc/integration/LoggingTest.java index 38392191..6715c2fa 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/LoggingTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/LoggingTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/MultiQueriesTest.java b/src/test/java/org/mariadb/r2dbc/integration/MultiQueriesTest.java index 474a27a6..8f1f83e1 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/MultiQueriesTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/MultiQueriesTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/NoPipelineTest.java b/src/test/java/org/mariadb/r2dbc/integration/NoPipelineTest.java index bb02617c..503700ee 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/NoPipelineTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/NoPipelineTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java b/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java index 98dda54a..e6c1763f 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/PrepareResultSetTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java b/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java index 8531beca..1e16687e 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/ResultsetTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/RowMetadataTest.java b/src/test/java/org/mariadb/r2dbc/integration/RowMetadataTest.java index 2e48d9d2..09495d9c 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/RowMetadataTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/RowMetadataTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/StatementBatchingTest.java b/src/test/java/org/mariadb/r2dbc/integration/StatementBatchingTest.java index 27ad4c41..1276181d 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/StatementBatchingTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/StatementBatchingTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/StatementTest.java b/src/test/java/org/mariadb/r2dbc/integration/StatementTest.java index 4a4f51f8..698de83d 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/StatementTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/StatementTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java b/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java index 810d5d47..bce6c0cd 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/TlsTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/TransactionTest.java b/src/test/java/org/mariadb/r2dbc/integration/TransactionTest.java index 088bf4bc..9ffbd413 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/TransactionTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/TransactionTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration; diff --git a/src/test/java/org/mariadb/r2dbc/integration/authentication/Ed25519PluginTest.java b/src/test/java/org/mariadb/r2dbc/integration/authentication/Ed25519PluginTest.java index 8da50c91..5dc4a44c 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/authentication/Ed25519PluginTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/authentication/Ed25519PluginTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.authentication; diff --git a/src/test/java/org/mariadb/r2dbc/integration/authentication/PamPluginTest.java b/src/test/java/org/mariadb/r2dbc/integration/authentication/PamPluginTest.java index 3d81f175..2bef5ba5 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/authentication/PamPluginTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/authentication/PamPluginTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.authentication; diff --git a/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java b/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java index 102c291e..0f4de851 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/authentication/Sha256PluginTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.authentication; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/BigIntegerParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/BigIntegerParseTest.java index 5e15ad05..8e7e4ed9 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/BigIntegerParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/BigIntegerParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/BitParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/BitParseTest.java index e349a526..7a93d8a9 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/BitParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/BitParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/BlobParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/BlobParseTest.java index 7e6cd99e..9d1d63a1 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/BlobParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/BlobParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java index 454687e3..6f8f6724 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/DateParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/DateTimeParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/DateTimeParseTest.java index a217cae2..877b8825 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/DateTimeParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/DateTimeParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/DecimalParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/DecimalParseTest.java index 6d70f452..9fd71923 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/DecimalParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/DecimalParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/DoubleParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/DoubleParseTest.java index d824861d..4ae9e1e4 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/DoubleParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/DoubleParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/FloatParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/FloatParseTest.java index 9eca924b..d14f4252 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/FloatParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/FloatParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/IntParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/IntParseTest.java index 9e4070fe..601a71ea 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/IntParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/IntParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/MediumIntParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/MediumIntParseTest.java index 3adee4e1..2d84a548 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/MediumIntParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/MediumIntParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/ShortParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/ShortParseTest.java index c3788869..42b6b033 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/ShortParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/ShortParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/StringParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/StringParseTest.java index 6b626d40..20cb7f37 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/StringParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/StringParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java index 8ec47764..ad85eb07 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/TimeParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/TimestampParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/TimestampParseTest.java index 82fccc6e..3467393b 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/TimestampParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/TimestampParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/TinyIntParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/TinyIntParseTest.java index 67b6e2d9..736763ee 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/TinyIntParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/TinyIntParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/codec/YearParseTest.java b/src/test/java/org/mariadb/r2dbc/integration/codec/YearParseTest.java index 7b9d9b2b..a174f10d 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/codec/YearParseTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/codec/YearParseTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.codec; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/BigIntegerParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/BigIntegerParameterTest.java index b13fd957..13d156bc 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/BigIntegerParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/BigIntegerParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/BitParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/BitParameterTest.java index b29d25b4..f3377a63 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/BitParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/BitParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/BlobParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/BlobParameterTest.java index 1f916123..8488bbef 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/BlobParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/BlobParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/DateParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/DateParameterTest.java index ac7034bc..534d10cf 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/DateParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/DateParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/DateTimeParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/DateTimeParameterTest.java index d015ec07..7ec2aed7 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/DateTimeParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/DateTimeParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/DecimalParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/DecimalParameterTest.java index 979afb42..14730359 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/DecimalParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/DecimalParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/FloatParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/FloatParameterTest.java index 679506bd..186d7482 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/FloatParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/FloatParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/IntParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/IntParameterTest.java index e013a054..8c1ec477 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/IntParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/IntParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/MediumIntParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/MediumIntParameterTest.java index d4039361..2205e1be 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/MediumIntParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/MediumIntParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/ShortParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/ShortParameterTest.java index afb6c5c6..900ec483 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/ShortParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/ShortParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/StringParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/StringParameterTest.java index 99e9b613..b62fd884 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/StringParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/StringParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeParameterTest.java index 4d9a2979..b0b36513 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeStampParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeStampParameterTest.java index e863c339..f8526e8d 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeStampParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/TimeStampParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/integration/parameter/TinyIntParameterTest.java b/src/test/java/org/mariadb/r2dbc/integration/parameter/TinyIntParameterTest.java index 116c57e9..e0605609 100644 --- a/src/test/java/org/mariadb/r2dbc/integration/parameter/TinyIntParameterTest.java +++ b/src/test/java/org/mariadb/r2dbc/integration/parameter/TinyIntParameterTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.integration.parameter; diff --git a/src/test/java/org/mariadb/r2dbc/tools/TcpProxy.java b/src/test/java/org/mariadb/r2dbc/tools/TcpProxy.java index 2ffd7c75..14132818 100644 --- a/src/test/java/org/mariadb/r2dbc/tools/TcpProxy.java +++ b/src/test/java/org/mariadb/r2dbc/tools/TcpProxy.java @@ -1,3 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab + package org.mariadb.r2dbc.tools; import java.io.IOException; diff --git a/src/test/java/org/mariadb/r2dbc/tools/TcpProxySocket.java b/src/test/java/org/mariadb/r2dbc/tools/TcpProxySocket.java index f4656346..6f35ac3d 100644 --- a/src/test/java/org/mariadb/r2dbc/tools/TcpProxySocket.java +++ b/src/test/java/org/mariadb/r2dbc/tools/TcpProxySocket.java @@ -1,3 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab + package org.mariadb.r2dbc.tools; import java.io.*; diff --git a/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java b/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java index c1064a71..3f9654b9 100644 --- a/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java +++ b/src/test/java/org/mariadb/r2dbc/unit/InitFinalClass.java @@ -1,3 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab + package org.mariadb.r2dbc.unit; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/mariadb/r2dbc/unit/SslModeTest.java b/src/test/java/org/mariadb/r2dbc/unit/SslModeTest.java index c3c1482f..d9e9a173 100644 --- a/src/test/java/org/mariadb/r2dbc/unit/SslModeTest.java +++ b/src/test/java/org/mariadb/r2dbc/unit/SslModeTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.unit; diff --git a/src/test/java/org/mariadb/r2dbc/unit/client/HostnameVerifierTest.java b/src/test/java/org/mariadb/r2dbc/unit/client/HostnameVerifierTest.java index 67d5b799..bbfdf7b3 100644 --- a/src/test/java/org/mariadb/r2dbc/unit/client/HostnameVerifierTest.java +++ b/src/test/java/org/mariadb/r2dbc/unit/client/HostnameVerifierTest.java @@ -1,6 +1,6 @@ -// SPDX-License-Identifier: LGPL-2.1-or-later +// SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2012-2014 Monty Program Ab -// Copyright (c) 2015-2021 MariaDB Corporation Ab +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.unit.client; diff --git a/src/test/java/org/mariadb/r2dbc/unit/client/ServerVersionTest.java b/src/test/java/org/mariadb/r2dbc/unit/client/ServerVersionTest.java index 28c0f324..09a85b9f 100644 --- a/src/test/java/org/mariadb/r2dbc/unit/client/ServerVersionTest.java +++ b/src/test/java/org/mariadb/r2dbc/unit/client/ServerVersionTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.unit.client; diff --git a/src/test/java/org/mariadb/r2dbc/unit/util/BufferUtilsTest.java b/src/test/java/org/mariadb/r2dbc/unit/util/BufferUtilsTest.java index 5805e7fa..81b6e4d0 100644 --- a/src/test/java/org/mariadb/r2dbc/unit/util/BufferUtilsTest.java +++ b/src/test/java/org/mariadb/r2dbc/unit/util/BufferUtilsTest.java @@ -1,3 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab + package org.mariadb.r2dbc.unit.util; import static org.junit.jupiter.api.Assertions.*; diff --git a/src/test/java/org/mariadb/r2dbc/unit/util/ClientPrepareResultTest.java b/src/test/java/org/mariadb/r2dbc/unit/util/ClientPrepareResultTest.java index 2e45a5e8..9681da80 100644 --- a/src/test/java/org/mariadb/r2dbc/unit/util/ClientPrepareResultTest.java +++ b/src/test/java/org/mariadb/r2dbc/unit/util/ClientPrepareResultTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.unit.util; diff --git a/src/test/java/org/mariadb/r2dbc/unit/util/DefaultHostnameVerifierTest.java b/src/test/java/org/mariadb/r2dbc/unit/util/DefaultHostnameVerifierTest.java index 6f45dab3..ea09c589 100644 --- a/src/test/java/org/mariadb/r2dbc/unit/util/DefaultHostnameVerifierTest.java +++ b/src/test/java/org/mariadb/r2dbc/unit/util/DefaultHostnameVerifierTest.java @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MariaDB Ab. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab package org.mariadb.r2dbc.unit.util; diff --git a/src/test/java/org/mariadb/r2dbc/unit/util/ServerPrepareResultTest.java b/src/test/java/org/mariadb/r2dbc/unit/util/ServerPrepareResultTest.java index cb24a609..b8c01201 100644 --- a/src/test/java/org/mariadb/r2dbc/unit/util/ServerPrepareResultTest.java +++ b/src/test/java/org/mariadb/r2dbc/unit/util/ServerPrepareResultTest.java @@ -1,3 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2020-2021 MariaDB Corporation Ab + package org.mariadb.r2dbc.unit.util; import org.junit.jupiter.api.Assertions; diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml index eb8589e7..1e2ab522 100644 --- a/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -1,20 +1,8 @@ -