From 0900e997608a89f3e5937aab0e3f831dc7d8ed35 Mon Sep 17 00:00:00 2001 From: Jacobus Martinus Kruithof Date: Wed, 29 Jun 2005 16:29:20 +0000 Subject: [PATCH] PR: 35544 Avoid getting NPE on calling close() twice. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278444 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 3 +++ .../org/apache/tools/ant/util/ReaderInputStream.java | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 0d8098046..6a4f0e9de 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -60,6 +60,9 @@ Changes that could break older environments: Fixed bugs: ----------- +* Calling close twice on ReaderInputStream gave a nullpointer exception. + Bugzilla Report 35544. + * Memory leak from IntrospectionHelper.getHelper(Class) in embedded environments. Bugzilla Report 30162. diff --git a/src/main/org/apache/tools/ant/util/ReaderInputStream.java b/src/main/org/apache/tools/ant/util/ReaderInputStream.java index 8142bd595..04f3df7b5 100755 --- a/src/main/org/apache/tools/ant/util/ReaderInputStream.java +++ b/src/main/org/apache/tools/ant/util/ReaderInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright 2004 The Apache Software Foundation. + * Copyright 2004-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -196,8 +196,10 @@ public class ReaderInputStream extends InputStream { * @exception IOException if the original StringReader fails to be closed */ public synchronized void close() throws IOException { - in.close(); - slack = null; - in = null; + if (in != null) { + in.close(); + slack = null; + in = null; + } } }