Skip to content

Commit 90e528d

Browse files
authored
debezium/dbz#1704 providing proper IfxDataSource to IfxCdcEngine (#148)
Providing proper IfxDataSource to IfxCdcEngine in order to avoid race condition in closing connections during connector shutdown.
1 parent 4856596 commit 90e528d

File tree

1 file changed

+5
-58
lines changed

1 file changed

+5
-58
lines changed

src/main/java/io/debezium/connector/informix/InformixConnection.java

Lines changed: 5 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
*/
66
package io.debezium.connector.informix;
77

8-
import java.io.PrintWriter;
9-
import java.sql.Connection;
108
import java.sql.SQLException;
11-
import java.sql.SQLFeatureNotSupportedException;
129
import java.time.Instant;
1310
import java.util.Optional;
1411

@@ -18,6 +15,7 @@
1815
import org.slf4j.LoggerFactory;
1916

2017
import com.informix.jdbc.IfxDriver;
18+
import com.informix.jdbcx.IfxDataSource;
2119

2220
import io.debezium.DebeziumException;
2321
import io.debezium.config.CommonConnectorConfig;
@@ -176,60 +174,9 @@ public String quoteIdentifier(String columnName) {
176174
return InformixIdentifierQuoter.quoteIfNecessary(columnName);
177175
}
178176

179-
public DataSource datasource() {
180-
return new DataSource() {
181-
private PrintWriter logWriter;
182-
183-
@Override
184-
public Connection getConnection() throws SQLException {
185-
return connection();
186-
}
187-
188-
@Override
189-
public Connection getConnection(String username, String password) throws SQLException {
190-
JdbcConfiguration config = JdbcConfiguration.copy(config()).withUser(username).withPassword(password).build();
191-
return FACTORY.connect(config);
192-
}
193-
194-
@Override
195-
public PrintWriter getLogWriter() {
196-
return this.logWriter;
197-
}
198-
199-
@Override
200-
public void setLogWriter(PrintWriter out) {
201-
this.logWriter = out;
202-
}
203-
204-
@Override
205-
public void setLoginTimeout(int seconds) {
206-
throw new UnsupportedOperationException("setLoginTimeout");
207-
}
208-
209-
@Override
210-
public int getLoginTimeout() {
211-
return (int) config().getConnectionTimeout().toSeconds();
212-
}
213-
214-
@Override
215-
public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
216-
return java.util.logging.Logger.getLogger("io.debezium.connector.informix");
217-
}
218-
219-
@Override
220-
@SuppressWarnings("unchecked")
221-
public <T> T unwrap(Class<T> iface) throws SQLException {
222-
if (iface.isInstance(this)) {
223-
return (T) this;
224-
}
225-
throw new SQLException("DataSource of type [" + getClass().getName() + "] cannot be unwrapped as [" + iface.getName() + "]");
226-
}
227-
228-
@Override
229-
public boolean isWrapperFor(Class<?> iface) throws SQLException {
230-
return iface.isInstance(this);
231-
}
232-
};
177+
public DataSource datasource() throws SQLException {
178+
IfxDataSource datasource = new IfxDataSource(connectionString());
179+
datasource.getDsProperties().putAll(config().withoutKnownFields().asProperties());
180+
return datasource;
233181
}
234-
235182
}

0 commit comments

Comments
 (0)