8305902: (cs) Resolve default Charset only once in StreamEncoder and StreamDecoder
Reviewed-by: alanb, bpb
This commit is contained in:
parent
8a1639d49b
commit
287bb06def
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -71,14 +71,10 @@ public class StreamDecoder extends Reader {
|
|||||||
String charsetName)
|
String charsetName)
|
||||||
throws UnsupportedEncodingException
|
throws UnsupportedEncodingException
|
||||||
{
|
{
|
||||||
String csn = charsetName;
|
|
||||||
if (csn == null) {
|
|
||||||
csn = Charset.defaultCharset().name();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
return new StreamDecoder(in, lock, Charset.forName(csn));
|
return new StreamDecoder(in, lock, Charset.forName(charsetName));
|
||||||
} catch (IllegalCharsetNameException | UnsupportedCharsetException x) {
|
} catch (IllegalCharsetNameException | UnsupportedCharsetException x) {
|
||||||
throw new UnsupportedEncodingException (csn);
|
throw new UnsupportedEncodingException (charsetName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -58,14 +58,10 @@ public final class StreamEncoder extends Writer {
|
|||||||
String charsetName)
|
String charsetName)
|
||||||
throws UnsupportedEncodingException
|
throws UnsupportedEncodingException
|
||||||
{
|
{
|
||||||
String csn = charsetName;
|
|
||||||
if (csn == null) {
|
|
||||||
csn = Charset.defaultCharset().name();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
return new StreamEncoder(out, lock, Charset.forName(csn));
|
return new StreamEncoder(out, lock, Charset.forName(charsetName));
|
||||||
} catch (IllegalCharsetNameException | UnsupportedCharsetException x) {
|
} catch (IllegalCharsetNameException | UnsupportedCharsetException x) {
|
||||||
throw new UnsupportedEncodingException (csn);
|
throw new UnsupportedEncodingException (charsetName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user