Skip to content

Commit b581178

Browse files
committed
HHH-18976 Use .clone() instead of Arrays#copyOf where possible
1 parent c9831ec commit b581178

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesResultSetImpl.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.hibernate.engine.spi.SharedSessionContractImplementor;
1818
import org.hibernate.exception.DataException;
1919
import org.hibernate.exception.LockTimeoutException;
20-
import org.hibernate.internal.build.AllowReflection;
2120
import org.hibernate.query.spi.Limit;
2221
import org.hibernate.query.spi.QueryOptions;
2322
import org.hibernate.sql.ast.spi.SqlSelection;
@@ -347,15 +346,14 @@ public boolean usesFollowOnLocking() {
347346
}
348347

349348
@Override
350-
@AllowReflection
351349
public void finishRowProcessing(RowProcessingState rowProcessingState, boolean wasAdded) {
352350
if ( queryCachePutManager != null ) {
353351
if ( wasAdded ) {
354352
resultCount++;
355353
}
356354
final Object objectToCache;
357355
if ( valueIndexesToCacheIndexes == null ) {
358-
objectToCache = Arrays.copyOf( currentRowJdbcValues, currentRowJdbcValues.length );
356+
objectToCache = currentRowJdbcValues.clone();
359357
}
360358
else if ( rowToCacheSize < 1 ) {
361359
if ( !wasAdded ) {

rules/forbidden-apis.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ org.hibernate.internal.util.collections.ArrayHelper#newInstance(java.lang.Class,
1515
org.hibernate.internal.util.collections.ArrayHelper#filledArray(java.lang.Object, java.lang.Class, int)
1616
org.hibernate.internal.util.collections.ArrayHelper#join(java.lang.Object[], java.lang.Object[])
1717

18-
@defaultMessage Use a type-specific 'ArrayHelper.copyOf' instead if possible. This forbidden method requires reflection and may not work in natively compiled applications. If you really must use this forbidden method, annotate the calling method with @AllowReflection.
18+
@defaultMessage Use '.clone()' or a type-specific 'ArrayHelper.copyOf' instead if possible. This forbidden method requires reflection and may not work in natively compiled applications. If you really must use this forbidden method, annotate the calling method with @AllowReflection.
1919

2020
java.util.Arrays#copyOf(java.lang.Object[], int)
2121
java.util.Arrays#copyOf(java.lang.Object[], int, java.lang.Class)

0 commit comments

Comments
 (0)