-
Bug
-
Resolution: Fixed
-
P4
-
8u66, 9
-
b124
-
x86
-
windows_8
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8332837 | 8u431 | Alexey Ivanov | P4 | Resolved | Fixed | b01 |
FULL PRODUCT VERSION :
java version "1.8.0_66"
A DESCRIPTION OF THE PROBLEM :
When JEdiotPane.setPage is used with a file-Url, a file lock persists.
The setPage function calls internal the function read(InputStream in, Document doc). The read function instantiates an InputStream - this inputstream will never be closed.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
File myFile = new File("ATextFile);
JEditorPane myEditorPane = new JEditorPane();
myEditorPane.setPage(myFile.toURI().toURL());
after this the ATextFile has a file lock until the java program has been closed.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After using setPage with a file-Url in my expection the file lock should be unlocked after reading the file.
ACTUAL -
The file lock persists, even when the file has been readen.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
File myFile = new File("ATextFile);
JEditorPane myEditorPane = new JEditorPane();
myEditorPane.setPage(myFile.toURI().toURL());
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The read-function in JEditorPane has private access. There is no way to to extend the JEditorPane.
-< create an own class copy and merge the code of the setPage- and read-function and use:
URL myUrl = p_TextFile.toURI().toURL();
URLConnection myURLConnection = o_Url.openConnection();
InputStream myInputStream = o_URLConnection.getInputStream();
String charset = (String) myEditorPanegetClientProperty("charset");
Reader r = (charset != null) ? new InputStreamReader(myInputStream, charset) :
new InputStreamReader(myInputStream);
myEditorPane.getEditorKit().read(r, myEditorPane.getDocument(), 0);
...
//after all close the myInputStream
myInputStream.close();
java version "1.8.0_66"
A DESCRIPTION OF THE PROBLEM :
When JEdiotPane.setPage is used with a file-Url, a file lock persists.
The setPage function calls internal the function read(InputStream in, Document doc). The read function instantiates an InputStream - this inputstream will never be closed.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
File myFile = new File("ATextFile);
JEditorPane myEditorPane = new JEditorPane();
myEditorPane.setPage(myFile.toURI().toURL());
after this the ATextFile has a file lock until the java program has been closed.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After using setPage with a file-Url in my expection the file lock should be unlocked after reading the file.
ACTUAL -
The file lock persists, even when the file has been readen.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
File myFile = new File("ATextFile);
JEditorPane myEditorPane = new JEditorPane();
myEditorPane.setPage(myFile.toURI().toURL());
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The read-function in JEditorPane has private access. There is no way to to extend the JEditorPane.
-< create an own class copy and merge the code of the setPage- and read-function and use:
URL myUrl = p_TextFile.toURI().toURL();
URLConnection myURLConnection = o_Url.openConnection();
InputStream myInputStream = o_URLConnection.getInputStream();
String charset = (String) myEditorPanegetClientProperty("charset");
Reader r = (charset != null) ? new InputStreamReader(myInputStream, charset) :
new InputStreamReader(myInputStream);
myEditorPane.getEditorKit().read(r, myEditorPane.getDocument(), 0);
...
//after all close the myInputStream
myInputStream.close();
- backported by
-
JDK-8332837 JEditorPane function setPage leaves a file lock
- Resolved
- relates to
-
JDK-8328953 JEditorPane.read throws ChangedCharSetException
- Resolved