Bug 1966176 - Java Desktop API open(File) hangs until the Java process is closed
Summary: Java Desktop API open(File) hangs until the Java process is closed
Keywords:
Status: CLOSED DUPLICATE of bug 1961119
Alias: None
Product: Fedora
Classification: Fedora
Component: java-11-openjdk
Version: 34
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: jiri vanek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-05-31 15:43 UTC by Robert Marcano
Modified: 2021-05-31 15:52 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2021-05-31 15:52:13 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Robert Marcano 2021-05-31 15:43:12 UTC
Description of problem:

The Java java.awt.Desktop#open(File) hangs without opening the supplied file, it finally opens only when the Java process exits


Version-Release number of selected component (if applicable):

java-11-openjdk-11.0.11.0.9-2.fc34.x86_64

and

java-1.8.0-openjdk-1.8.0.292.b10-3.fc34.x86_64

gtk2-2.24.33-4.fc34.x86_64
gtk3-3.24.29-1.fc34.x86_64

Tested with both GTK using the Java System property jdk.gtk.version=2 and jdk.gtk.version=3

How reproducible:

Always


Steps to Reproduce:
1. Compile this test class

import java.awt.Desktop;
import java.io.File;

public abstract class TestOpen {
    public static void main(String[] args) throws Exception {
        if (args.length != 1) {
            System.err.println("File argument required");
        }

        Desktop.getDesktop().open(new File(args[0]));
        Thread.sleep(60000);
    }
}

2. Run the test class with a file path argument, for example a PDF 
3. Wait for the PDF to open in the default associated application only after the 60 seconds timeout ends. 

Actual results:

The file is opened after the 60 seconds timeout ends, that is when the Java process exits.

Expected results:

The file should open as fast as possible, while the Java process is still running. 


Additional info:

The action of opening the associated application is delegated to GTK by Java native code like:

    gtk->gdk_threads_enter();
    success = gtk->gtk_show_uri(NULL, url_c, GDK_CURRENT_TIME, NULL);
    gtk->gdk_threads_leave();
 
It could be a threading issue or a bug in GTK

Comment 1 Severin Gehwolf 2021-05-31 15:52:13 UTC

*** This bug has been marked as a duplicate of bug 1961119 ***


Note You need to log in before you can comment on or make changes to this bug.