Issues

Select view

Select search mode

 

BytecodeProviderImpl throwing java.lang.IndexOutOfBoundsException

Description

Method org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl#encodeName) is invoked with three parameters propertyNames, getters, and setters. All three are of type java.util.List. Assumption is that all three lists are of equal size. However, this assumption is not correct. First list (propertyNames) can contain more element from either one or both other lists:

 

if ( getter.getDeclaringClass() == foreignPackageClassInfo.clazz && !Modifier.isPublic( getter.getModifiers() ) ) { foreignPackageClassInfo.getters.add( getter ); found = true; } if ( setter.getDeclaringClass() == foreignPackageClassInfo.clazz && !Modifier.isPublic( setter.getModifiers() ) ) { foreignPackageClassInfo.setters.add( setter ); found = true; } if ( found ) { foreignPackageClassInfo.propertyNames.add( propertyNames[i] ); }

In code above if either getter or setter is not added to corresponding list, property name will be still included, and one list will be shorter than property names list. This will cause `Index x out of bounds for length x` exception to be thrown in encodeName method (either getters or setters is shorter than propertyNames):

for ( int i = 0; i < propertyNames.size(); i++ ) { final String propertyName = propertyNames.get( i ); final Member getter = getters.get( i ); final Member setter = setters.get( i ); // Encode the two member types as 4 bit integer encoded as hex character sb.append( Integer.toHexString( getKind( getter ) << 2 | getKind( setter ) ) ); sb.append( propertyName ); }

[Additionally, getters.get(i) and setters.get(i) are not necessarily belonging to same property, but this is ‘hidden’ by exception]

 

Pull request #9952 is based on existing tes case by slightly changing model class(es)

Details

Assignee

Reporter

Affects versions

Priority

Created 10 hours ago
Updated 9 hours ago

Activity

Show:

Flag notifications