Index: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ObservationManagerImpl.java =================================================================== --- oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ObservationManagerImpl.java (revision 1875150) +++ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ObservationManagerImpl.java (working copy) @@ -234,12 +234,12 @@ boolean noLocal = filter.getNoLocal(); boolean noExternal = filter.getNoExternal() || listener instanceof ExcludeExternal; boolean noInternal = filter.getNoInternal(); - Set includePaths = getOakPaths(namePathMapper, filter.getAdditionalPaths()); + Set includePaths = getOakPaths(namePathMapper, filter.getAdditionalPaths(), "include"); String absPath = filter.getAbsPath(); if (absPath != null) { includePaths.add(namePathMapper.getOakPath(absPath)); } - Set excludedPaths = getOakPaths(namePathMapper, filter.getExcludedPaths()); + Set excludedPaths = getOakPaths(namePathMapper, filter.getExcludedPaths(), "exclude"); PathUtils.unifyInExcludes(includePaths, excludedPaths); if (oakEventFilter != null) { String[] includeGlobPaths = oakEventFilter.getIncludeGlobPaths(); @@ -388,10 +388,16 @@ return conditions; } - private static Set getOakPaths(NamePathMapper mapper, String[] paths) { + private static Set getOakPaths(NamePathMapper mapper, String[] paths, String type) + throws RepositoryException { Set oakPaths = newHashSet(); for (String path : paths) { - oakPaths.add(mapper.getOakPath(path)); + String oakPath = mapper.getOakPath(path); + if (oakPath != null) { + oakPaths.add(oakPath); + } else { + throw new RepositoryException("Invalid " + type + " path: " + path); + } } return oakPaths; } Index: oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationTest.java =================================================================== --- oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationTest.java (revision 1875150) +++ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationTest.java (working copy) @@ -34,11 +34,14 @@ import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED; import static org.apache.jackrabbit.oak.api.Type.STRING; +import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; import java.util.Arrays; @@ -870,6 +873,52 @@ } @Test + public void excludePathInvalid() { + assumeTrue(observationManager instanceof JackrabbitObservationManager); + ObservationManagerImpl oManager = (ObservationManagerImpl) observationManager; + ExpectationListener listener = new ExpectationListener(); + String invalidPath = TEST_PATH + "/[n]"; + JackrabbitEventFilter filter = new JackrabbitEventFilter() + .setAbsPath(TEST_PATH) + .setIsDeep(true) + .setExcludedPaths(TEST_PATH + "/c", invalidPath) + .setEventTypes(ALL_EVENTS); + try { + oManager.addEventListener(listener, filter); + fail("addEventListener() must fail with RepositoryException"); + } catch (RepositoryException e) { + // expected + assertThat(e.getMessage(), containsString("exclude")); + assertThat(e.getMessage(), containsString(invalidPath)); + } catch (Exception e) { + fail("Unexpected exception: " + e); + } + } + + @Test + public void includePathInvalid() { + assumeTrue(observationManager instanceof JackrabbitObservationManager); + ObservationManagerImpl oManager = (ObservationManagerImpl) observationManager; + ExpectationListener listener = new ExpectationListener(); + String invalidPath = TEST_PATH + "/[n]"; + JackrabbitEventFilter filter = new JackrabbitEventFilter() + .setAbsPath(TEST_PATH) + .setAdditionalPaths(invalidPath) + .setIsDeep(true) + .setEventTypes(ALL_EVENTS); + try { + oManager.addEventListener(listener, filter); + fail("addEventListener() must fail with RepositoryException"); + } catch (RepositoryException e) { + // expected + assertThat(e.getMessage(), containsString("include")); + assertThat(e.getMessage(), containsString(invalidPath)); + } catch (Exception e) { + fail("Unexpected exception: " + e); + } + } + + @Test public void parentPathExclude() throws ExecutionException, InterruptedException, RepositoryException { assumeTrue(observationManager instanceof JackrabbitObservationManager);