ARTEMIS-976: PostgresSequentialSequentialFileDriver SQLProvider NPE fix

(cherry picked from commit fc70f9414a)
This commit is contained in:
dOkI 2017-02-17 00:35:49 +05:00 committed by Clebert Suconic
parent f082185d7f
commit 6d0f28291f
2 changed files with 18 additions and 3 deletions

View File

@ -44,8 +44,7 @@ class JDBCFileUtils {
static JDBCSequentialFileFactoryDriver getDBFileDriver(DataSource dataSource, SQLProvider provider) throws SQLException {
JDBCSequentialFileFactoryDriver dbDriver;
if (provider instanceof PostgresSQLProvider) {
dbDriver = new PostgresSequentialSequentialFileDriver();
dbDriver.setDataSource(dataSource);
dbDriver = new PostgresSequentialSequentialFileDriver(dataSource, provider);
} else {
dbDriver = new JDBCSequentialFileFactoryDriver(dataSource, provider);
}
@ -55,7 +54,7 @@ class JDBCFileUtils {
static JDBCSequentialFileFactoryDriver getDBFileDriver(Connection connection, SQLProvider provider) throws SQLException {
JDBCSequentialFileFactoryDriver dbDriver;
if (provider instanceof PostgresSQLProvider) {
dbDriver = new PostgresSequentialSequentialFileDriver();
dbDriver = new PostgresSequentialSequentialFileDriver(connection, provider);
dbDriver.setConnection(connection);
} else {
dbDriver = new JDBCSequentialFileFactoryDriver(connection, provider);

View File

@ -17,14 +17,18 @@
package org.apache.activemq.artemis.jdbc.store.file;
import java.nio.ByteBuffer;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.activemq.artemis.jdbc.store.sql.SQLProvider;
import org.postgresql.PGConnection;
import org.postgresql.largeobject.LargeObject;
import org.postgresql.largeobject.LargeObjectManager;
import javax.sql.DataSource;
@SuppressWarnings("SynchronizeOnNonFinalField")
public final class PostgresSequentialSequentialFileDriver extends JDBCSequentialFileFactoryDriver {
@ -34,6 +38,18 @@ public final class PostgresSequentialSequentialFileDriver extends JDBCSequential
super();
}
public PostgresSequentialSequentialFileDriver(DataSource dataSource, SQLProvider provider) {
super();
this.setDataSource(dataSource);
this.setSqlProvider(provider);
}
public PostgresSequentialSequentialFileDriver(Connection connection, SQLProvider provider) {
super();
this.setConnection(connection);
this.setSqlProvider(provider);
}
@Override
protected void prepareStatements() throws SQLException {
this.deleteFile = connection.prepareStatement(sqlProvider.getDeleteFileSQL());