46
46
import oracle .sql .INTERVALYM ;
47
47
import oracle .sql .TIMESTAMPLTZ ;
48
48
import oracle .sql .TIMESTAMPTZ ;
49
+ import org .reactivestreams .Publisher ;
49
50
50
51
import java .math .BigDecimal ;
51
52
import java .nio .ByteBuffer ;
93
94
class OracleReadableImpl implements io .r2dbc .spi .Readable {
94
95
95
96
97
+ /** The R2DBC connection that created this readable */
98
+ private final OracleConnectionImpl r2dbcConnection ;
99
+
96
100
/** The JDBC connection that created this readable */
97
101
private final java .sql .Connection jdbcConnection ;
98
102
@@ -117,21 +121,21 @@ class OracleReadableImpl implements io.r2dbc.spi.Readable {
117
121
* {@code jdbcReadable} and obtains metadata of the values from
118
122
* {@code resultMetadata}.
119
123
* </p>
120
- * @param jdbcConnection JDBC connection that created the
124
+ * @param r2dbcConnection R2DBC connection that created the
121
125
* {@code jdbcReadable}. Not null.
122
126
* @param jdbcReadable Readable values from a JDBC Driver. Not null.
123
127
* @param readablesMetadata Metadata of each value. Not null.
124
128
* @param adapter Adapts JDBC calls into reactive streams. Not null.
125
129
*/
126
130
private OracleReadableImpl (
127
- java . sql . Connection jdbcConnection , DependentCounter dependentCounter ,
128
- JdbcReadable jdbcReadable , ReadablesMetadata <?> readablesMetadata ,
129
- ReactiveJdbcAdapter adapter ) {
130
- this .jdbcConnection = jdbcConnection ;
131
+ OracleConnectionImpl r2dbcConnection , DependentCounter dependentCounter ,
132
+ JdbcReadable jdbcReadable , ReadablesMetadata <?> readablesMetadata ) {
133
+ this . r2dbcConnection = r2dbcConnection ;
134
+ this .jdbcConnection = r2dbcConnection . jdbcConnection () ;
131
135
this .dependentCounter = dependentCounter ;
132
136
this .jdbcReadable = jdbcReadable ;
133
137
this .readablesMetadata = readablesMetadata ;
134
- this .adapter = adapter ;
138
+ this .adapter = r2dbcConnection . adapter () ;
135
139
}
136
140
137
141
/**
@@ -151,11 +155,10 @@ private OracleReadableImpl(
151
155
* {@code metadata}. Not null.
152
156
*/
153
157
static Row createRow (
154
- java .sql .Connection jdbcConnection , DependentCounter dependentCounter ,
155
- JdbcReadable jdbcReadable , RowMetadataImpl metadata ,
156
- ReactiveJdbcAdapter adapter ) {
158
+ OracleConnectionImpl r2dbcConnection , DependentCounter dependentCounter ,
159
+ JdbcReadable jdbcReadable , RowMetadataImpl metadata ) {
157
160
return new RowImpl (
158
- jdbcConnection , dependentCounter , jdbcReadable , metadata , adapter );
161
+ r2dbcConnection , dependentCounter , jdbcReadable , metadata );
159
162
}
160
163
161
164
/**
@@ -164,7 +167,7 @@ static Row createRow(
164
167
* the provided {@code jdbcReadable} and {@code rowMetadata}. The metadata
165
168
* object is used to determine the default type mapping of column values.
166
169
* </p>
167
- * @param jdbcConnection JDBC connection that created the
170
+ * @param r2dbcConnection R2DBC connection that created the
168
171
* {@code jdbcReadable}. Not null.
169
172
* @param dependentCounter Counter that is increased for each dependent
170
173
* {@code Result} created by the returned {@code OutParameters}
@@ -175,11 +178,10 @@ static Row createRow(
175
178
* {@code metadata}. Not null.
176
179
*/
177
180
static OutParameters createOutParameters (
178
- java .sql .Connection jdbcConnection , DependentCounter dependentCounter ,
179
- JdbcReadable jdbcReadable , OutParametersMetadataImpl metadata ,
180
- ReactiveJdbcAdapter adapter ) {
181
+ OracleConnectionImpl r2dbcConnection , DependentCounter dependentCounter ,
182
+ JdbcReadable jdbcReadable , OutParametersMetadataImpl metadata ) {
181
183
return new OutParametersImpl (
182
- jdbcConnection , dependentCounter , jdbcReadable , metadata , adapter );
184
+ r2dbcConnection , dependentCounter , jdbcReadable , metadata );
183
185
}
184
186
185
187
/**
@@ -335,11 +337,16 @@ private ByteBuffer getByteBuffer(int index) {
335
337
*/
336
338
private Blob getBlob (int index ) {
337
339
java .sql .Blob jdbcBlob = jdbcReadable .getObject (index , java .sql .Blob .class );
338
- return jdbcBlob == null
339
- ? null
340
- : OracleLargeObjects .createBlob (
341
- adapter .publishBlobRead (jdbcBlob ),
342
- adapter .publishBlobFree (jdbcBlob ));
340
+
341
+ if (jdbcBlob == null )
342
+ return null ;
343
+
344
+ Publisher <Void > freePublisher =
345
+ r2dbcConnection .addCloseTask (adapter .publishBlobFree (jdbcBlob ));
346
+
347
+ return OracleLargeObjects .createBlob (
348
+ adapter .publishBlobRead (jdbcBlob ),
349
+ freePublisher );
343
350
}
344
351
345
352
/**
@@ -367,11 +374,15 @@ private Clob getClob(int index) {
367
374
jdbcClob = jdbcReadable .getObject (index , java .sql .Clob .class );
368
375
}
369
376
370
- return jdbcClob == null
371
- ? null
372
- : OracleLargeObjects .createClob (
373
- adapter .publishClobRead (jdbcClob ),
374
- adapter .publishClobFree (jdbcClob ));
377
+ if (jdbcClob == null )
378
+ return null ;
379
+
380
+ Publisher <Void > freePublisher =
381
+ r2dbcConnection .addCloseTask (adapter .publishClobFree (jdbcClob ));
382
+
383
+ return OracleLargeObjects .createClob (
384
+ adapter .publishClobRead (jdbcClob ),
385
+ freePublisher );
375
386
}
376
387
377
388
/**
@@ -685,11 +696,10 @@ private OracleR2dbcObjectImpl getOracleR2dbcObject(int index) {
685
696
return null ;
686
697
687
698
return new OracleR2dbcObjectImpl (
688
- jdbcConnection ,
699
+ r2dbcConnection ,
689
700
dependentCounter ,
690
701
new StructJdbcReadable (oracleStruct ),
691
- ReadablesMetadata .createAttributeMetadata (oracleStruct ),
692
- adapter );
702
+ ReadablesMetadata .createAttributeMetadata (oracleStruct ));
693
703
}
694
704
695
705
/**
@@ -956,7 +966,7 @@ private Result getResult(int index) {
956
966
957
967
dependentCounter .increment ();
958
968
return OracleResultImpl .createQueryResult (
959
- dependentCounter , resultSet , adapter );
969
+ r2dbcConnection , dependentCounter , resultSet );
960
970
}
961
971
962
972
/**
@@ -994,17 +1004,16 @@ private static final class RowImpl
994
1004
* {@code jdbcReadable}, and uses the specified {@code rowMetadata} to
995
1005
* determine the default type mapping of column values.
996
1006
* </p>
997
- * @param jdbcConnection JDBC connection that created the
1007
+ * @param r2dbcConnection R2DBC connection that created the
998
1008
* {@code jdbcReadable}. Not null.
999
1009
* @param jdbcReadable Row data from the Oracle JDBC Driver. Not null.
1000
1010
* @param metadata Meta-data for the specified row. Not null.
1001
1011
* @param adapter Adapts JDBC calls into reactive streams. Not null.
1002
1012
*/
1003
1013
private RowImpl (
1004
- java .sql .Connection jdbcConnection , DependentCounter dependentCounter ,
1005
- JdbcReadable jdbcReadable , RowMetadataImpl metadata ,
1006
- ReactiveJdbcAdapter adapter ) {
1007
- super (jdbcConnection , dependentCounter , jdbcReadable , metadata , adapter );
1014
+ OracleConnectionImpl r2dbcConnection , DependentCounter dependentCounter ,
1015
+ JdbcReadable jdbcReadable , RowMetadataImpl metadata ) {
1016
+ super (r2dbcConnection , dependentCounter , jdbcReadable , metadata );
1008
1017
this .metadata = metadata ;
1009
1018
}
1010
1019
@@ -1044,10 +1053,9 @@ private static final class OutParametersImpl
1044
1053
* @param adapter Adapts JDBC calls into reactive streams. Not null.
1045
1054
*/
1046
1055
private OutParametersImpl (
1047
- java .sql .Connection jdbcConnection , DependentCounter dependentCounter ,
1048
- JdbcReadable jdbcReadable , OutParametersMetadataImpl metadata ,
1049
- ReactiveJdbcAdapter adapter ) {
1050
- super (jdbcConnection , dependentCounter , jdbcReadable , metadata , adapter );
1056
+ OracleConnectionImpl r2dbcConnection , DependentCounter dependentCounter ,
1057
+ JdbcReadable jdbcReadable , OutParametersMetadataImpl metadata ) {
1058
+ super (r2dbcConnection , dependentCounter , jdbcReadable , metadata );
1051
1059
this .metadata = metadata ;
1052
1060
}
1053
1061
@@ -1068,20 +1076,18 @@ private final class OracleR2dbcObjectImpl
1068
1076
* {@code jdbcReadable} and obtains metadata of the values from
1069
1077
* {@code outParametersMetaData}.
1070
1078
* </p>
1071
- * @param jdbcConnection JDBC connection that created the
1079
+ * @param r2dbcConnection R2DBC connection that created the
1072
1080
* {@code jdbcReadable}. Not null.
1073
1081
* @param structJdbcReadable Readable values from a JDBC Driver. Not null.
1074
1082
* @param metadata Metadata of each value. Not null.
1075
1083
* @param adapter Adapts JDBC calls into reactive streams. Not null.
1076
1084
*/
1077
1085
private OracleR2dbcObjectImpl (
1078
- java . sql . Connection jdbcConnection ,
1086
+ OracleConnectionImpl r2dbcConnection ,
1079
1087
DependentCounter dependentCounter ,
1080
1088
StructJdbcReadable structJdbcReadable ,
1081
- OracleR2dbcObjectMetadataImpl metadata ,
1082
- ReactiveJdbcAdapter adapter ) {
1083
- super (
1084
- jdbcConnection , dependentCounter , structJdbcReadable , metadata , adapter );
1089
+ OracleR2dbcObjectMetadataImpl metadata ) {
1090
+ super (r2dbcConnection , dependentCounter , structJdbcReadable , metadata );
1085
1091
this .metadata = metadata ;
1086
1092
}
1087
1093
0 commit comments