Ignore:
Timestamp:
2015-12-05T16:09:41+01:00 (8 years ago)
Author:
Don-vip
Message:

sonar - fix some errors, mainly NPEs

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
4 edited

Legend:

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

    r8870 r9087  
    8181     * @param nodes Nodes to be aligned.
    8282     * @return A array of two nodes.
     83     * @throws IllegalArgumentException if nodes is empty
    8384     */
    8485    private static Node[] nodePairFurthestApart(List<Node> nodes) {
     
    9394            else
    9495                waysRef.retainAll(ref);
     96        }
     97
     98        if (waysRef == null) {
     99            throw new IllegalArgumentException();
    95100        }
    96101
  • trunk/src/org/openstreetmap/josm/actions/DistributeAction.java

    r8870 r9087  
    212212     * @param nodes nodes to distribute
    213213     * @return Commands to execute to perform action
     214     * @throws IllegalArgumentException if nodes is empty
    214215     */
    215216    private static Collection<Command> distributeNodes(Collection<Node> nodes) {
     
    234235        }
    235236
     237        if (nodea == null || nodeb == null) {
     238            throw new IllegalArgumentException();
     239        }
     240
    236241        // Remove the nodes A and B from the list of nodes to move
    237242        nodes.remove(nodea);
     
    266271            }
    267272
    268             // First move the node to A's position, then move it towards B
    269             double dx = ax - s.getEastNorth().east() + (bx-ax)*pos/num;
    270             double dy = ay - s.getEastNorth().north() + (by-ay)*pos/num;
    271 
    272             cmds.add(new MoveCommand(s, dx, dy));
    273 
    274             //remove moved node from the list
    275             nodes.remove(s);
     273            if (s != null) {
     274                // First move the node to A's position, then move it towards B
     275                double dx = ax - s.getEastNorth().east() + (bx-ax)*pos/num;
     276                double dy = ay - s.getEastNorth().north() + (by-ay)*pos/num;
     277
     278                cmds.add(new MoveCommand(s, dx, dy));
     279
     280                //remove moved node from the list
     281                nodes.remove(s);
     282            }
    276283        }
    277284
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r9067 r9087  
    765765     * @param isInner - if true, reverts the direction (for multipolygon islands)
    766766     * @return list of parts, marked with the inside orientation.
     767     * @throws IllegalArgumentException if parts is empty
    767768     */
    768769    private List<WayInPolygon> markWayInsideSide(List<Way> parts, boolean isInner) {
     
    796797                }
    797798            }
     799        }
     800
     801        if (topWay == null || topNode == null) {
     802            throw new IllegalArgumentException();
    798803        }
    799804
     
    855860
    856861        //iterate till full circle is reached
    857         while (true) {
     862        while (curWay != null) {
    858863
    859864            //add cur way
  • trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java

    r8931 r9087  
    418418                way = w;
    419419            }
     420        }
     421        if (way == null) {
     422            return false;
    420423        }
    421424        List<Node> oldNodes = way.getNodes();
Note: See TracChangeset for help on using the changeset viewer.