Skip to content

Commit

Permalink
Merge pull request #115 from reda-alaoui
Browse files Browse the repository at this point in the history
* cache-row-set-factory:
  Polish "RowSetFactory is costly to build and is built very often"
  RowSetFactory is costly to build and is built very often

Closes gh-115
  • Loading branch information
ttddyy committed Oct 12, 2024
2 parents 3c4b168 + 838ed45 commit baa4421
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
@IgnoreJRERequirement
public class CachedRowSetResultSetProxyLogicFactory implements ResultSetProxyLogicFactory {

private final RowSetFactory rowSetFactory;

public CachedRowSetResultSetProxyLogicFactory() {
try {
this.rowSetFactory = RowSetProvider.newFactory();
} catch (SQLException ex) {
throw new RuntimeException(ex);
}
}

@Override
public ResultSetProxyLogic create(ResultSet resultSet, ConnectionInfo connectionInfo, ProxyConfig proxyConfig) {
ResultSet cachedRowSet = getCachedRowSet(resultSet);
Expand All @@ -40,8 +50,7 @@ protected ResultSet getCachedRowSet(ResultSet resultSet) {
try {
// CachedRowSet only works with non-null ResultSet
if (resultSet.getMetaData().getColumnCount() > 0) {
RowSetFactory rowSetFactory = RowSetProvider.newFactory();
CachedRowSet cachedRowSet = rowSetFactory.createCachedRowSet();
CachedRowSet cachedRowSet = this.rowSetFactory.createCachedRowSet();
cachedRowSet.populate(resultSet);
return cachedRowSet;
} else {
Expand Down

0 comments on commit baa4421

Please sign in to comment.