[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
1 changed files with 5 additions and 3 deletions

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() {