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) {
int n = 1;
String status = "INCORRECT: No IOexception thrown";
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 = "Exception: " + e;
} catch (UnavailableServiceException e) {
e.printStackTrace();
status = "Exception: " + e;
}
URL url = null;
// Start the test
try {
url = new URL(codebase, "Test3.txt");
service.create(url, 100l);
//try to create duplicate entry
n++;
service.create(url, 100l);
status = "INCORRECT (create call #2): Exception was not thrown";
} catch (MalformedURLException mue) {
status = "CORRECT (create call #" + n +
"): MalformedURLException was thrown: " + mue;
} catch (IOException ioe) {
status = "CORRECT (create call #" + n +
"): Exception was thrown: " + ioe;
}
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;
}
}
======================================================================
- duplicates
-
JDK-4414217 PersistenceService.create() doesn't throw IOException for dup. entry
- Closed