Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit d3cbec1

Browse files
author
Adam Lindenthal
committed
JERSEY-2604 MVC AbstractTemplateProcessor leaks file handles
Change-Id: Iacda483e763276ba40a6a28a8d2b9d7e3e469458
1 parent 3f3719a commit d3cbec1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

ext/mvc/src/main/java/org/glassfish/jersey/server/mvc/spi/AbstractTemplateProcessor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
import java.io.FileInputStream;
4444
import java.io.FileNotFoundException;
45+
import java.io.IOException;
4546
import java.io.InputStream;
4647
import java.io.InputStreamReader;
4748
import java.io.Reader;
@@ -219,6 +220,12 @@ private T resolve(final String name) {
219220
return resolve(template, reader);
220221
} catch (final Exception e) {
221222
LOGGER.log(Level.WARNING, LocalizationMessages.TEMPLATE_RESOLVE_ERROR(template), e);
223+
} finally {
224+
try {
225+
reader.close();
226+
} catch (final IOException e) {
227+
LOGGER.log(Level.WARNING, LocalizationMessages.TEMPLATE_ERROR_CLOSING_READER(), e);
228+
}
222229
}
223230
}
224231
}

ext/mvc/src/main/resources/org/glassfish/jersey/server/mvc/internal/localization.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
#
4-
# Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
4+
# Copyright (c) 2013-2014 Oracle and/or its affiliates. All rights reserved.
55
#
66
# The contents of this file are subject to the terms of either the GNU
77
# General Public License Version 2 only ("GPL") or the Common Development
@@ -47,4 +47,6 @@ template.names.could.not.be.resolved=Neither of the template names ({0}) could b
4747
template.no.matching.resource.available=There is no last matching resource available.
4848
template.resolve.error=An exception occurred during resolving the {0} template.
4949
template.resolving.class.cannot.be.null=Resolving class MUST not be null.
50+
template.error.closing.reader=File reader was not closed properly.
5051
wrong.template.object.factory=Provided template object factory class, {0}, is not assignable from required type {1}.
52+

0 commit comments

Comments
 (0)