Skip to content

Commit fdcc3a7

Browse files
update code.
1 parent 107ad01 commit fdcc3a7

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

core-web/src/org/apache/struts2/views/jasperreports/JasperReportsResult.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*
2-
* $Id$
3-
*
42
* Licensed to the Apache Software Foundation (ASF) under one
53
* or more contributor license agreements. See the NOTICE file
64
* distributed with this work for additional information
@@ -18,7 +16,6 @@
1816
* specific language governing permissions and limitations
1917
* under the License.
2018
*/
21-
2219
package org.apache.struts2.views.jasperreports;
2320

2421
import com.netsteadfast.greenstep.base.Constants;
@@ -289,7 +286,7 @@ protected void doExecute(String finalLocation, ActionInvocation invocation) thro
289286
// TODO 更改 systemId 的位址
290287
if (Constants.JASPER_REPORTS_RESULT_LOCATION_REPLACE_MODE) {
291288
systemId = finalLocation;
292-
}
289+
}
293290

294291
Map parameters = new ValueStackShadowMap(stack);
295292
File directory = new File(systemId.substring(0, systemId.lastIndexOf(File.separator)));
@@ -361,7 +358,7 @@ protected void doExecute(String finalLocation, ActionInvocation invocation) thro
361358

362359
Map imagesMap = new HashMap();
363360
request.getSession(true).setAttribute("IMAGES_MAP", imagesMap);
364-
361+
365362
// TODO : 改為jasperreport-6.5.1 版本使用的HtmlExporter , 原本: exporter = new JRHtmlExporter();
366363
exporter = new HtmlExporter();
367364
exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
@@ -395,7 +392,10 @@ protected void doExecute(String finalLocation, ActionInvocation invocation) thro
395392
throw new ServletException(e.getMessage(), e);
396393
} finally {
397394
try {
398-
conn.close();
395+
if (conn != null) {
396+
// avoid NPE if connection was not used for the report
397+
conn.close();
398+
}
399399
} catch (Exception e) {
400400
LOG.warn("Could not close db connection properly", e);
401401
}

0 commit comments

Comments
 (0)