RFR: 8328953 : JEditorPane.read throws ChangedCharSetException

rjolly duke at openjdk.org
Tue Mar 26 11:29:36 UTC 2024


On Thu, 25 Jan 2024 11:11:47 GMT, rjolly <duke at openjdk.org> wrote:

> ChangedCharSetException is used to amend the charset during read according to html directives. Currently it causes immediate exit of the method which in turn causes failure to load html documents with charset directives (even if the latter must not change after all). This PR restores the catch operation as it was before the use of try with resources.

Up

js>JEditorPane=javax.swing.JEditorPane
class javax.swing.JEditorPane
js>e=new JEditorPane()
javax.swing.JEditorPane[,0,0,0x0,invalid,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.basic.BasicBorders$MarginBorder at 4ac7e601,flags=296,maximumSize=,minimumSize=,preferredSize=,caretColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=javax.swing.plaf.InsetsUIResource[top=3,left=3,bottom=3,right=3],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],kit=javax.swing.JEditorPane$PlainEditorKit at 66bddb1f,typeHandlers=]
js>e.setContentType("text/html")
js>kit=e.getEditorKit()
javax.swing.text.html.HTMLEditorKit at 3602e8c4
js>doc=kit.createDefaultDocument()
javax.swing.text.html.HTMLDocument at 3367e16c
js>e.setDocument(doc)
js>URL=java.net.URL
class java.net.URL
js>u=new URL("https://www.google.com/")
https://www.google.com/
js>is=u.openStream()
sun.net.www.protocol.http.HttpURLConnection$HttpInputStream at 754c74c6
js>e.read(is, doc)
org.mozilla.javascript.WrappedException: Wrapped javax.swing.text.ChangedCharSetException (<Unknown source>#1) in <Unknown source> at line number 1

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17567#issuecomment-1959435606
PR Comment: https://git.openjdk.org/jdk/pull/17567#issuecomment-1992583067


More information about the client-libs-dev mailing list