Bug im RMIR with filename without directory

Discussion forum for JP1 software tools currently in use, or being developed, such as IR, KM, RemoteMaster, and other misc apps/tools.

Moderator: Moderators

Post Reply
Barf
Expert
Posts: 1522
Joined: Fri Oct 24, 2008 1:54 pm
Location: Munich, Germany
Contact:

Bug im RMIR with filename without directory

Post by Barf »

If RMIR is started from the command line with an rmir file without directory as argument, the program will crash with a NPE:

Code: Select all

Caught exception in RemoteMaster.main()!
java.lang.NullPointerException: Cannot invoke "java.io.File.getAbsolutePath()" because "file" is null
        at com.hifiremote.jp1.PropertyFile.setProperty(PropertyFile.java:112)
        at com.hifiremote.jp1.RemoteMaster.openFile(RemoteMaster.java:4223)
        at com.hifiremote.jp1.RemoteMaster.openFile(RemoteMaster.java:4183)
        at com.hifiremote.jp1.RemoteMaster.createAndShowGUI(RemoteMaster.java:7778)
        at com.hifiremote.jp1.RemoteMaster.access$84(RemoteMaster.java:7607)
        at com.hifiremote.jp1.RemoteMaster$12.run(RemoteMaster.java:7863)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Turns out that the argument file is taken the parent director of (line 4222 in RemoteMaster.java) (is null if argument file has no director) then subsequencly getAbsolutePath() is applied on that null argument.

Possible fix

Code: Select all

Index: src/main/java/com/hifiremote/jp1/RemoteMaster.java
===================================================================
--- src/main/java/com/hifiremote/jp1/RemoteMaster.java  (revision 2041)
+++ src/main/java/com/hifiremote/jp1/RemoteMaster.java  (working copy)
@@ -7654,7 +7654,7 @@
         }
         else
         {
-          fileToOpen = new File( parm );
+          fileToOpen = new File( parm ).getCanonicalFile();
           if (hasEnding(parm, upgradeEndings, upgradeImportEndings )) 
           {
             if (launchRMIR) 
I'll be happy to check it in if desired.
mathdon
Expert
Posts: 4725
Joined: Tue Jul 22, 2008 8:53 am
Location: Cambridge, UK

Post by mathdon »

Barf wrote:If RMIR is started from the command line with an rmir file without directory as argument, the program will crash with a NPE: ... Possible fix ... I'll be happy to check it in if desired.
Yes please. I have other matters to deal with at present and so am unable to spend time on RMIR.
Graham
Post Reply