[
https://issues.apache.org/jira/browse/UNOMI-927?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jerome Blanchard updated UNOMI-927:
-----------------------------------
Description:
When a session duration exceed a certain amount of time (24,86 days) the
duration can be negative !
Duration of a session is computed by the difference between 2 timestamp which
are long values.
Whereas, in the documentation and in ES mapping config, a Session's duration is
supposed to be a long:
[https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/manual/src/main/asciidoc/datamodel.adoc#L503]
{code:java}
duration | Integer | The duration of the session in milliseconds{code}
Also in the session mapping config for ESS and OS :
{code:java}
"properties": {
"duration": {
"type": "long"
},
"lastEventDate": {
"type": "date"
}, {code}
[https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/session.json#L21]
[https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/persistence-opensearch/core/src/main/resources/META-INF/cxs/mappings/session.json#L21]
In Session.java, there is a (int) cast when setting LastEventDate()
[https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/api/src/main/java/org/apache/unomi/api/Session.java#L191]
{code:java}
(...)
public void setLastEventDate(Date lastEventDate) {
this.lastEventDate = lastEventDate;
if (lastEventDate != null) {
duration = (int) (lastEventDate.getTime() - timeStamp.getTime());
}
}
/**
* Retrieves the duration.
*
* @return the duration
*/
public int getDuration() {
return duration;
}
(...){code}
It is also unclear why, in some translation (i18n) entries, it is mentioned
some thresholds for session duration in seconds (even of those entries seems to
not be used) :
[https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/plugins/baseplugin/src/main/resources/messages_en.properties#L80]
All duration in persistence are supposed to be milliseconds.
Fixing the issue also requires a database migration to restore negative values
into a real long value.
was:
When a session duration exceed a certain amount of time (24,86 days) the
duration can be negative !
Duration of a session is computed by the difference between 2 timestamp which
are long values.
Whereas, in the documentation and in ES mapping config, a Session's duration is
supposed to be a long:
[https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/manual/src/main/asciidoc/datamodel.adoc#L503]
{code:java}
duration | Integer | The duration of the session in milliseconds{code}
Also in the session mapping config for ESS and OS :
{code:java}
"properties": {
"duration": {
"type": "long"
},
"lastEventDate": {
"type": "date"
}, {code}
[https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/session.json#L21]
[https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/persistence-opensearch/core/src/main/resources/META-INF/cxs/mappings/session.json#L21]
In Session.java, there is a (int) cast when setting LastEventDate()
[https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/api/src/main/java/org/apache/unomi/api/Session.java#L191]
{code:java}
(...)
public void setLastEventDate(Date lastEventDate) {
this.lastEventDate = lastEventDate;
if (lastEventDate != null) {
duration = (int) (lastEventDate.getTime() - timeStamp.getTime());
}
}
/**
* Retrieves the duration.
*
* @return the duration
*/
public int getDuration() {
return duration;
}
(...){code}
It is also unclear why, in some translation (i18n) entries, it is mentioned
some thresholds for session duration in seconds (even of those entries seems to
not be used) :
[https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/plugins/baseplugin/src/main/resources/messages_en.properties#L80]
All duration in persistence are supposed to be milliseconds.
> Long Sessions can have a negative duration
> ------------------------------------------
>
> Key: UNOMI-927
> URL: https://issues.apache.org/jira/browse/UNOMI-927
> Project: Apache Unomi
> Issue Type: Bug
> Components: unomi(-core)
> Affects Versions: unomi-3.0.0
> Reporter: Jerome Blanchard
> Priority: Major
>
> When a session duration exceed a certain amount of time (24,86 days) the
> duration can be negative !
> Duration of a session is computed by the difference between 2 timestamp which
> are long values.
> Whereas, in the documentation and in ES mapping config, a Session's duration
> is supposed to be a long:
> [https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/manual/src/main/asciidoc/datamodel.adoc#L503]
> {code:java}
> duration | Integer | The duration of the session in milliseconds{code}
> Also in the session mapping config for ESS and OS :
> {code:java}
> "properties": {
> "duration": {
> "type": "long"
> },
> "lastEventDate": {
> "type": "date"
> }, {code}
> [https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/session.json#L21]
>
> [https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/persistence-opensearch/core/src/main/resources/META-INF/cxs/mappings/session.json#L21]
> In Session.java, there is a (int) cast when setting LastEventDate()
> [https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/api/src/main/java/org/apache/unomi/api/Session.java#L191]
> {code:java}
> (...)
> public void setLastEventDate(Date lastEventDate) {
> this.lastEventDate = lastEventDate;
> if (lastEventDate != null) {
> duration = (int) (lastEventDate.getTime() - timeStamp.getTime());
> }
> }
> /**
> * Retrieves the duration.
> *
> * @return the duration
> */
> public int getDuration() {
> return duration;
> }
> (...){code}
> It is also unclear why, in some translation (i18n) entries, it is mentioned
> some thresholds for session duration in seconds (even of those entries seems
> to not be used) :
> [https://github.com/apache/unomi/blob/15ae3eaca8c640a00df255bb0da781fa55f19fa8/plugins/baseplugin/src/main/resources/messages_en.properties#L80]
> All duration in persistence are supposed to be milliseconds.
> Fixing the issue also requires a database migration to restore negative
> values into a real long value.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)