Commit 2ad60199 authored by Dele Olajide's avatar Dele Olajide

Merge pull request #46 from sco0ter/of823

OF-823 Numeric overflow in MUCPersistenceManager when loading history ol...
parents a905f997 3337e79d
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
package org.jivesoftware.openfire.muc.spi; package org.jivesoftware.openfire.muc.spi;
import java.math.BigInteger;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
...@@ -229,7 +230,7 @@ public class MUCPersistenceManager { ...@@ -229,7 +230,7 @@ public class MUCPersistenceManager {
pstmt = con.prepareStatement(LOAD_HISTORY); pstmt = con.prepareStatement(LOAD_HISTORY);
// Reload the history, using "muc.history.reload.limit" (days); defaults to 2 // Reload the history, using "muc.history.reload.limit" (days); defaults to 2
int reloadLimitDays = JiveGlobals.getIntProperty(MUC_HISTORY_RELOAD_LIMIT, 2); int reloadLimitDays = JiveGlobals.getIntProperty(MUC_HISTORY_RELOAD_LIMIT, 2);
long from = System.currentTimeMillis() - (86400000 * reloadLimitDays); long from = System.currentTimeMillis() - (BigInteger.valueOf(86400000).multiply(BigInteger.valueOf(reloadLimitDays))).longValue();
pstmt.setString(1, StringUtils.dateToMillis(new Date(from))); pstmt.setString(1, StringUtils.dateToMillis(new Date(from)));
pstmt.setLong(2, room.getID()); pstmt.setLong(2, room.getID());
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -546,7 +547,7 @@ public class MUCPersistenceManager { ...@@ -546,7 +547,7 @@ public class MUCPersistenceManager {
// if the property is defined, but not numeric, default to 2 (days) // if the property is defined, but not numeric, default to 2 (days)
int reloadLimitDays = JiveGlobals.getIntProperty(MUC_HISTORY_RELOAD_LIMIT, 2); int reloadLimitDays = JiveGlobals.getIntProperty(MUC_HISTORY_RELOAD_LIMIT, 2);
Log.warn("MUC history reload limit set to " + reloadLimitDays + " days"); Log.warn("MUC history reload limit set to " + reloadLimitDays + " days");
from = System.currentTimeMillis() - (86400000 * reloadLimitDays); from = System.currentTimeMillis() - (BigInteger.valueOf(86400000).multiply(BigInteger.valueOf(reloadLimitDays))).longValue();
} }
statement.setLong(1, serviceID); statement.setLong(1, serviceID);
statement.setString(2, StringUtils.dateToMillis(new Date(from))); statement.setString(2, StringUtils.dateToMillis(new Date(from)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment