[hibernate-issues] [JIRA] (HHH-13876) Fix an obvious bug in StandardStack implementation
Nathan Xu (JIRA)
jira at hibernate.atlassian.net
Sat Feb 22 11:23:48 EST 2020
Nathan Xu ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Af1c90216-c2ff-4df7-8e20-9d0e140d7f64 ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZmMyYWJmMTRhZGI3NGJkNzllNjRjODdiYjQ5ZDc5ZjEiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-13876?atlOrigin=eyJpIjoiZmMyYWJmMTRhZGI3NGJkNzllNjRjODdiYjQ5ZDc5ZjEiLCJwIjoiaiJ9 ) HHH-13876 ( https://hibernate.atlassian.net/browse/HHH-13876?atlOrigin=eyJpIjoiZmMyYWJmMTRhZGI3NGJkNzllNjRjODdiYjQ5ZDc5ZjEiLCJwIjoiaiJ9 ) Fix an obvious bug in StandardStack implementation ( https://hibernate.atlassian.net/browse/HHH-13876?atlOrigin=eyJpIjoiZmMyYWJmMTRhZGI3NGJkNzllNjRjODdiYjQ5ZDc5ZjEiLCJwIjoiaiJ9 )
Issue Type: Bug Affects Versions: 5.4.9, 5.4.10, 5.4.11, 5.4.12 Assignee: Unassigned Components: hibernate-core Created: 22/Feb/2020 08:23 AM Priority: Trivial Reporter: Nathan Xu ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Af1c90216-c2ff-4df7-8e20-9d0e140d7f64 )
public class StandardStack<T> implements Stack<T> {
private LinkedList<T> internalStack = new LinkedList<>();
... ....
@Override
public void push(T newCurrent) {
internalStack.addFirst( newCurrent );
}
@Override
public T pop() {
return internalStack.removeFirst();
}
@Override
public T getCurrent() {
return internalStack.peek();
}
@Override
public T getPrevious() {
if ( internalStack.size() < 2 ) {
return null ;
}
return internalStack.get( internalStack.size() - 2 );
}
As you can see, new node is pushed at the beginning of the linked list, so 'getPrevious()' implementation is wrong. We simply return `internalStack.get( 1 )` (current node corresponds to index of 0).
However, this method has never been used. Also, it has been fixed in v6 for its implementation has been totally changed.
( https://hibernate.atlassian.net/browse/HHH-13876#add-comment?atlOrigin=eyJpIjoiZmMyYWJmMTRhZGI3NGJkNzllNjRjODdiYjQ5ZDc5ZjEiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-13876#add-comment?atlOrigin=eyJpIjoiZmMyYWJmMTRhZGI3NGJkNzllNjRjODdiYjQ5ZDc5ZjEiLCJwIjoiaiJ9 )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100121- sha1:96a3924 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200222/7b979381/attachment.html
More information about the hibernate-issues
mailing list