Skip to content

Commit 69db2a0

Browse files
committed
use AtomicReference to capture the updated column name in test
1 parent 80acc4e commit 69db2a0

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/test/java/org/apache/commons/beanutils2/sql/DynaResultSetTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.sql.ResultSet;
2929
import java.sql.SQLException;
3030
import java.util.Iterator;
31+
import java.util.concurrent.atomic.AtomicReference;
3132

3233
import org.apache.commons.beanutils2.DynaBean;
3334
import org.apache.commons.beanutils2.DynaProperty;
@@ -105,17 +106,17 @@ void testGetName() {
105106
*/
106107
@Test
107108
void testSetUsesColumnName() throws Exception {
108-
final String[] updatedColumn = new String[1];
109+
final AtomicReference<String> updatedColumn = new AtomicReference<>();
109110
final ResultSet resultSet = TestResultSet.createProxy(new TestResultSet() {
110111
@Override
111112
public void updateObject(final String columnName, final Object value) throws SQLException {
112-
updatedColumn[0] = columnName;
113+
updatedColumn.set(columnName);
113114
}
114115
});
115116
final ResultSetDynaClass rsdc = new ResultSetDynaClass(resultSet);
116117
final DynaBean row = rsdc.iterator().next();
117118
row.set("stringproperty", "new value");
118-
assertEquals("stringProperty", updatedColumn[0], "update targets the real column name");
119+
assertEquals("stringProperty", updatedColumn.get(), "update targets the real column name");
119120
}
120121

121122
@Test

0 commit comments

Comments
 (0)