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

PersistenceService.create() doesn't throw IOException for dup. entry

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • None
    • 1.0.1
    • deploy
    • sparc
    • solaris_2.6

    Description



      Name: aaR10142 Date: 02/12/2001



      The jnlp javadoc says:
      "
      public long create(java.net.URL url,
                         long maxsize)
                  throws java.net.MalformedURLException,
                         java.io.IOException
      ....

      Throws:
                java.io.IOException - if an I/O exception occurs,
                or the entry already exists.
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      "

      The create mathod does not throw IOException when application, call it to
      times with the same URL(try to create entry that already exists).

      See example

      ------------- test.jnlp ----------
      <?xml version="1.0" encoding="UTF-8"?>
      <jnlp spec="0.2+" version="1.0"
        codebase="http://falcon:12345">
        <information>
          <title>Test</title>
          <vendor>Sun Microsystems, Inc.</vendor>
          <homepage href="index.html"/>
          <description>Test</description>
        </information>
        <resources>
          <j2se version="1.3 1.2"/>
          <jar href="main.jar"/>
        </resources>
        <application-desc main-class="Main">
        </application-desc>

      </jnlp>

      --------------Main.java----------------
      import java.awt.Frame;
      import java.awt.Label;
      import java.io.*;
      import java.net.*;
      import javax.jnlp.*;

      public class Main {
          public static void main(String[] args) {

          String status = "OKAY";
          URL codebase = null;

          String name = "javax.jnlp.PersistenceService";
          PersistenceService service = null;
          try {
              service = (PersistenceService)ServiceManager.lookup(name);
              codebase = getBase();
          } catch (ClassCastException e) {
             e.printStackTrace();
              status = "Excpetion:" + e;
          } catch (UnavailableServiceException e) {
             e.printStackTrace();
              status = "Excpetion:" + e;
          }

          URL url = null;
                

          // Start the test
          try {
              url = new URL(codebase, "Test3.txt");
              service.create(url, 100l);
               //try to create duplicate entry
              service.create(url, 100l);
              status = "IOException was not thrown";
             
          } catch (MalformedURLException e) {
              e.printStackTrace();
              status = "Excpetion:" + e;
          } catch (IOException e) {

          }

               Frame f = new Frame("Test");
               f.add(new Label(status));
               f.setSize(300, 100);
               f.setVisible(true);
                        
          }


          static URL getBase() throws UnavailableServiceException{
              URL codebase;
              String name = "javax.jnlp.BasicService";
              BasicService service = (BasicService)ServiceManager.lookup(name);
              codebase = service.getCodeBase();
              return codebase;
          }

      }
      ------------------- OUTPUT ------------
      IOException was not thrown

      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              alisunw Ali Ali (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: