Ignore:
Timestamp:
2012-03-08T22:03:42+01:00 (12 years ago)
Author:
simon04
Message:

see #7395 - don't cache erroneously downloaded MOTD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/GettingStarted.java

    r4865 r5061  
    99import java.awt.event.InputEvent;
    1010import java.awt.event.KeyEvent;
     11import java.io.IOException;
    1112import java.io.UnsupportedEncodingException;
    1213import java.net.URL;
     
    5758     * Grabs current MOTD from cache or webpage and parses it.
    5859     */
    59     private static class MotdContent extends CacheCustomContent<RuntimeException> {
     60    private static class MotdContent extends CacheCustomContent<IOException> {
    6061        public MotdContent() {
    6162            super("motd.html", CacheCustomContent.INTERVAL_DAILY);
     
    7071         */
    7172        @Override
    72         protected byte[] updateData() {
     73        protected byte[] updateData() throws IOException {
    7374            String motd = new WikiReader().readLang("StartupPage");
    74             if (motd.length() == 0) {
    75                 motd = "<html>" + STYLE + "<h1>" + "JOSM - " + tr("Java OpenStreetMap Editor")
    76                 + "</h1>\n<h2 align=\"center\">(" + tr("Message of the day not available") + ")</h2></html>";
    77             }
    7875            // Save this to prefs in case JOSM is updated so MOTD can be refreshed
    7976            Main.pref.putInteger("cache.motd.html.version", myVersion);
     
    118115        // Asynchronously get MOTD to speed-up JOSM startup
    119116        Thread t = new Thread(new Runnable() {
     117            @Override
    120118            public void run() {
    121                 if (content.length() == 0 && Main.pref.getBoolean("help.displaymotd", true)) {
    122                     content = new MotdContent().updateIfRequiredString();
     119                if (content.isEmpty() && Main.pref.getBoolean("help.displaymotd", true)) {
     120                    try {
     121                        content = new MotdContent().updateIfRequiredString();
     122                    } catch (IOException ex) {
     123                        System.out.println(tr("Warning: failed to read MOTD. Exception was: {1}", ex.toString()));
     124                        content = "<html>" + STYLE + "<h1>" + "JOSM - " + tr("Java OpenStreetMap Editor")
     125                                + "</h1>\n<h2 align=\"center\">(" + tr("Message of the day not available") + ")</h2></html>";
     126                    }
    123127                }
    124128
    125129                EventQueue.invokeLater(new Runnable() {
     130                    @Override
    126131                    public void run() {
    127132                        lg.setText(fixImageLinks(content));
Note: See TracChangeset for help on using the changeset viewer.