1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-23 11:07:57 +01:00

[core] Fix potential NPE in Java7ZlibInputOutputStream

The field XMPPInputOutputStream.flushMethod was not initialized, which
could cause an NPE in the "switch (flushMethod)" found in
Java7ZlibInputOutputStream.getOutputStream().
This commit is contained in:
Florian Schmaus 2020-05-21 12:47:55 +02:00
parent cbcf1d15f5
commit 33720e8d97

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2013-2018 Florian Schmaus
* Copyright 2013-2020 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,9 +20,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.jivesoftware.smack.util.Objects;
public abstract class XMPPInputOutputStream {
protected static FlushMethod flushMethod;
protected static FlushMethod flushMethod = FlushMethod.SYNC_FLUSH;
/**
* Set the used flushed method when compressing data. The default is full flush which may not
@ -33,7 +35,7 @@ public abstract class XMPPInputOutputStream {
* @param flushMethod TODO javadoc me please
*/
public static void setFlushMethod(FlushMethod flushMethod) {
XMPPInputOutputStream.flushMethod = flushMethod;
XMPPInputOutputStream.flushMethod = Objects.requireNonNull(flushMethod);
}
public static FlushMethod getFlushMethod() {