Modify

Opened 5 years ago

Closed 5 years ago

#17525 closed defect (fixed)

NPE just causes a log message

Reported by: GerdP Owned by: team
Priority: critical Milestone:
Component: Plugin reverter Version:
Keywords: Cc: Don-vip

Description

While working on a patch for the reverter plugin I noticed this log message

2019-03-26 08:54:08.204 SEVERE: Thread main-worker-0 raised java.lang.NullPointerException

There is no hint in the dialog and no traceback in the log explaining what went wrong. With this small hack I can reproduce the problem easily.

  • src/reverter/DataSetCommandMerger.java

     
    106106
    107107        List<Node> newNodes = new ArrayList<>(source.getNodesCount());
    108108        for (Node sourceNode : source.getNodes()) {
     109               if (true) sourceNode = null;
    109110            Node targetNode = (Node) getMergeTarget(sourceNode);
    110111            // Target node is not deleted or it will be undeleted when running existing commands
    111112            if (!targetNode.isDeleted() || nominalRevertedPrimitives.contains(targetNode)) {

Attachments (1)

17525-reverter.patch (925 bytes ) - added by GerdP 5 years ago.
possible solution for reverter

Download all attachments as: .zip

Change History (7)

comment:1 by GerdP, 5 years ago

Owner: Upliner removed
Priority: normalcritical
Summary: NPE in DataSetCommandMerger just causes a log messageNPE just causes a log message

If I got that right this is a potential problem in all routines which override PleaseWaitRunnable.realRun() without a proper try/catch block using

                // Exception has to thrown in EDT to be shown to user
                SwingUtilities.invokeLater(() -> {
                    if (e instanceof RuntimeException) {
                        BugReportExceptionHandler.handleException(e);
                    } else {
                        ExceptionDialogUtil.explainException(e);
                    }
                });
Last edited 5 years ago by Don-vip (previous) (diff)

by GerdP, 5 years ago

Attachment: 17525-reverter.patch added

possible solution for reverter

comment:2 by GerdP, 5 years ago

Sorry, I confused realRun() in reverter with doRealRun() in class PleaseWaitRunnable:

        } catch (final JosmRuntimeException | IllegalArgumentException | IllegalStateException | UnsupportedOperationException |
                OsmTransferException | IOException | SAXException | InvocationTargetException | InterruptedException e) {

So, we already have code to catch a lot of possible exceptions, but NullPointerException is not yet handled.
Not sure if it makes sense to catch all RunTimeExceptions or if NPE should be added to the above list?

comment:3 by GerdP, 5 years ago

Owner: set to team

comment:4 by GerdP, 5 years ago

Cc: Don-vip added

Regression of r11746?

comment:5 by Don-vip, 5 years ago

likely. Maybe this commit wasn't a good idea after all. I'm OK to catch RuntimeException. Maybe PMD config must be tuned.

comment:6 by GerdP, 5 years ago

Resolution: fixed
Status: newclosed

In 14936/josm:

fix #17525: catch all RunTimeExceptions in PleaseWaitRunnable.doRealRun()

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.