Issue #4861 - changes from review

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2020-05-13 23:05:54 +10:00
parent 629e106045
commit 4aece5e9cf
2 changed files with 18 additions and 27 deletions

View File

@ -1868,10 +1868,13 @@ public class Request implements HttpServletRequest
_asyncNotSupportedSource = null; _asyncNotSupportedSource = null;
_handled = false; _handled = false;
_attributes = Attributes.unwrap(_attributes); _attributes = Attributes.unwrap(_attributes);
if (ServletAttributes.class.equals(_attributes.getClass())) if (_attributes != null)
_attributes.clearAttributes(); {
else if (ServletAttributes.class.equals(_attributes.getClass()))
_attributes = new ServletAttributes(); _attributes.clearAttributes();
else
_attributes = null;
}
_contentType = null; _contentType = null;
_characterEncoding = null; _characterEncoding = null;
_contextPath = null; _contextPath = null;

View File

@ -33,51 +33,39 @@ public class ServletAttributes implements Attributes
_asyncAttributes = attributes; _asyncAttributes = attributes;
} }
private Attributes getAttributes()
{
return (_asyncAttributes == null) ? _attributes : _asyncAttributes;
}
@Override @Override
public void removeAttribute(String name) public void removeAttribute(String name)
{ {
if (_asyncAttributes == null) getAttributes().removeAttribute(name);
_attributes.removeAttribute(name);
else
_asyncAttributes.removeAttribute(name);
} }
@Override @Override
public void setAttribute(String name, Object attribute) public void setAttribute(String name, Object attribute)
{ {
if (_asyncAttributes == null) getAttributes().setAttribute(name, attribute);
_attributes.setAttribute(name, attribute);
else
_asyncAttributes.setAttribute(name, attribute);
} }
@Override @Override
public Object getAttribute(String name) public Object getAttribute(String name)
{ {
if (_asyncAttributes == null) return getAttributes().getAttribute(name);
return _attributes.getAttribute(name);
else
return _asyncAttributes.getAttribute(name);
} }
@Override @Override
public Set<String> getAttributeNameSet() public Set<String> getAttributeNameSet()
{ {
if (_asyncAttributes == null) return getAttributes().getAttributeNameSet();
return _attributes.getAttributeNameSet();
else
return _asyncAttributes.getAttributeNameSet();
} }
@Override @Override
public void clearAttributes() public void clearAttributes()
{ {
if (_asyncAttributes == null) getAttributes().clearAttributes();
_attributes.clearAttributes(); _asyncAttributes = null;
else
{
_asyncAttributes.clearAttributes();
_asyncAttributes = null;
}
} }
} }