{"action":"created","issue":{"url":"https://api.github.com/repos/igniterealtime/Openfire/issues/306","labels_url":"https://api.github.com/repos/igniterealtime/Openfire/issues/306/labels{/name}","comments_url":"https://api.github.com/repos/igniterealtime/Openfire/issues/306/comments","events_url":"https://api.github.com/repos/igniterealtime/Openfire/issues/306/events","html_url":"https://github.com/igniterealtime/Openfire/pull/306","id":111053336,"number":306,"title":"Made connection retry parameters configurable","user":{"login":"AlphaGit","id":1113433,"avatar_url":"https://avatars.githubusercontent.com/u/1113433?v=3","gravatar_id":"","url":"https://api.github.com/users/AlphaGit","html_url":"https://github.com/AlphaGit","followers_url":"https://api.github.com/users/AlphaGit/followers","following_url":"https://api.github.com/users/AlphaGit/following{/other_user}","gists_url":"https://api.github.com/users/AlphaGit/gists{/gist_id}","starred_url":"https://api.github.com/users/AlphaGit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlphaGit/subscriptions","organizations_url":"https://api.github.com/users/AlphaGit/orgs","repos_url":"https://api.github.com/users/AlphaGit/repos","events_url":"https://api.github.com/users/AlphaGit/events{/privacy}","received_events_url":"https://api.github.com/users/AlphaGit/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-12T20:50:29Z","updated_at":"2015-10-22T11:16:57Z","closed_at":"2015-10-19T12:33:15Z","pull_request":{"url":"https://api.github.com/repos/igniterealtime/Openfire/pulls/306","html_url":"https://github.com/igniterealtime/Openfire/pull/306","diff_url":"https://github.com/igniterealtime/Openfire/pull/306.diff","patch_url":"https://github.com/igniterealtime/Openfire/pull/306.patch"},"body":"Some cloud environments will enforce throttling parameters on database access (Microsoft Azure is a great example of that). As such, it is important that administrators are able to configure OpenFire's retry policy on the database login in order to prevent DoS'ing themselves from the database.\r\n\r\nThis small change does the following:\r\n\r\n- introduces `database.defaultProvider.maxRetries` as the server property that will indicate how many retries can be used before giving up (default: 10 retries)\r\n- introduces `database.defaultProvider.retryDelay` as the server property that will indicate how much OpenFire will wait until retrying the connection (default: 250 ms). (Note: should it be called \"retryDelayMs\" for better clarity? Seems weird. \"retryDelayMsec\"?)\r\n- refactored some `if (condition) { statements }` into `if (!condition) return; statements;` to avoid nesting\r\n- refactored out `ensureConnectionProvider()`, the first part that `getConnection()` did, just for clarity\r\n- other minor adjustments (variable names, comments, indentation)"},"comment":{"url":"https://api.github.com/repos/igniterealtime/Openfire/issues/comments/150184082","html_url":"https://github.com/igniterealtime/Openfire/pull/306#issuecomment-150184082","issue_url":"https://api.github.com/repos/igniterealtime/Openfire/issues/306","id":150184082,"user":{"login":"guusdk","id":4253898,"avatar_url":"https://avatars.githubusercontent.com/u/4253898?v=3","gravatar_id":"","url":"https://api.github.com/users/guusdk","html_url":"https://github.com/guusdk","followers_url":"https://api.github.com/users/guusdk/followers","following_url":"https://api.github.com/users/guusdk/following{/other_user}","gists_url":"https://api.github.com/users/guusdk/gists{/gist_id}","starred_url":"https://api.github.com/users/guusdk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guusdk/subscriptions","organizations_url":"https://api.github.com/users/guusdk/orgs","repos_url":"https://api.github.com/users/guusdk/repos","events_url":"https://api.github.com/users/guusdk/events{/privacy}","received_events_url":"https://api.github.com/users/guusdk/received_events","type":"User","site_admin":false},"created_at":"2015-10-22T11:16:57Z","updated_at":"2015-10-22T11:16:57Z","body":"Auch! There's an issue with this commit. Setting up a fresh Openfire instance now throws a StackOverFlow exception while setting up the database. This is called recursively:\r\n\r\n        at org.jivesoftware.util.XMLProperties.parsePropertyName(XMLProperties.java:805)\r\n        at org.jivesoftware.util.XMLProperties.getProperty(XMLProperties.java:185)\r\n        at org.jivesoftware.util.XMLProperties.getProperty(XMLProperties.java:169)\r\n        at org.jivesoftware.util.JiveGlobals.getXMLProperty(JiveGlobals.java:321)\r\n        at org.jivesoftware.util.JiveGlobals.isSetupMode(JiveGlobals.java:970)\r\n        at org.jivesoftware.util.JiveGlobals.getProperty(JiveGlobals.java:536)\r\n        at org.jivesoftware.util.JiveGlobals.getIntProperty(JiveGlobals.java:578)\r\n        at org.jivesoftware.database.DbConnectionManager.getConnection(DbConnectionManager.java:124)\r\n        at org.jivesoftware.util.JiveGlobals.isSetupMode(JiveGlobals.java:981)\r\n        at org.jivesoftware.util.JiveGlobals.getProperty(JiveGlobals.java:536)\r\n        at org.jivesoftware.util.JiveGlobals.getIntProperty(JiveGlobals.java:578)\r\n        at org.jivesoftware.database.DbConnectionManager.getConnection(DbConnectionManager.java:124)\r\n\r\nThe issue at hand: to set up the database, we (now) use a property. To read a property, we determine if we're in setup mode. To determine if we're in setup mode, we see if there's a database configured. Lather, rinse, repeat."}}