Skip to content

Commit

Permalink
payara#4281 Introduced internal getter that does not cause deadlock
Browse files Browse the repository at this point in the history
- isValid has side effect described in Session interface
- we cannot break contract
  • Loading branch information
sgflt authored and David Matejcek committed Apr 16, 2020
1 parent 4b1b4af commit b664e51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1346,13 +1346,22 @@ public Map<String, Object> getAttributes() {
@Override
public Enumeration<String> getAttributeNames() {

if (!getIsValid()) {
if (!isValid()) {
throw new IllegalStateException
("getAttributeNames: " + RESOURCE_BUNDLE.getString(LogFacade.SESSION_INVALIDATED_EXCEPTION));
}

return (new Enumerator<>(attributes.keySet(), true));
return getAttributeNamesInternal();

}

/**
* Returns names of attributes even for expired session.
*
* @return names of attributes ignoring state of session
*/
protected Enumerator<String> getAttributeNamesInternal() {
return new Enumerator<>(attributes.keySet(), true);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public String superToString() {
sb.append("isValid:" + getIsValid());

if (getIsValid()) {
Enumeration<String> attrNamesEnum = getAttributeNames();
Enumeration<String> attrNamesEnum = getAttributeNamesInternal();
while(attrNamesEnum.hasMoreElements()) {
String nextAttrName = attrNamesEnum.nextElement();
Object nextAttrValue = getAttributeInternal(nextAttrName);
Expand Down

0 comments on commit b664e51

Please sign in to comment.