Description:
|
Given
An API going from:
ConnectionFactory newHeartBeatConnectionFactory(ConnectionFactory, long, TimeUnit, SearchRequest, ScheduledExecutorService)
to:
ConnectionFactory newHeartBeatConnectionFactory(ConnectionFactory, long, long, TimeUnit, SearchRequest)
will trigger the following error report:
[ERROR] 7005: Connections: Parameter 3 of 'public ConnectionFactory newHeartBeatConnectionFactory(ConnectionFactory, long, TimeUnit, SearchRequest, ScheduledExecutorService)' has changed its type to long
[ERROR] 7005: Connections: Parameter 4 of 'public ConnectionFactory newHeartBeatConnectionFactory(ConnectionFactory, long, TimeUnit, SearchRequest, ScheduledExecutorService)' has changed its type to TimeUnit
[ERROR] 7005: Connections: Parameter 5 of 'public ConnectionFactory newHeartBeatConnectionFactory(ConnectionFactory, long, TimeUnit, SearchRequest, ScheduledExecutorService)' has changed its type to SearchRequest
When
when trying to ignore this difference with the following code:
<difference>
<className>org/forgerock/opendj/ldap/Connections</className>
<differenceType>7005</differenceType>
<method>%regex[ConnectionFactory newHeartBeatConnectionFactory\(ConnectionFactory, long, .*\)]</method>
<to>%regex[ConnectionFactory newHeartBeatConnectionFactory\(ConnectionFactory, long, long, .*\)]</to>
</difference>
Then
Actual
This difference still gets reported.
Expected
This difference is ignored and not reported anymore.
Explanation
This is because the code in Difference.replaceNthArgumentType() is not trimming the type before appending to the StringBuilder.
While the <method> matches, the <to> does not match, because code ends up testing the following which returns false:
"ConnectionFactory newHeartBeatConnectionFactory(ConnectionFactory, long, long, TimeUnit, SearchRequest)"
.matches("ConnectionFactory newHeartBeatConnectionFactory\(ConnectionFactory, long, long, .*\)")
Notice how undesired extra spaces have been added to the new method signature.
A workaround is possible by using \s+ instead of a simple space ' ', but it makes the regex harder to read than necessary.
Please consider fixing this issue with the attached patch.
|