[jboss-jira] [JBoss JIRA] (JGRP-2169) PDC.java can NPE when calling deleteFile

Elias Ross (JIRA) issues at jboss.org
Fri May 5 14:28:00 EDT 2017


     [ https://issues.jboss.org/browse/JGRP-2169?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Elias Ross updated JGRP-2169:
-----------------------------
    Description: 
[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;
        }
}}

  was:
[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;
        }
}}



> PDC.java can NPE when calling deleteFile
> ----------------------------------------
>
>                 Key: JGRP-2169
>                 URL: https://issues.jboss.org/browse/JGRP-2169
>             Project: JGroups
>          Issue Type: Bug
>    Affects Versions: 4.0.1
>            Reporter: Elias Ross
>            Assignee: Bela Ban
>
> [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;
>         }
> }}



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list