From commits-return-19476-archive-asf-public=cust-asf.ponee.io@struts.apache.org Sun Jan 3 09:15:21 2021 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mxout1-ec2-va.apache.org (mxout1-ec2-va.apache.org [3.227.148.255]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id 47C7F18066D for ; Sun, 3 Jan 2021 10:15:21 +0100 (CET) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-ec2-va.apache.org (ASF Mail Server at mxout1-ec2-va.apache.org) with SMTP id 6B86D45600 for ; Sun, 3 Jan 2021 09:15:20 +0000 (UTC) Received: (qmail 22701 invoked by uid 500); 3 Jan 2021 09:15:20 -0000 Mailing-List: contact commits-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list commits@struts.apache.org Received: (qmail 22680 invoked by uid 99); 3 Jan 2021 09:15:19 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Jan 2021 09:15:19 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id B203781F5B; Sun, 3 Jan 2021 09:15:19 +0000 (UTC) Date: Sun, 03 Jan 2021 09:15:20 +0000 To: "commits@struts.apache.org" Subject: [struts] 01/01: WW-5099 Upgrades JFreeChart to version 1.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: lukaszlenart@apache.org In-Reply-To: <160966531958.18380.11460378682100601597@gitbox.apache.org> References: <160966531958.18380.11460378682100601597@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: struts X-Git-Refname: refs/heads/WW-5099-upgrade-jfreechart X-Git-Reftype: branch X-Git-Rev: 22ee49151b68b201e67f0ea7192251b43fc18089 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20210103091519.B203781F5B@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-5099-upgrade-jfreechart in repository https://gitbox.apache.org/repos/asf/struts.git commit 22ee49151b68b201e67f0ea7192251b43fc18089 Author: Lukasz Lenart AuthorDate: Sun Jan 3 10:15:09 2021 +0100 WW-5099 Upgrades JFreeChart to version 1.5.1 --- plugins/jfreechart/pom.xml | 4 ++-- .../org/apache/struts2/dispatcher/ChartResult.java | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/plugins/jfreechart/pom.xml b/plugins/jfreechart/pom.xml index f2d4d21..0ee1990 100644 --- a/plugins/jfreechart/pom.xml +++ b/plugins/jfreechart/pom.xml @@ -35,7 +35,7 @@ org.jfree jcommon - 1.0.23 + 1.0.24 provided @@ -47,7 +47,7 @@ org.jfree jfreechart - 1.0.19 + 1.5.1 provided diff --git a/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java b/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java index eabd988..c7c16a3 100644 --- a/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java +++ b/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java @@ -18,12 +18,13 @@ */ package org.apache.struts2.dispatcher; +import com.opensymphony.xwork2.config.ConfigurationException; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionInvocation; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; import org.apache.struts2.result.StrutsResultSupport; -import org.jfree.chart.ChartUtilities; +import org.jfree.chart.ChartUtils; import org.jfree.chart.JFreeChart; import java.io.OutputStream; @@ -105,14 +106,16 @@ public class ChartResult extends StrutsResultSupport { private final static Logger LOG = LogManager.getLogger(ChartResult.class); private static final long serialVersionUID = -6484761870055986612L; + private static final String DEFAULT_TYPE = "png"; private static final String DEFAULT_VALUE = "chart"; private JFreeChart chart; // the JFreeChart to render private boolean chartSet; - String height, width; - String type = DEFAULT_TYPE; // supported are jpg, jpeg or png, defaults to png - String value = DEFAULT_VALUE; // defaults to 'chart' + private String height; + private String width; + private String type = DEFAULT_TYPE; // supported are jpg, jpeg or png, defaults to png + private String value = DEFAULT_VALUE; // defaults to 'chart' // CONSTRUCTORS ---------------------------- @@ -200,11 +203,11 @@ public class ChartResult extends StrutsResultSupport { // check the type to see what kind of output we have to produce if ("png".equalsIgnoreCase(type)) { response.setContentType("image/png"); - ChartUtilities.writeChartAsPNG(os, chart, getIntValueFromString(width), getIntValueFromString(height)); + ChartUtils.writeChartAsPNG(os, chart, getIntValueFromString(width), getIntValueFromString(height)); } else if ("jpg".equalsIgnoreCase(type) || "jpeg".equalsIgnoreCase(type)) { response.setContentType("image/jpg"); - ChartUtilities.writeChartAsJPEG(os, chart, getIntValueFromString(width), getIntValueFromString(height)); + ChartUtils.writeChartAsJPEG(os, chart, getIntValueFromString(width), getIntValueFromString(height)); } else throw new IllegalArgumentException(type + " is not a supported render type (only JPG and PNG are)."); @@ -217,9 +220,8 @@ public class ChartResult extends StrutsResultSupport { * Sets up result properties, parsing etc. * * @param invocation Current invocation. - * @throws Exception on initialization error. */ - private void initializeProperties(ActionInvocation invocation) throws Exception { + private void initializeProperties(ActionInvocation invocation) { if (height != null) { height = conditionalParse(height, invocation); @@ -238,12 +240,12 @@ public class ChartResult extends StrutsResultSupport { } } - private Integer getIntValueFromString(String value) { + private int getIntValueFromString(String value) { try { return Integer.parseInt(value); } catch (Exception e) { LOG.error("Specified value for width or height is not of type Integer...", e); - return null; + throw new ConfigurationException("Wrong value \"" + value + "\", expected Integer!", e); } }