Skip to content

Commit

Permalink
(2.6) dcache-core (statistics): fix yet another potential NPE in tree…
Browse files Browse the repository at this point in the history
… creation

If the user runs the admin command create html <yyyy> or create html <yyyy> <mm> and those directories do not exist, an NPE is thrown when the list of subfiles is sorted, since the list ends up being a NULL array.

It costs little to ensure the presence of those directories in each of the three methods, so dir.mkdirs() has been added there.

Testing:

Running commands in absence of the statistics directory tree now avoids the NPE and creates the necessary empty directories.

Target: 2.6
Patch: http://rb.dcache.org/r/6341/
Require-book: no
Require-notes: yes
Acked-by: Tigran
Committed: 0200256

RELEASE NOTES:

Fixes potential Null Pointer Exception thrown when create html <yyyy> or create html <yyyy> <mm> is run and those directories do not yet exist.
  • Loading branch information
alrossi committed Dec 12, 2013
1 parent 9f86596 commit f82ad29
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -459,7 +459,7 @@ public void run( CellCron.TimerTask task ){
}
private void updateHtmlMonth( Calendar calendar ) throws IOException {
File dir = getHtmlPath(calendar).getParentFile() ;

dir.mkdirs();
File [] list = dir.listFiles( new MonthFileFilter() ) ;

list = resortFileList( list , -1 ) ;
Expand Down Expand Up @@ -525,6 +525,7 @@ private void updateHtmlMonth( Calendar calendar ) throws IOException {
}
private void updateHtmlYear( Calendar calendar ) throws IOException {
File dir = getHtmlPath(calendar).getParentFile().getParentFile() ;
dir.mkdirs();
File [] list = dir.listFiles( new MonthFileFilter() ) ;

list = resortFileList( list , -1 ) ;
Expand Down Expand Up @@ -588,6 +589,7 @@ private void updateHtmlYear( Calendar calendar ) throws IOException {
}
private void updateHtmlTop( ) throws IOException {
File dir = _htmlBase ;
dir.mkdirs();
File [] list = dir.listFiles( new YearFileFilter() ) ;

list = resortFileList( list , -1 ) ;
Expand Down

0 comments on commit f82ad29

Please sign in to comment.