Menu

#322 OJ stops without warnings on system shutdown

OJ_future
pending
ede
None
Windows
5
2020-11-23
2013-05-24
No

Tested with version 1.6.1 release on Windows.
If there are layers with unsaved edits in OpenJUMP and user ask computer to shut down, OpenJUMP is closed without any warnings and unsaved edits are lost. For comparison, Kosmo GIS 3.0 is keeping the computer in such a state that operating system sends a message that Kosmo prevents the shutdown and asks if user wants to cancel or do a forced shutdown.

Related

Bugs: #322

Discussion

  • Matthias Scholz

    Matthias Scholz - 2013-05-25

    Don't know how Windows is "killing" the Java VM during system shutdown. The only possibility to avoid lost of data is Runtime.addShutdownHook(). Here we can add a Thread, which ask's the user if there are unsaved layers. This Thread is startet if the Java VM is shutting down.

     
  • michael michaud

    michael michaud - 2020-08-31

    Implementing Runtime.addShutdownHook is not too complicated (some explanations here https://www.geeksforgeeks.org/jvm-shutdown-hook-java/). It is not an absolute guarantee as it depends how exactly the process is shutdown.
    Question is : what can we do during this hook (must not be too long as the system may shut the process down anyway after a timeout).
    I can see some options like
    - save modifications (layers having a datasource but unsaved modification)
    - save unsaved layers (layers without datasource)
    - save project
    Some could be checked by default.
    Any thought ?

     
  • ede

    ede - 2020-08-31
    • status: open --> pending
    • assigned_to: ede
    • Operating System: --> Windows
    • Milestone: --> OJ_1.16
     
    • ede

      ede - 2020-08-31

      On 8/31/2020 14:26, ede wrote:

      tl;dr Runtime.addShutdownHook() should run com.vividsolutions.jump.workbench.ui.WorkbenchFrame.closeApplication() done.

      implemented for testing in r6400

      well. according to my tests that does a lot of nothing.in the best case

      1.
      run with 'java' so you have a console you can Ctrl+C in
      gui is killed and java process hangs, probably in the "wanna save?" dialog.

      2.
      any other case
      java killed, dead!

      tested on Win10x64 with adoptopenjdk-1.8.0_265 64bit

      ..ede

       
  • ede

    ede - 2020-08-31

    applications i work with do not save anything without being explicitly told so. even on windows shutdown. the application simply don't exit and i'll have to force shutdown and go back save my work or at least deal with the dialog that popped up. usually the same as closing the application with unsaved changes.

    tl;dr Runtime.addShutdownHook() should run com.vividsolutions.jump.workbench.ui.WorkbenchFrame.closeApplication() done.

    implemented for testing in r6400

     
  • michael michaud

    michael michaud - 2020-08-31

    I could not see much effect either (same environment as yours).
    Seems that the saving dialog appears a fraction of second, but the task killer is not one to be very patient.
    Also I dicovered that tasks in the taskmanager can show their subprocesses : killing OpenJDK kill the whole process, but shuting OpenJUMP down open the save dialog (it already did it in the previous versions).

     
  • ede

    ede - 2020-08-31

    so it shall be done in OJ 2.x .. ede

    On 31.08.2020 20:03, Giuseppe Aruta wrote:

    I18N.getInstance("my.great.extension").get(String)

    seems more logical and easy to use

    Il lun 31 ago 2020, 18:58 ede via Jump-pilot-devel jump-pilot-devel@lists.sourceforge.net ha scritto:

    On 8/31/2020 18:19, michael michaud wrote:

    String getText(Syting label)
    String getText(Syting label, Object...objects)
    static String get(Syting label) // legacy
    static String getMessage(Syting label)
    static String getMessage(Syting label, Object...objects)

    must remove :
    static getText(String,String)
    could remove
    static getMessage(File,String,Object...objects)

    don't like getText() vs getMessage(). i suppose that is going to confuse
    developers, because actually there is no difference between text and
    Message here.

    we have the rare chance of breaking backward compatibility with OJ2 let's
    take advantage of it as we will have to touch every extension anyway!

    let me propose something logically more sound, even if it'll be a little
    bit more work for us

    static (we could hide these, but i don't see why. when first argument is
    null the default resourcebundles are used)
    get(File,String,Object...objects)
    get(String,String,Object...objects)

    instance
    get(String,Object...objects) //this notation includes get(String) without
    objects as well

    this'll allow for OJ Core
    I18N.getInstance().get(String)

    for instances
    I18N.getInstance("my.great.extension").get(String)
    or
    I18N i18n = I18N.getInstance("my.great.extension");
    i18n.get(String)
    i18n.get(String, Object, Object)
    i18n.get(String, new Object[]{ o1, o2, o3})


    Status: open
    Milestone: undecided
    Created: Mon Aug 31, 2020 10:32 AM UTC by michael michaud
    Last Updated: Mon Aug 31, 2020 04:19 PM UTC
    Owner: nobody

    Ede, I prefer to document the usage of I18N in Extension in a separate
    ticket.
    Here are two reasons which drove me to use a hack instead of the I18N
    class (indeed there is a third : I have been too lazy to try to fix the two
    former reasons) :
    - using categoryPrefixOrPath with properties files in the classpath means
    files are in a subdirectory named language/jump (generally possible, but no
    much reason to be constrained like that);
    - the only public method you can use to get a key in this case is
    getText(final String categoryPrefix, final String key). Currently,
    getMessage(final Object categoryPrefixOrPathOrI18n,
    final String label, final Object... objects) is private. Not sure if we
    must make it public or if we must use I18N instances in extensions instead
    of static methods. A class instance could avoid repeating the
    categoryPrefixOrPathOrI18n parameter again and again).
    - indeed, we can create an instance of I18 for a particular extension, but
    we cannot really use it as most methods are static. For example, if I
    create an instance for myExtension, calling getMessage(final String label,
    final Object... objects) will not search keys in myExtension but in main
    openjump properties file


    Sent from sourceforge.net because jump-pilot-devel@lists.sourceforge.net
    is subscribed to https://sourceforge.net/p/jump-pilot/bugs/

    To unsubscribe from further messages, a project admin can change settings
    at https://sourceforge.net/p/jump-pilot/admin/bugs/options. Or, if this
    is a mailing list, you can unsubscribe from the mailing list.


    Jump-pilot-devel mailing list
    Jump-pilot-devel@lists.sourceforge.net
    https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


    Jump-pilot-devel mailing list
    Jump-pilot-devel@lists.sourceforge.net
    https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

     

    Related

    Bugs: #501

  • ede

    ede - 2020-11-23
    • Milestone: OJ_1.16 --> OJ_future
     
  • ede

    ede - 2020-11-23

    if JVM retrieves a shutdown signal there is little we can do. tried to add shutdown hooks and such, but JVM ends uncancellable. no way to show a save me dialog .

    if we could find a way to catch the Ctrl+C ("kill") signal before it reaches the jvm? will tag it as oj_future for now

     

Log in to post a comment.