Project: datamanagement
Issue DM-5854: Java array index out of bound error in VisSeverCommand.java
The class FileFluxCmdJson in VisServerCommand.java is calling {code} String[] res = VisServerOps.getFileFlux(fahAry, pt); {code} However, when the mouse is outside the image, the VisServerOps.getFileFlux(fahAry, pt) returns: {code} new String[]{PlotState.NO_CONTEXT} {code} It is fine for a single band. However, for 2 or 3 bands, the for loop below caused the index out of bound error because res is an array of length=1 and the expected res is an array of length=no of bands. {code} JSONObject obj= new JSONObject(); obj.put("JSON", true); obj.put("success", true); int cnt=0; JSONObject data= new JSONObject(); for(Band b : state.getBands()) { data.put(b.toString(), res[cnt++]); } data.put("success", true); {code} Thus, res\[cnt++\] caused array index out of bound error. To fix this issue, the for loop is changed as below: {code} int cnt=0; JSONObject data= new JSONObject(); Band[] bands = state.getBands(); for (int i=0; i
Story points: 1