From 44b2fe714455c690d064a52631486007001ca8ef Mon Sep 17 00:00:00 2001
From: Michael McMahon
Date: Tue, 12 Nov 2024 12:25:49 -0800
Subject: [PATCH] JavaDoc and code clean up
---
.../java/oracle/r2dbc/impl/AsyncLock.java | 14 +------
.../oracle/r2dbc/impl/OracleBatchImpl.java | 20 +++------
.../r2dbc/impl/OracleConnectionImpl.java | 2 +
.../oracle/r2dbc/impl/OracleReadableImpl.java | 42 ++-----------------
.../oracle/r2dbc/impl/OracleResultImpl.java | 2 -
5 files changed, 13 insertions(+), 67 deletions(-)
diff --git a/src/main/java/oracle/r2dbc/impl/AsyncLock.java b/src/main/java/oracle/r2dbc/impl/AsyncLock.java
index 9a10c66..c77f948 100644
--- a/src/main/java/oracle/r2dbc/impl/AsyncLock.java
+++ b/src/main/java/oracle/r2dbc/impl/AsyncLock.java
@@ -25,12 +25,6 @@
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
-import reactor.core.publisher.Mono;
-
-import java.util.concurrent.ConcurrentLinkedDeque;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.function.Function;
/**
*
@@ -70,12 +64,6 @@
* immediately, before {@code lock(Runnable)} returns if the lock is
* available. Otherwise, the {@code Runnable} is executed asynchronously
* after the lock becomes available.
- *
- * The {@code Runnable} provided to {@link #lock(Runnable)} MUST ensure
- * that a single invocation of {@link #unlock()} will occur after its
- * {@code run()} method is invoked. The call to {@code unlock} may occur
- * within the scope of the {@code Runnable.run()} method. It may also occur
- * asynchronously, after the {@code run()} method has returned.
*
* Locking for Synchronous JDBC Calls
*
@@ -96,7 +84,7 @@
* methods.
*
*/
-public interface AsyncLock {
+interface AsyncLock {
/**
* Acquires this lock, executes a {@code callback}, and then releases this
diff --git a/src/main/java/oracle/r2dbc/impl/OracleBatchImpl.java b/src/main/java/oracle/r2dbc/impl/OracleBatchImpl.java
index e45cb56..cabc457 100755
--- a/src/main/java/oracle/r2dbc/impl/OracleBatchImpl.java
+++ b/src/main/java/oracle/r2dbc/impl/OracleBatchImpl.java
@@ -21,18 +21,15 @@
package oracle.r2dbc.impl;
-import java.sql.Connection;
-import java.sql.Statement;
-import java.time.Duration;
-import java.util.LinkedList;
-import java.util.Queue;
-import java.util.concurrent.atomic.AtomicReference;
-
import io.r2dbc.spi.Batch;
import io.r2dbc.spi.R2dbcException;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
+
+import java.sql.Connection;
+import java.time.Duration;
+import java.util.LinkedList;
+import java.util.Queue;
import static oracle.r2dbc.impl.OracleR2dbcExceptions.requireNonNull;
import static oracle.r2dbc.impl.OracleR2dbcExceptions.requireOpenConnection;
@@ -59,9 +56,6 @@ final class OracleBatchImpl implements Batch {
/** The OracleConnectionImpl that created this Batch */
private final OracleConnectionImpl r2dbcConnection;
- /** Adapts Oracle JDBC Driver APIs into Reactive Streams APIs */
- private final ReactiveJdbcAdapter adapter;
-
/**
* JDBC connection to an Oracle Database which executes this batch.
*/
@@ -83,14 +77,12 @@ final class OracleBatchImpl implements Batch {
* SQL statements with a {@code jdbcConnection}.
* @param timeout Timeout applied to each statement this batch executes.
* Not null. Not negative.
- * @param jdbcConnection JDBC connection to an Oracle Database. Not null.
- * @param adapter Adapts JDBC calls into reactive streams. Not null.
+ * @param r2dbcConnection R2DBC connection that created this batch. Not null.
*/
OracleBatchImpl(Duration timeout, OracleConnectionImpl r2dbcConnection) {
this.timeout = timeout;
this.r2dbcConnection = r2dbcConnection;
this.jdbcConnection = r2dbcConnection.jdbcConnection();
- this.adapter = r2dbcConnection.adapter();
}
/**
diff --git a/src/main/java/oracle/r2dbc/impl/OracleConnectionImpl.java b/src/main/java/oracle/r2dbc/impl/OracleConnectionImpl.java
index 11b8bec..f61c83e 100755
--- a/src/main/java/oracle/r2dbc/impl/OracleConnectionImpl.java
+++ b/src/main/java/oracle/r2dbc/impl/OracleConnectionImpl.java
@@ -411,6 +411,8 @@ public Publisher close() {
* publisher when there is no obligation to do so.
*
*
+ * @param the type of element signaled by the publisher.
+ *
* @param publisher Publisher that must be subscribed to before closing the
* JDBC connection. Not null.
*
diff --git a/src/main/java/oracle/r2dbc/impl/OracleReadableImpl.java b/src/main/java/oracle/r2dbc/impl/OracleReadableImpl.java
index 850f886..fddad53 100755
--- a/src/main/java/oracle/r2dbc/impl/OracleReadableImpl.java
+++ b/src/main/java/oracle/r2dbc/impl/OracleReadableImpl.java
@@ -63,14 +63,10 @@
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.Period;
-import java.time.temporal.ChronoUnit;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
-import java.util.Objects;
import java.util.TreeMap;
-import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.function.IntFunction;
@@ -125,7 +121,6 @@ class OracleReadableImpl implements io.r2dbc.spi.Readable {
* {@code jdbcReadable}. Not null.
* @param jdbcReadable Readable values from a JDBC Driver. Not null.
* @param readablesMetadata Metadata of each value. Not null.
- * @param adapter Adapts JDBC calls into reactive streams. Not null.
*/
private OracleReadableImpl(
OracleConnectionImpl r2dbcConnection, DependentCounter dependentCounter,
@@ -144,13 +139,12 @@ private OracleReadableImpl(
* provided {@code jdbcReadable} and {@code metadata}. The metadata
* object is used to determine the default type mapping of column values.
*
- * @param jdbcConnection JDBC connection that created the
+ * @param r2dbcConnection R2DBC connection that created the
* {@code jdbcReadable}. Not null.
* @param dependentCounter Counter that is increased for each dependent
* {@code Result} created by the returned {@code Row}
* @param jdbcReadable Row data from the Oracle JDBC Driver. Not null.
* @param metadata Meta-data for the specified row. Not null.
- * @param adapter Adapts JDBC calls into reactive streams. Not null.
* @return A {@code Row} backed by the {@code jdbcReadable} and
* {@code metadata}. Not null.
*/
@@ -173,7 +167,6 @@ static Row createRow(
* {@code Result} created by the returned {@code OutParameters}
* @param jdbcReadable Row data from the Oracle JDBC Driver. Not null.
* @param metadata Meta-data for the specified row. Not null.
- * @param adapter Adapts JDBC calls into reactive streams. Not null.
* @return An {@code OutParameters} backed by the {@code jdbcReadable} and
* {@code metadata}. Not null.
*/
@@ -406,17 +399,6 @@ private Clob getClob(int index) {
*/
private LocalDateTime getLocalDateTime(int index) {
return jdbcReadable.getObject(index, LocalDateTime.class);
- /*
- if (OracleR2dbcTypes.TIMESTAMP_WITH_LOCAL_TIME_ZONE
- .equals(readablesMetadata.get(index).getType())) {
- // TODO: Remove this when Oracle JDBC implements a correct conversion
- Timestamp timestamp = jdbcReadable.getObject(index, Timestamp.class);
- return timestamp == null ? null : timestamp.toLocalDateTime();
- }
- else {
- return jdbcReadable.getObject(index, LocalDateTime.class);
- }
- */
}
/**
@@ -741,7 +723,7 @@ private static Map toMap(OracleReadableImpl readable) {
private Function getMappingFunction(
Class fromType, Class toType) {
- Function extends Object, Object> mappingFunction = null;
+ Function, Object> mappingFunction = null;
if (toType.isAssignableFrom(fromType)) {
return toType::cast;
@@ -857,20 +839,7 @@ else if (INTERVALYM.class.isAssignableFrom(fromType)
}
else if (INTERVALDS.class.isAssignableFrom(fromType)
&& toType.isAssignableFrom(Duration.class)) {
- mappingFunction = (INTERVALDS intervalds) -> {
- // The binary representation is specified in the JavaDoc of
- // oracle.sql.INTERVALDS. In 21.x, the JavaDoc has bug: It neglects
- // to mention that the day and fractional second values are offset by
- // 0x80000000
- ByteBuffer byteBuffer = ByteBuffer.wrap(intervalds.shareBytes());
- return Duration.of(
- TimeUnit.DAYS.toNanos(byteBuffer.getInt() - 0x80000000)// 4 byte day
- + TimeUnit.HOURS.toNanos(byteBuffer.get() - 60) // 1 byte hour
- + TimeUnit.MINUTES.toNanos(byteBuffer.get() - 60) // 1 byte minute
- + TimeUnit.SECONDS.toNanos(byteBuffer.get() - 60) // 1 byte second
- + byteBuffer.getInt() - 0x80000000, // 4 byte fractional second
- ChronoUnit.NANOS);
- };
+ mappingFunction = (INTERVALDS intervalds) -> intervalds.getDuration();
}
else if (java.sql.Blob.class.isAssignableFrom(fromType)
&& byte[].class.equals(toType)) {
@@ -1008,7 +977,6 @@ private static final class RowImpl
* {@code jdbcReadable}. Not null.
* @param jdbcReadable Row data from the Oracle JDBC Driver. Not null.
* @param metadata Meta-data for the specified row. Not null.
- * @param adapter Adapts JDBC calls into reactive streams. Not null.
*/
private RowImpl(
OracleConnectionImpl r2dbcConnection, DependentCounter dependentCounter,
@@ -1046,11 +1014,10 @@ private static final class OutParametersImpl
* {@code jdbcReadable} and obtains metadata of the values from
* {@code outParametersMetaData}.
*
- * @param jdbcConnection JDBC connection that created the
+ * @param r2dbcConnection R2DBC connection that created the
* {@code jdbcReadable}. Not null.
* @param jdbcReadable Readable values from a JDBC Driver. Not null.
* @param metadata Metadata of each value. Not null.
- * @param adapter Adapts JDBC calls into reactive streams. Not null.
*/
private OutParametersImpl(
OracleConnectionImpl r2dbcConnection, DependentCounter dependentCounter,
@@ -1080,7 +1047,6 @@ private final class OracleR2dbcObjectImpl
* {@code jdbcReadable}. Not null.
* @param structJdbcReadable Readable values from a JDBC Driver. Not null.
* @param metadata Metadata of each value. Not null.
- * @param adapter Adapts JDBC calls into reactive streams. Not null.
*/
private OracleR2dbcObjectImpl(
OracleConnectionImpl r2dbcConnection,
diff --git a/src/main/java/oracle/r2dbc/impl/OracleResultImpl.java b/src/main/java/oracle/r2dbc/impl/OracleResultImpl.java
index 6cd7327..d2ea6cb 100644
--- a/src/main/java/oracle/r2dbc/impl/OracleResultImpl.java
+++ b/src/main/java/oracle/r2dbc/impl/OracleResultImpl.java
@@ -268,7 +268,6 @@ protected void setPublished() {
* statement which created the {@code ResultSet} to remain open until all
* results are consumed.
* @param resultSet {@code ResultSet} to publish. Not null.
- * @param adapter Adapts JDBC calls into reactive streams. Not null.
* @return A {@code Result} for a ResultSet
*/
public static OracleResultImpl createQueryResult(
@@ -305,7 +304,6 @@ static OracleResultImpl createCallResult(
* statement which created the {@code generatedKeys} {@code ResultSet} to
* remain open until all results are consumed.
* @param generatedKeys Generated values to publish. Not null.
- * @param adapter Adapts JDBC calls into reactive streams. Not null.
*/
static OracleResultImpl createGeneratedValuesResult(
OracleConnectionImpl r2dbcConnection, long updateCount,