NASAWorldWind / WorldWindJava

The NASA WorldWind Java SDK (WWJ) is for building cross-platform 3D geospatial desktop applications in Java.
712 stars 324 forks source link

Made StatusBar swing timer stoppable #234

Open paper-tiger opened 2 years ago

paper-tiger commented 2 years ago

Description of the Change

In the class gov.nasa.worldwind.util.StatusBar a SwingTimer is created as a local variable in the constructor. This way the timer can never be stopped.

Why Should This Be In Core?

Every Application which does not rely on System.exit() for its shutdown could have a problem with the timer mentioned above as the AWT Thread won't stop. Usage of System.exit() can be a problem if there are automated system tests executed by tools like the maven-failsafe-plugin, which does not allow for such calls.

Benefits

The timer can be stopped and applications can do a graceful shutdown.

Potential Drawbacks

There is the risk that a programmer calls the stop method and wonders why the network status is not updated anymore. It could even be argued that the encapsulation is broken but by using global state like the swing timer facility there is no other practical way to clean this up the way it is currently designed.

Applicable Issues