@@ -238,30 +238,32 @@ public void removeAttachedFile(String aFilename) {
238238 public String getFileSize (String aFilename ) {
239239 if (getWorkitem () != null ) {
240240 FileData fileData = getWorkitem ().getFileData (aFilename );
241- double bytes = fileData .getContent ().length ;
242- if (bytes == 0 ) {
243- // test if we have the attribute size
244- List <Object > sizeAttribute = (List <Object >) fileData .getAttribute ("size" );
245- if (sizeAttribute != null && sizeAttribute .size () > 0 ) {
246- try {
247- bytes = Double .parseDouble (sizeAttribute .get (0 ).toString ());
248- } catch (NumberFormatException n ) {
249- logger .log (Level .WARNING , "unable to parse size attribute in FileData for file ''{0}''" ,
250- aFilename );
241+ if (fileData != null ) {
242+ double bytes = fileData .getContent ().length ;
243+ if (bytes == 0 ) {
244+ // test if we have the attribute size
245+ List <Object > sizeAttribute = (List <Object >) fileData .getAttribute ("size" );
246+ if (sizeAttribute != null && sizeAttribute .size () > 0 ) {
247+ try {
248+ bytes = Double .parseDouble (sizeAttribute .get (0 ).toString ());
249+ } catch (NumberFormatException n ) {
250+ logger .log (Level .WARNING , "unable to parse size attribute in FileData for file ''{0}''" ,
251+ aFilename );
252+ }
251253 }
252254 }
253- }
254- if ( bytes >= 1000000000 ) {
255- bytes = (bytes / 1000000000 ) ;
256- return round (bytes ) + " GB" ;
257- } else if ( bytes >= 1000000 ) {
258- bytes = (bytes / 1000000 ) ;
259- return round (bytes ) + " MB" ;
260- } else if ( bytes >= 1000 ) {
261- bytes = (bytes / 1000 ) ;
262- return round ( bytes ) + " KB" ;
263- } else {
264- return round ( bytes ) + " bytes" ;
255+ if ( bytes >= 1000000000 ) {
256+ bytes = ( bytes / 1000000000 );
257+ return round (bytes ) + " GB" ;
258+ } else if (bytes >= 1000000 ) {
259+ bytes = ( bytes / 1000000 );
260+ return round (bytes ) + " MB" ;
261+ } else if (bytes >= 1000 ) {
262+ bytes = ( bytes / 1000 );
263+ return round (bytes ) + " KB" ;
264+ } else {
265+ return round ( bytes ) + " bytes" ;
266+ }
265267 }
266268 }
267269 return "" ;
0 commit comments