I am working on upgrading from WLS10g and JavaEE6 to WLS12c and JavaEE7.
I noticed a difference in how it works HttpSession.setAttribute. In WLS10, any object already stored under a specific key will always be replaced.
In WLS12, an object is not replaced if newObject.equals(oldObject).
This is a problem for us, because applications have these objects:
class ValueObject {
int key;
String data;
@Override
public int hashCode()
{
return key;
}
boolean equals(Object o) {
if (o == null || (o instanceof ValueObject) == false) {
return false;
}
ValueObject otherObject = (ValueObject)o;
return key == otherObject.key;
}
}
ValueObject changes through a workflow that spans multiple web pages. Intermediate values are stored in HTTPSession, and at the end of the workflow, the changed value is written to the database.
There is such code in servlets (members are actually modified using getters / seters, but I simplify reducing the amount of code in the question):
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
HttpSession session = request.getSession();
ValueObject newValue = new ValueObject();
newValue.key = Integer.parseInt(request.getParameter("key"));
newValue.data = request.getParameter("data");
session.setAttribute("value", newValue);
...
newValue.keynot changed, but newValue.datahas a new meaning.
HTTPSession WLS12 - , data , .
, :
session.setAttribute("value", newValue);
to
session.removeAttribute("value");
session.setAttribute("value", newValue);
, 100 , . , , .
WLS12c , HttpSession.setAttribute()?
2015-09-30:
, Oracle. , wero. , Weblogic , , , weblogic.server.internal.ServletRequestImpl, , ClassCastException Weblogic.
, Gimby. - . memory .
2016-02-03:
Oracle " ".