8265496: improve null check in DeflaterOutputStream/InflaterInputStream
Reviewed-by: lancea, naoto
This commit is contained in:
parent
1d37b9840a
commit
15d4787724
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2021, 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
|
||||||
@ -74,7 +74,7 @@ public class DeflaterInputStream extends FilterInputStream {
|
|||||||
* @throws NullPointerException if {@code in} is null
|
* @throws NullPointerException if {@code in} is null
|
||||||
*/
|
*/
|
||||||
public DeflaterInputStream(InputStream in) {
|
public DeflaterInputStream(InputStream in) {
|
||||||
this(in, new Deflater());
|
this(in, in != null ? new Deflater() : null);
|
||||||
usesDefaultDeflater = true;
|
usesDefaultDeflater = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2021, 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
|
||||||
@ -158,7 +158,7 @@ public class DeflaterOutputStream extends FilterOutputStream {
|
|||||||
* @since 1.7
|
* @since 1.7
|
||||||
*/
|
*/
|
||||||
public DeflaterOutputStream(OutputStream out, boolean syncFlush) {
|
public DeflaterOutputStream(OutputStream out, boolean syncFlush) {
|
||||||
this(out, new Deflater(), 512, syncFlush);
|
this(out, out != null ? new Deflater() : null, 512, syncFlush);
|
||||||
usesDefaultDeflater = true;
|
usesDefaultDeflater = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2021, 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
|
||||||
@ -74,7 +74,7 @@ public class GZIPInputStream extends InflaterInputStream {
|
|||||||
* @throws IllegalArgumentException if {@code size <= 0}
|
* @throws IllegalArgumentException if {@code size <= 0}
|
||||||
*/
|
*/
|
||||||
public GZIPInputStream(InputStream in, int size) throws IOException {
|
public GZIPInputStream(InputStream in, int size) throws IOException {
|
||||||
super(in, new Inflater(true), size);
|
super(in, in != null ? new Inflater(true) : null, size);
|
||||||
usesDefaultInflater = true;
|
usesDefaultInflater = true;
|
||||||
readHeader(in);
|
readHeader(in);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2021, 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
|
||||||
@ -90,7 +90,7 @@ public class GZIPOutputStream extends DeflaterOutputStream {
|
|||||||
public GZIPOutputStream(OutputStream out, int size, boolean syncFlush)
|
public GZIPOutputStream(OutputStream out, int size, boolean syncFlush)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true),
|
super(out, out != null ? new Deflater(Deflater.DEFAULT_COMPRESSION, true) : null,
|
||||||
size,
|
size,
|
||||||
syncFlush);
|
syncFlush);
|
||||||
usesDefaultDeflater = true;
|
usesDefaultDeflater = true;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2021, 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
|
||||||
@ -105,7 +105,7 @@ public class InflaterInputStream extends FilterInputStream {
|
|||||||
* @param in the input stream
|
* @param in the input stream
|
||||||
*/
|
*/
|
||||||
public InflaterInputStream(InputStream in) {
|
public InflaterInputStream(InputStream in) {
|
||||||
this(in, new Inflater());
|
this(in, in != null ? new Inflater() : null);
|
||||||
usesDefaultInflater = true;
|
usesDefaultInflater = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2021, 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
|
||||||
@ -74,7 +74,7 @@ public class InflaterOutputStream extends FilterOutputStream {
|
|||||||
* @throws NullPointerException if {@code out} is null
|
* @throws NullPointerException if {@code out} is null
|
||||||
*/
|
*/
|
||||||
public InflaterOutputStream(OutputStream out) {
|
public InflaterOutputStream(OutputStream out) {
|
||||||
this(out, new Inflater());
|
this(out, out != null ? new Inflater() : null);
|
||||||
usesDefaultInflater = true;
|
usesDefaultInflater = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2021, 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
|
||||||
@ -130,7 +130,7 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
|
|||||||
* @since 1.7
|
* @since 1.7
|
||||||
*/
|
*/
|
||||||
public ZipOutputStream(OutputStream out, Charset charset) {
|
public ZipOutputStream(OutputStream out, Charset charset) {
|
||||||
super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true));
|
super(out, out != null ? new Deflater(Deflater.DEFAULT_COMPRESSION, true) : null);
|
||||||
if (charset == null)
|
if (charset == null)
|
||||||
throw new NullPointerException("charset is null");
|
throw new NullPointerException("charset is null");
|
||||||
this.zc = ZipCoder.get(charset);
|
this.zc = ZipCoder.get(charset);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Red Hat Inc. All rights reserved.
|
* Copyright (c) 2020, 2021, Red Hat Inc. 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
|
||||||
|
Loading…
Reference in New Issue
Block a user