Skip to content

Commit

Permalink
HHH-18976 Use .clone() instead of Arrays#copyOf where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Jan 8, 2025
1 parent c9831ec commit b581178
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.exception.DataException;
import org.hibernate.exception.LockTimeoutException;
import org.hibernate.internal.build.AllowReflection;
import org.hibernate.query.spi.Limit;
import org.hibernate.query.spi.QueryOptions;
import org.hibernate.sql.ast.spi.SqlSelection;
Expand Down Expand Up @@ -347,15 +346,14 @@ public boolean usesFollowOnLocking() {
}

@Override
@AllowReflection
public void finishRowProcessing(RowProcessingState rowProcessingState, boolean wasAdded) {
if ( queryCachePutManager != null ) {
if ( wasAdded ) {
resultCount++;
}
final Object objectToCache;
if ( valueIndexesToCacheIndexes == null ) {
objectToCache = Arrays.copyOf( currentRowJdbcValues, currentRowJdbcValues.length );
objectToCache = currentRowJdbcValues.clone();
}
else if ( rowToCacheSize < 1 ) {
if ( !wasAdded ) {
Expand Down
2 changes: 1 addition & 1 deletion rules/forbidden-apis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ org.hibernate.internal.util.collections.ArrayHelper#newInstance(java.lang.Class,
org.hibernate.internal.util.collections.ArrayHelper#filledArray(java.lang.Object, java.lang.Class, int)
org.hibernate.internal.util.collections.ArrayHelper#join(java.lang.Object[], java.lang.Object[])

@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.
@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.

java.util.Arrays#copyOf(java.lang.Object[], int)
java.util.Arrays#copyOf(java.lang.Object[], int, java.lang.Class)
Expand Down

0 comments on commit b581178

Please sign in to comment.