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

Upgrades Oracle database libraries to version 21.9.0.0. Adds tests under datasource-ucp CDI integration. #8221

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 3 additions & 2 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@
<version.lib.neo4j>5.12.0</version.lib.neo4j>
<version.lib.netty>4.1.100.Final</version.lib.netty>
<version.lib.oci>3.34.0</version.lib.oci>
<version.lib.ojdbc8>21.4.0.0</version.lib.ojdbc8>
<version.lib.ojdbc>21.11.0.0</version.lib.ojdbc>
<version.lib.ojdbc8>${version.lib.ojdbc}</version.lib.ojdbc8>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we keeping this property for backward compatibility or should we remove it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My assumption has always been that if there is a property defined in a pom.xml somewhere that appears in the inheritance chain of, say, applications/mp/pom.xml, which this one does, then it probably should obey the rules of semantic versioning, so should stick around, in this case, until Helidon 5. Maybe others have opinions.

<!-- Force upgrade okio for CVE-2023-3635. When okhttp 4.12.0 is available we can remove this -->
<version.lib.okio>3.4.0</version.lib.okio>
<!-- Force upgrade okhttp3 for CVE-2023-0833 -->
Expand Down Expand Up @@ -1379,7 +1380,7 @@
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc-bom</artifactId>
<version>${version.lib.ojdbc8}</version>
<version>${version.lib.ojdbc}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/employee-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<dependencies>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8-production</artifactId>
<artifactId>ojdbc11-production</artifactId>
<type>pom</type>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/integrations/cdi/datasource-hikaricp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<!-- Runtime-scoped dependencies. -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8-production</artifactId>
<artifactId>ojdbc11-production</artifactId>
<type>pom</type>
<scope>runtime</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/integrations/oci/atp-cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8-production</artifactId>
<artifactId>ojdbc11-production</artifactId>
<type>pom</type>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/integrations/oci/atp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8-production</artifactId>
<artifactId>ojdbc11-production</artifactId>
<type>pom</type>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion integrations/cdi/datasource-ucp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8-production</artifactId>
<artifactId>ojdbc11-production</artifactId>
<type>pom</type>
<scope>compile</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
* Copyright (c) 2024 Oracle and/or its affiliates.
*
* 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 io.helidon.integrations.datasource.ucp.cdi;

import java.sql.Connection;
import java.sql.SQLException;

import oracle.ucp.jdbc.ConnectionInitializationCallback;
import oracle.ucp.jdbc.PoolDataSource;
import oracle.ucp.jdbc.PoolDataSourceFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.jupiter.api.Assertions.fail;

/**
* A test class that shows that the Universal Connection Pool does not reset connection state when a borrowed connection
* is returned.
*/
class TestUcpConnectionStateResetBehavior {

private PoolDataSource pds;

private TestUcpConnectionStateResetBehavior() {
super();
}

@BeforeEach
void initializeDataSource() throws SQLException {
this.pds = PoolDataSourceFactory.getPoolDataSource();

// We register this callback, knowing that UCP will ignore it, despite documentation that does not say so. It
// ignores it because the connection factory (DataSource) we use is H2, not Oracle. In case UCP fixes this
// shortcoming we want to know about it.
this.pds.registerConnectionInitializationCallback(new FailingCallback());
assertThat(this.pds.getConnectionInitializationCallback(), is(instanceOf(FailingCallback.class)));

this.pds.setConnectionFactoryClassName("org.h2.jdbcx.JdbcDataSource");
this.pds.setURL("jdbc:h2:mem:" + this.getClass().getSimpleName());
this.pds.setUser("sa");
this.pds.setPassword("");

this.pds.setInitialPoolSize(2);
this.pds.setMinPoolSize(2);
this.pds.setMaxPoolSize(8); // actually the default but just being explicit
}

@AfterEach
void destroyDataSource() throws SQLException {
this.pds.unregisterConnectionInitializationCallback();
}

@Test
void testUCPErroneouslyDoesNotResetConnectionStateOnReturn() throws SQLException {

// The connection pool has two connections in it.

// Borrow connection zero.
Connection c0 = this.pds.getConnection();
assertThat(c0.getAutoCommit(), is(true)); // we never set it anywhere; default value is true

// Borrow connection one.
Connection c1 = this.pds.getConnection();
assertThat(c1.getAutoCommit(), is(true)); // we never set it anywhere; default value is true

// There are now no more connections available in the pool.
assertThat(this.pds.getAvailableConnectionsCount(), is(0));

// Change the state of connection one.
c1.setAutoCommit(false);

// Return it to the pool.
c1.close();

// There is now exactly one connection available in the pool (the one we just returned).
assertThat(this.pds.getAvailableConnectionsCount(), is(1));

// Borrow connection two. (It will be connection one.)
Connection c2 = this.pds.getConnection();

// There are now no more connections available in the pool.
assertThat(this.pds.getAvailableConnectionsCount(), is(0));

// Note that the state of connection two includes the state of connection one. Oops. The pool really should
// reset at least this portion of the connection state, but it does not.
assertThat(c2.getAutoCommit(), is(false));

// Return it.
c2.close();

// Return connection zero.
c0.close();

// No more borrowed connections are extant.
assertThat(this.pds.getAvailableConnectionsCount(), is(2));
}

private static class FailingCallback implements ConnectionInitializationCallback {

private FailingCallback() {
super();
}

@Override
public void initialize(Connection connection) throws SQLException {
// ConnectionInitializationCallbacks are ignored by the UCP unless you are using an Oracle JDBC driver.
fail();
}

}

}
10 changes: 6 additions & 4 deletions integrations/cdi/datasource-ucp/src/test/logging.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019, 2022 Oracle and/or its affiliates.
# Copyright (c) 2019, 2024 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
.level=INFO
handlers=io.helidon.logging.jul.HelidonConsoleHandler
oracle.ucp.level=FINE
.level = INFO
# handlers = io.helidon.logging.jul.HelidonConsoleHandler
handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = FINEST
oracle.ucp.level = FINEST
4 changes: 2 additions & 2 deletions integrations/db/ojdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8-production</artifactId>
<artifactId>ojdbc11-production</artifactId>
<type>pom</type>
<exclusions>
<exclusion>
Expand All @@ -59,7 +59,7 @@
<!-- Include version without JAXP impl -->
<groupId>com.oracle.database.xml</groupId>
<artifactId>xmlparserv2_sans_jaxp_services</artifactId>
<version>${version.lib.ojdbc8}</version>
<version>${version.lib.ojdbc}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion messaging/connectors/aq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8-production</artifactId>
<artifactId>ojdbc11-production</artifactId>
<type>pom</type>
</dependency>
<dependency>
Expand Down
Loading