diff --git a/src/java.base/share/classes/sun/nio/cs/StreamDecoder.java b/src/java.base/share/classes/sun/nio/cs/StreamDecoder.java index f172683d1de..340349a40fe 100644 --- a/src/java.base/share/classes/sun/nio/cs/StreamDecoder.java +++ b/src/java.base/share/classes/sun/nio/cs/StreamDecoder.java @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -71,14 +71,10 @@ public class StreamDecoder extends Reader { String charsetName) throws UnsupportedEncodingException { - String csn = charsetName; - if (csn == null) { - csn = Charset.defaultCharset().name(); - } try { - return new StreamDecoder(in, lock, Charset.forName(csn)); + return new StreamDecoder(in, lock, Charset.forName(charsetName)); } catch (IllegalCharsetNameException | UnsupportedCharsetException x) { - throw new UnsupportedEncodingException (csn); + throw new UnsupportedEncodingException (charsetName); } } diff --git a/src/java.base/share/classes/sun/nio/cs/StreamEncoder.java b/src/java.base/share/classes/sun/nio/cs/StreamEncoder.java index 5a81e697970..456d89b32e3 100644 --- a/src/java.base/share/classes/sun/nio/cs/StreamEncoder.java +++ b/src/java.base/share/classes/sun/nio/cs/StreamEncoder.java @@ -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. * * 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) throws UnsupportedEncodingException { - String csn = charsetName; - if (csn == null) { - csn = Charset.defaultCharset().name(); - } try { - return new StreamEncoder(out, lock, Charset.forName(csn)); + return new StreamEncoder(out, lock, Charset.forName(charsetName)); } catch (IllegalCharsetNameException | UnsupportedCharsetException x) { - throw new UnsupportedEncodingException (csn); + throw new UnsupportedEncodingException (charsetName); } }