Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

JavaDoc and Code Clean Up for 1.3.0 #158

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions src/main/java/oracle/r2dbc/impl/AsyncLock.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* <p>
Expand Down Expand Up @@ -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.
* </p><p>
* The {@code Runnable} provided to {@link #lock(Runnable)} <i>MUST</i> 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.
* </p>
* <h3>Locking for Synchronous JDBC Calls</h3>
* <p>
Expand All @@ -96,7 +84,7 @@
* methods.
* </p>
*/
public interface AsyncLock {
interface AsyncLock {

/**
* Acquires this lock, executes a {@code callback}, and then releases this
Expand Down
20 changes: 6 additions & 14 deletions src/main/java/oracle/r2dbc/impl/OracleBatchImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
*/
Expand All @@ -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();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/oracle/r2dbc/impl/OracleConnectionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ public Publisher<Void> close() {
* publisher when there is no obligation to do so.
* </p>
*
* @param <T> the type of element signaled by the publisher.
*
* @param publisher Publisher that must be subscribed to before closing the
* JDBC connection. Not null.
*
Expand Down
42 changes: 4 additions & 38 deletions src/main/java/oracle/r2dbc/impl/OracleReadableImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand All @@ -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.
* </p>
* @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.
*/
Expand All @@ -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.
*/
Expand Down Expand Up @@ -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);
}
*/
}

/**
Expand Down Expand Up @@ -741,7 +723,7 @@ private static Map<String, Object> toMap(OracleReadableImpl readable) {
private <T,U> Function<T,U> getMappingFunction(
Class<T> fromType, Class<U> toType) {

Function<? extends Object, Object> mappingFunction = null;
Function<?, Object> mappingFunction = null;

if (toType.isAssignableFrom(fromType)) {
return toType::cast;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1046,11 +1014,10 @@ private static final class OutParametersImpl
* {@code jdbcReadable} and obtains metadata of the values from
* {@code outParametersMetaData}.
* </p>
* @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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/oracle/r2dbc/impl/OracleResultImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
Loading