Avoid possible NullPointerException

Resolves: rhbz#1993889
This commit is contained in:
Marian Koncek 2021-08-18 17:48:47 +02:00
parent 2a8f07bab4
commit 5f13dce508
2 changed files with 33 additions and 1 deletions

26
0001-Avoid-NPE.patch Normal file
View File

@ -0,0 +1,26 @@
From d94c5832e14504d44abeba47866dfa7dac5992b5 Mon Sep 17 00:00:00 2001
From: Guillaume Nodet <gnodet@gmail.com>
Date: Fri, 23 Jul 2021 09:22:19 +0200
Subject: [PATCH] Avoid possible NPE, fixes #214
---
src/main/java/org/fusesource/jansi/AnsiPrintStream.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/fusesource/jansi/AnsiPrintStream.java b/src/main/java/org/fusesource/jansi/AnsiPrintStream.java
index e153c43..df6e5a6 100644
--- a/src/main/java/org/fusesource/jansi/AnsiPrintStream.java
+++ b/src/main/java/org/fusesource/jansi/AnsiPrintStream.java
@@ -76,7 +76,11 @@ public void install() throws IOException {
}
public void uninstall() throws IOException {
- getOut().uninstall();
+ // If the system output stream has been closed, out should be null, so avoid a NPE
+ AnsiOutputStream out = getOut();
+ if (out != null) {
+ out.uninstall();
+ }
}
@Override

View File

@ -2,7 +2,7 @@
Name: jansi Name: jansi
Version: 2.3.3 Version: 2.3.3
Release: 3%{?dist} Release: 4%{?dist}
Summary: Generate and interpret ANSI escape sequences in Java Summary: Generate and interpret ANSI escape sequences in Java
License: ASL 2.0 License: ASL 2.0
URL: http://fusesource.github.io/jansi/ URL: http://fusesource.github.io/jansi/
@ -15,6 +15,8 @@ Source1: generate-tarball.sh
# Change the location of the native artifact to where Fedora wants it # Change the location of the native artifact to where Fedora wants it
Patch0: %{name}-jni.patch Patch0: %{name}-jni.patch
Patch1: 0001-Avoid-NPE.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: maven-local BuildRequires: maven-local
%if %{with bootstrap} %if %{with bootstrap}
@ -101,6 +103,10 @@ cp -p src/main/native/libjansi.so %{buildroot}%{_libdir}/%{name}
%license license.txt %license license.txt
%changelog %changelog
* Wed Aug 18 2021 Marian Koncek <mkoncek@redhat.com> - 2.3.3-4
- Avoid possible NullPointerException
- Resolves: rhbz#1993889
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 2.3.3-3 * Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 2.3.3-3
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags - Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688 Related: rhbz#1991688