Skip to content

Commit

Permalink
ARTEMIS-2410 max-saved-replicated-journals-size=0 throws ArrayIndexOu…
Browse files Browse the repository at this point in the history
…tOfBoundsException
  • Loading branch information
shailendra14k authored and clebertsuconic committed Aug 1, 2019
1 parent fb7de13 commit 51fdcca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ public void doMove() throws IOException {
return;
}

// Since we will create one folder, we are already taking that one into consideration
internalCheckOldFolders(1);

int whereToMove = getMaxID() + 1;

if (maxFolders == 0) {
internalCheckOldFolders(0);
ActiveMQServerLogger.LOGGER.backupDeletingData(folder.getPath());
for (String fileMove : files) {
File fileFrom = new File(folder, fileMove);
logger.tracef("deleting %s", fileFrom);
deleteTree(fileFrom);
}
} else {
// Since we will create one folder, we are already taking that one into consideration
internalCheckOldFolders(1);
File folderTo = getFolder(whereToMove);
folderTo.mkdirs();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,17 +272,21 @@ public void testMaxZero() throws Exception {
File folderF = new File(dataLocation, "folder" + f);
folderF.mkdirs();

File replicaFolder = new File(dataLocation, FileMoveManager.PREFIX + f);
replicaFolder.mkdir();

// FILES_PER_FOLDER + f, I'm just creating more files as f grows.
// this is just to make each folder unique somehow
for (int i = 0; i < FILES_PER_FOLDER + f; i++) {
createFile(folderF, i);
createFile(replicaFolder, i);
}
}

manager.doMove();

// We will always have maximum of 3 folders
Assert.assertEquals(0, manager.getNumberOfFolders());
Assert.assertEquals(0, manager.getFiles().length);
}

Assert.assertEquals(0, manager.getMaxID());
Expand Down

0 comments on commit 51fdcca

Please sign in to comment.