MaxSem has uploaded a new change for review. https://gerrit.wikimedia.org/r/201091
Change subject: Disable preferences save spam ...................................................................... Disable preferences save spam Change-Id: I53292cb13df942b833d6bc2fbf220fa79361f618 --- A src/hierator/DisabledPreferences.java A src/hierator/DisabledPreferencesFactory.java M src/hierator/HieratorServlet.java 3 files changed, 118 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/hierator refs/changes/91/201091/1 diff --git a/src/hierator/DisabledPreferences.java b/src/hierator/DisabledPreferences.java new file mode 100644 index 0000000..0a5a66c --- /dev/null +++ b/src/hierator/DisabledPreferences.java @@ -0,0 +1,75 @@ +package hierator; + +import java.util.prefs.AbstractPreferences; +import java.util.prefs.BackingStoreException; +import java.util.prefs.Preferences; + +/** + * Copyright 2003-2011 Robert Slifka + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * A do-nothing Preferences implementation so that we can avoid the hassles + * of the JVM Preference implementations. + * + * @author Robert Slifka (robert.sli...@gmail.com) + */ +public class DisabledPreferences extends AbstractPreferences { + + public DisabledPreferences() { + super(null, ""); + } + + protected void putSpi(String key, String value) { + + } + + protected String getSpi(String key) { + return null; + } + + protected void removeSpi(String key) { + + } + + protected void removeNodeSpi() throws BackingStoreException { + + } + + protected String[] keysSpi() throws BackingStoreException { + return new String[0]; + } + + protected String[] childrenNamesSpi() + throws BackingStoreException { + return new String[0]; + } + + protected AbstractPreferences childSpi(String name) { + return null; + } + + protected void syncSpi() throws BackingStoreException { + + } + + protected void flushSpi() throws BackingStoreException { + + } + + public Preferences node(String path) { + return new DisabledPreferences(); + } +} + + diff --git a/src/hierator/DisabledPreferencesFactory.java b/src/hierator/DisabledPreferencesFactory.java new file mode 100644 index 0000000..d7b8bf2 --- /dev/null +++ b/src/hierator/DisabledPreferencesFactory.java @@ -0,0 +1,36 @@ +package hierator; + +import java.util.prefs.PreferencesFactory; +import java.util.prefs.Preferences; + +/** + * Copyright 2003-2011 Robert Slifka + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Returns do-nothing Preferences implementation. We don't use this + * facility, so we want to avoid the hassles that come with the JVM's + * implementation. + * + * @author Robert Slifka (robert.sli...@gmail.com) + */ +public class DisabledPreferencesFactory implements PreferencesFactory { + + public Preferences systemRoot() { + return new DisabledPreferences(); + } + + public Preferences userRoot() { + return new DisabledPreferences(); + } +} diff --git a/src/hierator/HieratorServlet.java b/src/hierator/HieratorServlet.java index 3cb0a06..a8be6f6 100644 --- a/src/hierator/HieratorServlet.java +++ b/src/hierator/HieratorServlet.java @@ -24,6 +24,13 @@ */ public HieratorServlet() { super(); + + /** + * JSesh attempts to periodically save empty preferences. Disable their loading/saving using + * the code from http://allaboutbalance.com/articles/disableprefs/ + */ + System.setProperty("java.util.prefs.PreferencesFactory", "hierator.DisabledPreferencesFactory"); + routing.put("png", new PngRenderer()); routing.put("svg", new SvgRenderer()); routing.put("list", new HieroglyphLister()); -- To view, visit https://gerrit.wikimedia.org/r/201091 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I53292cb13df942b833d6bc2fbf220fa79361f618 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/hierator Gerrit-Branch: master Gerrit-Owner: MaxSem <maxsem.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits