Changeset 5889 in josm for trunk


Ignore:
Timestamp:
2013-04-20T15:50:18+02:00 (7 years ago)
Author:
Don-vip
Message:

fix potential bugs detected by FindBugs

Location:
trunk/src/org/openstreetmap/josm
Files:
14 edited

Legend:

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

    r5854 r5889  
    455455        // listen to change events of the very first layer
    456456        //
    457         firstLayer.addPropertyChangeListener(LayerListDialog.getInstance().getModel());
     457        if (firstLayer != null) {
     458            firstLayer.addPropertyChangeListener(LayerListDialog.getInstance().getModel());
     459        }
    458460    }
    459461
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r5698 r5889  
    4747import org.openstreetmap.josm.tools.Shortcut;
    4848
    49 
    5049/**
    5150 * Join Areas (i.e. closed ways and multipolygons)
     
    5554    private LinkedList<Command> cmds = new LinkedList<Command>();
    5655    private int cmdsCount = 0;
    57 
    5856
    5957    /**
     
    799797
    800798            //if odd number of crossings, invert orientation
    801             if (intersectionCount % 2 == 1) {
     799            if (intersectionCount % 2 != 0) {
    802800                curWayInsideToTheRight = !curWayInsideToTheRight;
    803801            }
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r5886 r5889  
    8181    }
    8282
    83     private static LinkedList<SearchSetting> searchHistory = null;
    84 
     83    private static final LinkedList<SearchSetting> searchHistory = new LinkedList<SearchSetting>();
     84    static {
     85        for (String s: Main.pref.getCollection("search.history", Collections.<String>emptyList())) {
     86            SearchSetting ss = SearchSetting.readFromString(s);
     87            if (ss != null) {
     88                searchHistory.add(ss);
     89            }
     90        }
     91    }
     92   
    8593    public static Collection<SearchSetting> getSearchHistory() {
    86         if (searchHistory == null) {
    87             searchHistory = new LinkedList<SearchSetting>();
    88             for (String s: Main.pref.getCollection("search.history", Collections.<String>emptyList())) {
    89                 SearchSetting ss = SearchSetting.readFromString(s);
    90                 if (ss != null) {
    91                     searchHistory.add(ss);
    92                 }
    93             }
    94         }
    95 
    9694        return searchHistory;
    9795    }
  • trunk/src/org/openstreetmap/josm/data/AutosaveTask.java

    r5874 r5889  
    295295                        try {
    296296                            String jvmId = reader.readLine();
    297                             String pid = jvmId.split("@")[0];
    298                             skipFile = jvmPerfDataFileExists(pid);
     297                            if (jvmId != null) {
     298                                String pid = jvmId.split("@")[0];
     299                                skipFile = jvmPerfDataFileExists(pid);
     300                            }
    299301                        } catch (Throwable t) {
    300302                            System.err.println(t.getClass()+":"+t.getMessage());
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r5548 r5889  
    366366
    367367    public static double parseDouble(Map<String, String> parameters, String parameterName) throws ProjectionConfigurationException {
     368        if (!parameters.containsKey(parameterName))
     369            throw new IllegalArgumentException(tr("Unknown parameter ''{0}''", parameterName));
    368370        String doubleStr = parameters.get(parameterName);
    369         if (doubleStr == null && parameters.containsKey(parameterName))
     371        if (doubleStr == null)
    370372            throw new ProjectionConfigurationException(
    371373                    tr("Expected number argument for parameter ''{0}''", parameterName));
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r5634 r5889  
    165165        if (proj != null) return proj;
    166166        ProjectionChoice pc = allProjectionChoicesByCode.get(code);
    167         if (pc != null) {
     167        if (pc == null) {
    168168            Pair<String, String> pair = inits.get(code);
    169169            if (pair == null) return null;
     
    183183        return Collections.unmodifiableCollection(allCodes);
    184184    }
    185 
    186185}
  • trunk/src/org/openstreetmap/josm/gui/GettingStarted.java

    r5886 r5889  
    3131import org.openstreetmap.josm.tools.WikiReader;
    3232
    33 public class GettingStarted extends JPanel {
     33public final class GettingStarted extends JPanel {
    3434    private String content = "";
    3535    private static final String STYLE = "<style type=\"text/css\">\n"
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/AdvancedChangesetQueryPanel.java

    r5886 r5889  
    11551155                return null;
    11561156
    1157             for (int i = 0; i< 4; i++) {
     1157            for (int style : new int[]{DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG, DateFormat.FULL}) {
    11581158                try {
    1159                     DateFormat df = null;
    1160                     switch(i) {
    1161                     case 0: df = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.getDefault()); break;
    1162                     case 1: df = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.getDefault()); break;
    1163                     case 2: df = DateFormat.getTimeInstance(DateFormat.LONG, Locale.getDefault()); break;
    1164                     case 3: df = DateFormat.getTimeInstance(DateFormat.FULL,Locale.getDefault()); break;
    1165                     }
    1166                     Date d = df.parse(getComponent().getText());
    1167                     return d;
     1159                    return DateFormat.getTimeInstance(style, Locale.getDefault()).parse(getComponent().getText());
    11681160                } catch(ParseException e) {
    11691161                    continue;
  • trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java

    r5810 r5889  
    118118    protected boolean autoDownloadEnabled = true;
    119119    protected boolean settingsChanged;
    120     protected ImageryInfo info;
    121120    public WmsCache cache;
    122121    private AttributionSupport attribution = new AttributionSupport();
     
    159158        setBackgroundLayer(true); /* set global background variable */
    160159        initializeImages();
    161         this.info = new ImageryInfo(info);
    162160
    163161        attribution.initialize(this.info);
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/WMSLayerTree.java

    r5617 r5889  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.gui.preferences.imagery;
    23
     
    45
    56import java.awt.Component;
    6 import java.io.Serializable;
    77import java.util.LinkedList;
    88import java.util.List;
     9
    910import javax.swing.JOptionPane;
    1011import javax.swing.JTree;
     
    1617import javax.swing.tree.MutableTreeNode;
    1718import javax.swing.tree.TreePath;
     19
    1820import org.openstreetmap.josm.io.imagery.WMSImagery;
    1921
    20 public class WMSLayerTree implements Serializable {
     22public class WMSLayerTree {
    2123    private final MutableTreeNode treeRootNode = new DefaultMutableTreeNode();
    2224    private final DefaultTreeModel treeData = new DefaultTreeModel(treeRootNode);
     
    3739    }
    3840
     41    /**
     42     * Constructs a new {@code WMSLayerTree}.
     43     */
    3944    public WMSLayerTree() {
    4045        layerTree.setCellRenderer(new LayerTreeCellRenderer());
    4146        layerTree.addTreeSelectionListener(new WMSTreeSelectionListener());
    42 
    4347    }
    4448
  • trunk/src/org/openstreetmap/josm/io/InvalidXmlCharacterFilter.java

    r5855 r5889  
    4141    @Override
    4242    public int read() throws IOException {
    43         return filter((byte)read());
     43        return filter((byte)super.read());
    4444    }
    4545
  • trunk/src/org/openstreetmap/josm/io/auth/AbstractCredentialsAgent.java

    r5863 r5889  
    5050                public void run() {
    5151                    CredentialDialog dialog = null;
    52                     switch(requestorType) {
    53                     case SERVER: dialog = CredentialDialog.getOsmApiCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break;
    54                     case PROXY: dialog = CredentialDialog.getHttpProxyCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break;
    55                     }
     52                    if (requestorType.equals(RequestorType.PROXY))
     53                        dialog = CredentialDialog.getHttpProxyCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText());
     54                    else
     55                        dialog = CredentialDialog.getOsmApiCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText());
    5656                    dialog.setVisible(true);
    5757                    response.setCanceled(dialog.isCanceled());
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java

    r5876 r5889  
    135135        Writer out = null;
    136136        try {
    137             OutputStream raw = new BufferedOutputStream(
    138                     request.getOutputStream());
     137            OutputStream raw = new BufferedOutputStream(request.getOutputStream());
    139138            out = new OutputStreamWriter(raw);
    140139            BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream(), "ASCII"));
    141140           
    142141            String get = in.readLine();
     142            if (get == null) {
     143                sendError(out);
     144                return;
     145            }
    143146            System.out.println("RemoteControl received: " + get);
    144147
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandler.java

    r5872 r5889  
    7777                int urlIdx = query.indexOf("&url=");
    7878                if (urlIdx != -1) {
    79                     /*String url =*/ query.substring(urlIdx + 1);
    8079                    args.put("url", decodeParam(query.substring(urlIdx + 5)));
    8180                    query = query.substring(0, urlIdx);
Note: See TracChangeset for help on using the changeset viewer.