Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2169

PDC.java can NPE when calling deleteFile

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.0.3
    • 4.0.1
    • None

      As seen in my logs:

      [thread=jgroups-4,pv36d01ls-geo02042101-26405] [level=ERROR] [logger=unknown.jul.logger] - JGRP000027: failed passing message up
      java.lang.NullPointerException: null
              at org.jgroups.protocols.PDC.deleteFile(PDC.java:271) ~[org.jgroups-jgroups-4.0.1.Final.jar:4.0.1.Final]
              at org.jgroups.protocols.PDC.writeNodeToDisk(PDC.java:208) ~[org.jgroups-jgroups-4.0.1.Final.jar:4.0.1.Final]
              at org.jgroups.protocols.PDC.down(PDC.java:89) ~[org.jgroups-jgroups-4.0.1.Final.jar:4.0.1.Final]
      

      It seems that there are code paths where deleteFile can be called with a null parameter. For example:

          protected File writeToTempFile(File dir, Address logical_addr, Address physical_addr, String logical_name) throws Exception {
              DataOutputStream out=null;
              File file=null;
              String filename=null;
              try {
                  file=File.createTempFile("temp", null, dir);
      ^^ If this fails, then file is null and delete is called with null
                  filename=file.getName();
      ...
              }
              catch(Exception e) {
                  Util.close(out);
                  log.error(Util.getMessage("FailedToWriteTemporaryFile") + filename, e);
                  deleteFile(file);
                  return null;
              }
      
      

              rhn-engineering-bban Bela Ban
              genman_jira Elias Ross (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: