Bug 1966176

Summary: Java Desktop API open(File) hangs until the Java process is closed
Product: [Fedora] Fedora Reporter: Robert Marcano <robert>
Component: java-11-openjdkAssignee: jiri vanek <jvanek>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 34CC: ahughes, ashundi, jerboaa, jvanek, mageia-java, sgehwolf
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-31 15:52:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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 ***