> On Nov. 16, 2017, 7:11 p.m., Vadim Spector wrote: > > sentry-core/sentry-core-common/src/main/java/org/apache/sentry/core/common/utils/PathUtils.java > > Line 220 (original), 225 (patched) > > <https://reviews.apache.org/r/63645/diff/2/?file=1884803#file1884803line225> > > > > at this point too late to check path != null. If the input path was > > originally null, then the first line will throw NullPointerException. If > > path is not null, then String.replaceAll() will never return null. > > > > Should, probably, just do > > if (path != null) { > > do stuff > > } else { > > throw new IllegalArgumentException("Null path"); > > } > > > > to put the most common case first. This function may be used a lot > > inside the loops, so it better be efficiant. > > > > As to making non-null path part of the contract, we have no way to > > ensure it, and when it's broken, it's betetr to have clear message.
I will remove the NULL check. Every code that uses NotificationProcessor#splitPath handles NULL String - Arjun ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/63645/#review191214 ----------------------------------------------------------- On Nov. 8, 2017, 3:03 p.m., Arjun Mishra wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/63645/ > ----------------------------------------------------------- > > (Updated Nov. 8, 2017, 3:03 p.m.) > > > Review request for sentry, Alexander Kolbasov, Sergio Pena, and Vadim Spector. > > > Repository: sentry > > > Description > ------- > > When retrieving full path image update, we split a path by "/" and create HMS > Path entries. However, the leading "/" presence will cause issues because on > splitting the value at index 0 will be empty. This will affect the creation > of HMS path entries. > > > Diffs > ----- > > > sentry-core/sentry-core-common/src/main/java/org/apache/sentry/core/common/utils/PathUtils.java > cef8bd734 > > sentry-core/sentry-core-common/src/test/java/org/apache/sentry/core/common/utils/TestPathUtils.java > 8419b9d5e > > sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java > 7217dea7a > > sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/NotificationProcessor.java > d92f23e63 > > sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java > cf83e7796 > > > Diff: https://reviews.apache.org/r/63645/diff/2/ > > > Testing > ------- > > mvn -f sentry-provider/sentry-provider-db/pom.xml test -Dtest=TestSentryStore > mvn -f sentry-core/sentry-core-common/pom.xml test -Dtest=TestPathUtils > > > Thanks, > > Arjun Mishra > >