ac2cz / KlaTrack

G0KLA Satellite Tracker
8 stars 5 forks source link

Keps download logic has a bug #17

Open FastThenLeft opened 2 years ago

FastThenLeft commented 2 years ago

First, thanks for such a great app! I use it all the time. I've shown it to all my satellite friends and they now run it too!

Second, issue #14 and #15 are manifestations of the same bug which I also have and all my friends that use the app have too.

So, I started to debug it. I don't know Java, but I can do some debugging. Here's what I found. I'm using Ubuntu, so I'll show some linux commands.

It's an easily repeatable bug.

First, start out with a running KlaTrack. Then close the app and set the timestamp on nasabare.txt to more than 24 hours in the past: $ touch -d "1 day ago" nasabare.txt

Now run the app and you get: $ java -jar KlaTrack.jar Downloading new keps .. .. keps are current ... open output file ../home/david/KLATrack/nasabare.txt ... getting file .. SERIOUS ERROR - Uncaught and thrown from GUI java.lang.NullPointerException at java.base/sun.nio.ch.FileChannelImpl.transferFrom(FileChannelImpl.java:766) at com.g0kla.track.SatManager.fetchTLEFile(SatManager.java:188) at com.g0kla.track.SatManager.loadTLEFile(SatManager.java:125) at com.g0kla.track.SatManager.(SatManager.java:53) at com.g0kla.track.gui.MainWindow.(MainWindow.java:267) at com.g0kla.track.TrackMain$1.run(TrackMain.java:98) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740) 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)

The bug occurs in SatManager.java on line 188. The result is that it sets nasabare.txt to a zero-byte file which results in a display with no satellites being tracked when you run the app again.

I believe the bug is that when: fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); is run, rbc is null because of the path through the code which causes the "SERIOUS ERROR - Uncaught and thrown from GUI" error.

I'm hoping that gives you enough pointers that you may look at it and go, "oh yeah, I see what's going on." If not, I'll continue to look at it and see if I can figure out the logic.

Thanks!

ac2cz commented 2 years ago

Thanks for the bug report and the investigation. I'll try to fix this when I get a chance.

FastThenLeft commented 2 years ago

Chris- Hold off. I think I got it fixed. Give me another week to test and I'll send you a pull request! -David, N9KT

On Sat, Aug 20, 2022 at 11:31 AM Chris Thompson @.***> wrote:

Thanks for the bug report and the investigation. I'll try to fix this when I get a chance.

— Reply to this email directly, view it on GitHub https://github.com/ac2cz/KlaTrack/issues/17#issuecomment-1221335491, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB7K5RKHJJ2HK7HYFA2KUNTV2D26DANCNFSM56ZEX7DQ . You are receiving this because you authored the thread.Message ID: @.***>

ac2cz commented 2 years ago

I think I fixed this bug in similar code in FoxTelem. It is here starting line 489: https://github.com/ac2cz/FoxTelem/blob/master/src/common/SatelliteManager.java

I check that the file actually exists and that it can be parsed. But I don't know that this code can be dropped in as is.