Mercurial > dive4elements > river
changeset 4045:de6e2b933f33
Fix for ArrayIndexOutOfBoundsException (#818).
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Sat, 06 Oct 2012 00:25:28 +0200 |
parents | 7eebd9e58641 |
children | ca208b2f35a0 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java |
diffstat | 2 files changed, 19 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Oct 05 23:21:18 2012 +0200 +++ b/flys-artifacts/ChangeLog Sat Oct 06 00:25:28 2012 +0200 @@ -1,3 +1,8 @@ +2012-10-06 Christian Lins <christian.lins@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java: + Fix for ArrayIndexOutOfBoundsException (#818). + 2012-10-05 Christian Lins <christian.lins@intevation.de> * src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java Fri Oct 05 23:21:18 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java Sat Oct 06 00:25:28 2012 +0200 @@ -1,14 +1,11 @@ package de.intevation.flys.artifacts.model; import de.intevation.artifactdatabase.state.Facet; - import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; - import de.intevation.flys.artifacts.FLYSArtifact; - +import de.intevation.flys.artifacts.math.Linear; import de.intevation.flys.artifacts.states.DefaultState.ComputeType; -import de.intevation.flys.artifacts.math.Linear; import org.apache.log4j.Logger; @@ -45,6 +42,7 @@ * Get waterlevel data. * @return a WQKms at given index. */ + @Override public Object getData(Artifact artifact, CallContext context) { if (logger.isDebugEnabled()) { @@ -52,6 +50,11 @@ " /stateId: " + stateId); } + if (artifact == null) { + logger.error("WaterlevelFacet.getData: artifact is null"); + return null; + } + FLYSArtifact winfo = (FLYSArtifact) artifact; CalculationResult res = (CalculationResult) @@ -62,11 +65,6 @@ return null; } - if (winfo == null) { - logger.error("WaterlevelFacet.getData: artifact is null"); - return null; - } - WQKms [] wqkms = getWQKms(res); Object KM = context.getContextValue("currentKm"); if (KM != null) { @@ -92,18 +90,20 @@ idx--; } } + WQKms resultWQKms = new WQKms(); - if (idx != -1 && idx < size) { + if ((idx != -1) && (idx < size) && (idx - mod != -1) && (idx - mod < size)) { double inW = Linear.linear( km, - wqkmsI.getKm(idx), wqkmsI.getKm(idx-mod), - wqkmsI.getW(idx), wqkmsI.getW(idx-mod)); + wqkmsI.getKm(idx), wqkmsI.getKm(idx - mod), + wqkmsI.getW(idx), wqkmsI.getW(idx - mod)); double inQ = Linear.linear( km, - wqkmsI.getKm(idx), wqkmsI.getKm(idx-mod), - wqkmsI.getQ(idx), wqkmsI.getQ(idx-mod)); + wqkmsI.getKm(idx), wqkmsI.getKm(idx - mod), + wqkmsI.getQ(idx), wqkmsI.getQ(idx - mod)); resultWQKms.add(inW, inQ, km); } + return resultWQKms; }