Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8152922

Applet RandomAccessFile named pipe open fails for java 8 where java 7 was OK

XMLWordPrintable

    • generic
    • windows_8

      FULL PRODUCT VERSION :
      32 bit jdk 1.8.0_45 and 1.8.0_60

      ADDITIONAL OS VERSION INFORMATION :
      Windows 8.1 Enterprise 64 bit running on an Oracle Virtual Box

      A DESCRIPTION OF THE PROBLEM :
      Created a C++ pipe sample, connecting to a java applet using RandomAccessFile. Works OK when tested using jdk 1.7.0_65, Switch to using jdk 1.8.0_45 or 1.8.0_60 and it fails with 'All pipe instances are busy' or 'The system cannot find the file specified'

      REGRESSION. Last worked in version 7u80

      ADDITIONAL REGRESSION INFORMATION:
      jdk1.8.0_60

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Windows 8.1 Enterprise 64 bit running on an Oracle Virtual Box, Visual Studio 2012 Professional, Eclipse Luna 32 bit, 32 bit java 1.7.0_65 and 32 bit java 1.8.0_45 jdk's installed.

      Use Vis Studio to create a new C++ project configuration Win32, create a .cpp file and paste the following:

      // PipeSample.cpp : Defines the entry point for the console application.
      //
      #include "stdafx.h"
      #include <iostream>
      #include <fstream>
      #include <windows.h>
      using namespace std;
      #define DEFAULTTIMEOUT 120
      #define BUFSIZE 512
      int main(int argc, const char **argv)
      {
          wcout << "Creating an instance of a named pipe..." << endl;
          // Create a pipe to send data
                          HANDLE pipe = CreateNamedPipe( L"\\\\.\\pipe\\UC_MENU_PIPE", // name of the pipe
                                                                                      PIPE_ACCESS_DUPLEX,
                                                                                      PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
                                                                                      1, // only allow 1 instance of this pipe
                                                                                      BUFSIZE,
                                                                                      BUFSIZE,
                                                                                      DEFAULTTIMEOUT,
                                                                                      &sa // use default security attributes
                                              );
          if (pipe == NULL || pipe == INVALID_HANDLE_VALUE) {
              wcout << "Failed to create outbound pipe instance.";
              system("pause");
              return 1;
          }
          wcout << "Waiting for a client to connect to the pipe..." << endl;
          // This call blocks until a client process connects to the pipe
          BOOL result = ConnectNamedPipe(pipe, NULL);
          if (!result) {
              wcout << "Failed to make connection on named pipe." << endl;
              // look up error code here using GetLastError()
              CloseHandle(pipe); // close the pipe
              system("pause");
              return 1;
          }
          wcout << "Sending data to pipe..." << endl;
          // This call blocks until a client process reads all the data
          const wchar_t *data = L"*** Hello Pipe World ***";
          DWORD numBytesWritten = 0;
          result = WriteFile(
              pipe, // handle to our outbound pipe
              data, // data to send
              wcslen(data) * sizeof(wchar_t), // length of data to send (bytes)
              &numBytesWritten, // will store actual amount of data sent
              NULL // not using overlapped IO
          );
          if (result) {
              wcout << "Number of bytes sent: " << numBytesWritten << endl;
          } else {
              wcout << "Failed to send data." << endl;
                                              int pipe_err = GetLastError();
                                              wcout << "GetLastError(): " << pipe_err << endl;
          }
          // Close the pipe (automatically disconnects client too)
          CloseHandle(pipe);
          wcout << "Done." << endl;
          system("pause");
          return 0;
      }

      Save and build to ensure no errors.

      Create a new workbench in Java, set the Project properties to point Compiler and Build Path to jdk 8.45, add a new class called AppletTester and paste the following:

      import java.io.File;
      import java.io.RandomAccessFile;
      import javax.swing.JApplet;
      public final class AppletTester extends JApplet implements ISuperRequestFocus {
                          private static final long serialVersionUID = 1L;
                          {
                          try
                          {
                                              File pipe = new File("\\\\.\\pipe\\UC_MENU_PIPE");
                                              RandomAccessFile rafile = new RandomAccessFile(pipe,"rwd");
                                              rafile.close();
                          }
                          catch(Exception e)
                          {
                                              e.printStackTrace();
                                              System.out.println("exception in run " + e);
                          }
                          }

                          public void superRequestFocus()
                          {
                                              super.requestFocus();
                          }
      }
      interface ISuperRequestFocus
      {
                          public void superRequestFocus(); }

      Save and Clean to ensure no problems.

      Start the Vis Studio C++ pipe creator.

      Start the AppletTester – fails to connect. Terminate the Vis Studio C++ pipe creator.

      Change AppletTester Properties Compiler and Build Path to jdk 1.7.0_65, Clean.

      Start the Vis Studio C++ pipe creator.

      Start the AppletTester – connects OK.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Connects without errors to the named pipe
      ACTUAL -
      Fails to connect to the named pipe

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      fails with 'All pipe instances are busy' or 'The system cannot find the file specified'.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      As listed above in Steps to Reproduce.
      ---------- END SOURCE ----------

        1. AppletTester.java
          0.7 kB
          Pallavi Sonal
        2. ConsoleApplication1.cpp
          3 kB
          Pallavi Sonal

            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: