Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,11 @@ private void invalidateLocationCache(final String path) {
Iterator<Entry<String, PathLocation>> it = entries.iterator();
while (it.hasNext()) {
Entry<String, PathLocation> entry = it.next();
String key = entry.getKey();
PathLocation loc = entry.getValue();
String src = loc.getSourcePath();
if (src != null) {
if (isParentEntry(src, path)) {
if (isParentEntry(key, path)) {
LOG.debug("Removing {}", src);
it.remove();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,4 +704,29 @@ public void testLocationCache() throws Exception {
mountTable.removeEntry("/testlocationcache");
mountTable.removeEntry("/anothertestlocationcache");
}

/**
* Test if we add a new entry, the cached locations which are children of it
* should be invalidate
*/
@Test
public void testInvalidateCache() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment describing what the case to test is about.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your comments. I have added some comments. Pending jenkins. Please review again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The high level description should go as a javadoc.
You can add the particular comments inline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again. New commit here. Pending jenkins.

// Add the entry 1->/ and ensure cache update correctly
Map<String, String> map1 = getMountTableEntry("1", "/");
MountTable entry1 = MountTable.newInstance("/", map1);
mountTable.addEntry(entry1);
assertEquals("1->/", mountTable.getDestinationForPath("/").toString());
assertEquals("1->/testInvalidateCache/foo", mountTable
.getDestinationForPath("/testInvalidateCache/foo").toString());

// Add the entry 2->/testInvalidateCache and ensure the cached location
// under it is invalidated correctly
Map<String, String> map2 = getMountTableEntry("2", "/testInvalidateCache");
MountTable entry2 = MountTable.newInstance("/testInvalidateCache", map2);
mountTable.addEntry(entry2);
assertEquals("2->/testInvalidateCache",
mountTable.getDestinationForPath("/testInvalidateCache").toString());
assertEquals("2->/testInvalidateCache/foo", mountTable
.getDestinationForPath("/testInvalidateCache/foo").toString());
}
}